flintlib / flint

FLINT (Fast Library for Number Theory)
http://www.flintlib.org
GNU Lesser General Public License v3.0
423 stars 241 forks source link

linker error during `make check` under macOS (duplicate symbol `_d_randtest2`) #2058

Open jaganmn opened 3 weeks ago

jaganmn commented 3 weeks ago

A colleague of mine is trying to check FLINT built under macOS. He does not hit #2048, perhaps because his architecture is x86_64 rather than aarch64 ... ? But he encounters a linker error at a later stage:

$ make check
<...>
   CC  mag/test/main.c
duplicate symbol '_d_randtest2' in:
     /private/var/folders/rr/q47s6xq93n1_lhj48t9rmqkr0000gn/T/main-4a8524.o
     ./libflint.a[85](double_interval_merged.o)
ld: 1 duplicate symbols
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)
make: *** [build/mag/test/main] Error 1

Indeed, I see d_randtest2 defined twice (in the double_interval module and again in the tests), but perhaps other linkers have ignored it. He is, like me, using the native Apple LLVM, not Homebrew LLVM ...

albinahlback commented 3 weeks ago

Thanks for noticing this! Looks like we should remove the one in double_interval.h as it is currently unused, but I'll let @fredrik-johansson decide when he gets back from vacation.

jaganmn commented 2 weeks ago

d_randtest2 seems to be used by di_randtest, defined just below. For now, I am working around this with:

diff -ruN flint-3.1.3/src/double_interval.h flint-3.1.3-patched/src/double_interval.h
--- flint-3.1.3/src/double_interval.h   2024-04-25 17:00:25
+++ flint-3.1.3-patched/src/double_interval.h   2024-08-28 10:47:50
@@ -183,6 +183,7 @@
 di_t arb_get_di(const arb_t x);
 void arb_set_di(arb_t res, di_t x, slong prec);

+static
 DOUBLE_INTERVAL_INLINE
 double d_randtest2(flint_rand_t state)
 {