Re: [CLN-list] Error building cln on M1 Mac
Hi Ron, (Sending this to mailing list, too.) On 3/5/23 01:44, Ron Garret wrote:
I tried to build cln on an M1 mac and got the following error:
depbase=`echo base/low/cl_low_div.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ../libtool --tag=CXX --mode=compile g++ -std=gnu++11 -DHAVE_CONFIG_H -I. -I../autoconf -I../include -I../src -I../include -I../src -g -O2 -MT base/low/cl_low_div.lo -MD -MP -MF $depbase.Tpo -c -o base/low/cl_low_div.lo base/low/cl_low_div.cc <http://cl_low_div.cc> &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: g++ -std=gnu++11 -DHAVE_CONFIG_H -I. -I../autoconf -I../include -I../src -I../include -I../src -g -O2 -MT base/low/cl_low_div.lo -MD -MP -MF base/low/.deps/cl_low_div.Tpo -c base/low/cl_low_div.cc <http://cl_low_div.cc> -fno-common -DPIC -o base/low/.libs/cl_low_div.o *base/low/cl_low_div.cc:13 <http://cl_low_div.cc:13>:8: **error: **declaration of 'divu_16_rest' in global scope conflicts with declaration with C language linkage* uint16 divu_16_rest; * ^* *./base/cl_low.h:447:21: note: *declared with C language linkage here extern "C" uint16 divu_16_rest; // -> Rest r * ^* *base/low/cl_low_div.cc:104 <http://cl_low_div.cc:104>:8: **error: **declaration of 'divu_32_rest' in global scope conflicts with declaration with C language linkage* uint32 divu_32_rest; * ^* *./base/cl_low.h:597:21: note: *declared with C language linkage here extern "C" uint32 divu_32_rest; // -> Rest r * ^* *base/low/cl_low_div.cc:210 <http://cl_low_div.cc:210>:8: **error: **declaration of 'divu_64_rest' in global scope conflicts with declaration with C language linkage* uint64 divu_64_rest; * ^* *./base/cl_low.h:987:21: note: *declared with C language linkage here extern "C" uint64 divu_64_rest; // -> Rest r * ^* 3 errors generated.
From a cursory inspection of the code I suspect this is a problem with the preprocessor. Specifically, this code in cl_low.h
#elifdefined(__arm__) && !defined(NO_ASM) ... #defineNEED_VAR_divu_16_rest
looks highly suspect to me. I have not traced the problem back any further than that.
I tried configure CPPFLAGS=-DNO_ASM but that did not fix the problem, which surprised me. It really looks like that should have worked.
Did you use the CLN off from git? I'm asking because patch 6edafa136b which is not in the released 1.3.6. All my best, -richy. -- Richard B. Kreckel <https://in.terlu.de/~kreckel/>
Richard B. Kreckel wrote:
Did you use the CLN off from git? I'm asking because patch 6edafa136b which is not in the released 1.3.6.
I reproduce the issue also with CLN 1.3.6. The problem is that while ==================================== typedef unsigned short uint16; extern "C" uint16 divu_16_rest; uint16 divu_16_rest; ==================================== and ==================================== typedef unsigned short uint16; namespace cln { extern "C" uint16 divu_16_rest; } uint16 cln::divu_16_rest; ==================================== compile OK, this one ==================================== typedef unsigned short uint16; namespace cln { extern "C" uint16 divu_16_rest; } uint16 divu_16_rest; ==================================== gives a compilation error. In other words, it's a namespace inconsistency problem (although you would naïvely expect that the namespace does not matter because of 'extern "C"'). The error message is just misleading. This error occurs with all versions of clang, but not with GCC. Bruno
On Mar 5, 2023, at 8:28 AM, Bruno Haible <bruno@clisp.org> wrote:
Richard B. Kreckel wrote:
Did you use the CLN off from git? I'm asking because patch 6edafa136b which is not in the released 1.3.6.
I reproduce the issue also with CLN 1.3.6.
This has apparently already been fixed, but the fix has not been published as a release. I copied cl_low_div.cc and cl_low_mul.cc from the git sources and after that was able to build successfully (but only with the NO_ASM flag defined). Unfortunately, make check failed: ===================================== cln 1.3.6: tests/test-suite.log ===================================== # TOTAL: 2 # PASS: 1 # SKIP: 0 # XFAIL: 0 # FAIL: 1 # XPASS: 0 # ERROR: 0 .. contents:: :depth: 2 FAIL: tests =========== Testing test_I_abs... Testing test_I_compare... Testing test_I_plus... Testing test_I_minus... Testing test_I_plus1... Testing test_I_minus1... Testing test_I_mul... Testing test_I_div... Testing test_I_gcd... Testing test_I_xgcd... Testing test_I_ash... Testing test_I_evenp... Testing test_I_oddp... Testing test_I_lognot... Testing test_I_logand... Testing test_I_logandc1... Testing test_I_logandc2... Testing test_I_logior... Testing test_I_logorc1... Testing test_I_logorc2... Testing test_I_logxor... Testing test_I_lognand... Testing test_I_lognor... Testing test_I_logeqv... Testing test_I_boole... Testing test_I_logbitp... Testing test_I_logtest... Testing test_I_ldb... Testing test_I_ldb_test... Testing test_I_mask_field... Testing test_I_dpb... Testing test_I_deposit_field... Testing test_I_logcount... Testing test_I_integer_length... Testing test_I_ord2... Testing test_I_power2p... Testing test_I_isqrt... Testing test_I_sqrtp... Testing test_I_io... FAIL tests (exit status: 134)
On Mar 5, 2023, at 9:08 AM, Ron Garret <ron@flownet.com> wrote:
On Mar 5, 2023, at 8:28 AM, Bruno Haible <bruno@clisp.org <mailto:bruno@clisp.org>> wrote:
Richard B. Kreckel wrote:
Did you use the CLN off from git? I'm asking because patch 6edafa136b which is not in the released 1.3.6.
I reproduce the issue also with CLN 1.3.6.
This has apparently already been fixed, but the fix has not been published as a release. I copied cl_low_div.cc <http://cl_low_div.cc/> and cl_low_mul.cc <http://cl_low_mul.cc/> from the git sources and after that was able to build successfully (but only with the NO_ASM flag defined).
Unfortunately, make check failed:
I took the plunge and installed autoconf and all the other thing you need to build the git version, and that worked. So I guess the only issue is that the latest official release is a little behind. rg
On Mar 5, 2023, at 6:28 AM, Richard B. Kreckel <kreckel@in.terlu.de> wrote:
Hi Ron,
(Sending this to mailing list, too.)
On 3/5/23 01:44, Ron Garret wrote:
I tried to build cln on an M1 mac and got the following error: depbase=`echo base/low/cl_low_div.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ../libtool --tag=CXX --mode=compile g++ -std=gnu++11 -DHAVE_CONFIG_H -I. -I../autoconf -I../include -I../src -I../include -I../src -g -O2 -MT base/low/cl_low_div.lo -MD -MP -MF $depbase.Tpo -c -o base/low/cl_low_div.lo base/low/cl_low_div.cc <http://cl_low_div.cc> &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: g++ -std=gnu++11 -DHAVE_CONFIG_H -I. -I../autoconf -I../include -I../src -I../include -I../src -g -O2 -MT base/low/cl_low_div.lo -MD -MP -MF base/low/.deps/cl_low_div.Tpo -c base/low/cl_low_div.cc <http://cl_low_div.cc> -fno-common -DPIC -o base/low/.libs/cl_low_div.o *base/low/cl_low_div.cc:13 <http://cl_low_div.cc:13>:8: **error: **declaration of 'divu_16_rest' in global scope conflicts with declaration with C language linkage* uint16 divu_16_rest; * ^* *./base/cl_low.h:447:21: note: *declared with C language linkage here extern "C" uint16 divu_16_rest; // -> Rest r * ^* *base/low/cl_low_div.cc:104 <http://cl_low_div.cc:104>:8: **error: **declaration of 'divu_32_rest' in global scope conflicts with declaration with C language linkage* uint32 divu_32_rest; * ^* *./base/cl_low.h:597:21: note: *declared with C language linkage here extern "C" uint32 divu_32_rest; // -> Rest r * ^* *base/low/cl_low_div.cc:210 <http://cl_low_div.cc:210>:8: **error: **declaration of 'divu_64_rest' in global scope conflicts with declaration with C language linkage* uint64 divu_64_rest; * ^* *./base/cl_low.h:987:21: note: *declared with C language linkage here extern "C" uint64 divu_64_rest; // -> Rest r * ^* 3 errors generated. From a cursory inspection of the code I suspect this is a problem with the preprocessor. Specifically, this code in cl_low.h #elifdefined(__arm__) && !defined(NO_ASM) ... #defineNEED_VAR_divu_16_rest looks highly suspect to me. I have not traced the problem back any further than that. I tried configure CPPFLAGS=-DNO_ASM but that did not fix the problem, which surprised me. It really looks like that should have worked.
Did you use the CLN off from git?
No. I don't have autoconf installed so I was using the 1.3.6 release.
I'm asking because patch 6edafa136b which is not in the released 1.3.6.
Thanks, that was the problem. rg
participants (3)
-
Bruno Haible
-
Richard B. Kreckel
-
Ron Garret