Describe the bug
If we run the configure script from a symlinked directory but call configure using the non-symlinked path (or vice versa), then flint compiles correctly, but fails at the linking step:
/usr/bin/ld: build/fmpz/fmpz.lo: in function `_fmpz_new_mpz':
/tmp/symlink-to-flint/src/fmpz/fmpz.c:86: multiple definition of `_fmpz_new_mpz'; build/fmpz/fmpz.lo:/tmp/symlink-to-flint/src/fmpz/fmpz.c:86: first defined here
/usr/bin/ld: build/fmpz/fmpz.lo:(.tbss+0x8): multiple definition of `mpz_free_num'; build/fmpz/fmpz.lo:(.tbss+0x8): first defined here
/usr/bin/ld: build/fmpz/fmpz.lo:(.tbss+0x10): multiple definition of `mpz_free_arr'; build/fmpz/fmpz.lo:(.tbss+0x10): first defined here
/usr/bin/ld: build/fmpz/fmpz.lo:(.tbss+0x0): multiple definition of `mpz_free_alloc'; build/fmpz/fmpz.lo:(.tbss+0x0): first defined here
/usr/bin/ld: build/fmpz/fmpz.lo: in function `_fmpz_clear_mpz':
/tmp/symlink-to-flint/src/fmpz/fmpz.c:145: multiple definition of `_fmpz_clear_mpz'; build/fmpz/fmpz.lo:/tmp/symlink-to-flint/src/fmpz/fmpz.c:145: first defined here
/usr/bin/ld: build/fmpz/fmpz.lo: in function `_fmpz_cleanup_mpz_content':
/tmp/symlink-to-flint/src/fmpz/fmpz.c:195: multiple definition of `_fmpz_cleanup_mpz_content'; build/fmpz/fmpz.lo:/tmp/symlink-to-flint/src/fmpz/fmpz.c:195: first defined here
/usr/bin/ld: build/fmpz/fmpz.lo: in function `_fmpz_cleanup':
/tmp/symlink-to-flint/src/fmpz/fmpz.c:223: multiple definition of `_fmpz_cleanup'; build/fmpz/fmpz.lo:/tmp/symlink-to-flint/src/fmpz/fmpz.c:223: first defined here
/usr/bin/ld: build/fmpz/fmpz.lo: in function `_fmpz_promote':
/tmp/symlink-to-flint/src/fmpz/fmpz.c:230: multiple definition of `_fmpz_promote'; build/fmpz/fmpz.lo:/tmp/symlink-to-flint/src/fmpz/fmpz.c:230: first defined here
/usr/bin/ld: build/fmpz/fmpz.lo: in function `_fmpz_promote_val':
/tmp/symlink-to-flint/src/fmpz/fmpz.c:242: multiple definition of `_fmpz_promote_val'; build/fmpz/fmpz.lo:/tmp/symlink-to-flint/src/fmpz/fmpz.c:242: first defined here
/usr/bin/ld: build/fmpz/fmpz.lo: in function `_fmpz_demote_val':
/tmp/symlink-to-flint/src/fmpz/fmpz.c:256: multiple definition of `_fmpz_demote_val'; build/fmpz/fmpz.lo:/tmp/symlink-to-flint/src/fmpz/fmpz.c:256: first defined here
/usr/bin/ld: build/fmpz/fmpz.lo: in function `_fmpz_init_readonly_mpz':
/tmp/symlink-to-flint/src/fmpz/fmpz.c:280: multiple definition of `_fmpz_init_readonly_mpz'; build/fmpz/fmpz.lo:/tmp/symlink-to-flint/src/fmpz/fmpz.c:280: first defined here
/usr/bin/ld: build/fmpz/fmpz.lo: in function `_fmpz_clear_readonly_mpz':
/tmp/symlink-to-flint/src/fmpz/fmpz.c:290: multiple definition of `_fmpz_clear_readonly_mpz'; build/fmpz/fmpz.lo:/tmp/symlink-to-flint/src/fmpz/fmpz.c:290: first defined here
make: *** [Makefile:436: build/fmpz_merged.lo] Error 1
The problem is that we link everything we've compiled in the source directory and the generated file fmpz.c from the build directory. If we call configure using the actual directory from the symlink or vice versa, then we think we're in an out of tree build, and so we end up linking the objects from the generated file twice, since it's really in the same directory.
This is a problem when using spack in macOS since builds are in /var, but that's really a symlink to /private/var.
Steps to reproduce
cd /tmp
git clone https://github.com/flint/flint
ln -s flint symlink-to-flint
cd symlink-to-flint
./bootstrap.sh
/tmp/flint/configure
make
# linking error
Expected behavior
FLINT should link correctly :)
System (please complete the following information):
- System CPU:
- Version of FLINT (if using Git, please specify commit): 58030f4
- How FLINT was configured (i.e. options pushed):
/tmp/flint/configure # no additional options
Output of configure
$ /tmp/flint/configure
checking build system type... zen-pc-linux-gnu
checking host system type... zen-pc-linux-gnu
checking how to print strings... printf
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert zen-pc-linux-gnu file names to zen-pc-linux-gnu format... func_convert_file_noop
checking how to convert zen-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for file... file
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... gawk
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking how to run the C preprocessor... gcc -E
checking if compiler is GCC... yes
checking if compiler is Clang... no
checking for inline... inline
checking whether byte ordering is bigendian... no
checking if memory is strongly-ordered... yes
checking for gmp.h... yes
checking if version of GMP is greater than 6.2.1... yes
checking if GMP defines mp_limb_t as unsigned long long int... no
checking for mpfr.h... yes
checking if version of MPFR is greater than 4.1.0... yes
checking for desired ABI... 64
checking for stdarg.h... yes
checking for math.h... yes
checking for float.h... yes
checking for errno.h... yes
checking for fenv.h... yes
checking for alloca.h... yes
checking for malloc.h... yes
checking for sys/param.h... yes
checking for windows.h... no
checking for pthread_np.h... no
checking for pthread.h... yes
checking for library containing atan2... -lm
checking for library containing __gmpz_init... -lgmp
checking for library containing __gmpn_mul_basecase... none required
checking for library containing __gmpn_gcd_11... none required
checking for library containing __gmpn_div_q... none required
checking for library containing __gmpn_invert_limb... none required
checking for library containing __gmpn_modexact_1_odd... none required
checking for library containing __gmpn_addmul_2... none required
checking for library containing __gmpn_add_n_sub_n... none required
checking for library containing __gmpn_add_nc... none required
checking for library containing __gmpn_sub_nc... none required
checking for library containing __gmpn_addlsh1_n... none required
checking for library containing __gmpn_addlsh1_n_ip1... no
checking for library containing __gmpn_rsh1sub_n... none required
checking for library containing __gmpn_rsh1add_n... none required
checking for library containing __gmpn_mulmid_n... none required
checking for library containing mpfr_init... -lmpfr
checking for library containing mpfr_round_p... none required
checking for library containing mpfr_mulhigh_n... none required
checking for library containing mpfr_sqrhigh_n... none required
checking whether gcc accepts -pthread... yes
checking if cpu_set_t is supported... yes
checking if alloca works... yes
checking for aligned_alloc... yes
checking for _aligned_malloc... no
checking whether gcc accepts -O3... yes
checking whether gcc accepts -pedantic... yes
checking whether gcc accepts -std=c11... yes
checking whether gcc accepts -Wall... yes
checking whether gcc accepts -Werror=implicit-function-declaration... yes
checking whether gcc accepts -Werror=newline-eof... no
checking whether gcc accepts -Wno-stringop-overread... yes
checking whether gcc accepts -Wno-stringop-overflow... yes
checking whether gcc accepts -Wmissing-prototypes... yes
checking whether gcc accepts -Wno-deprecated-declarations... yes
checking whether gcc accepts -march=znver1... yes
checking whether gcc accepts -funroll-loops... yes
checking for immintrin.h... yes
checking if system have required x86_64 instruction set for fft_small... (cached) yes
checking if system can use FLINT's fft_small module... yes
checking for suitable m4... m4
checking whether assembler supports --noexecstack option... yes
checking how to switch to text section... .text
checking how to switch to data section... .data
checking for assembler label suffix... :
checking for assembler global directive... .globl
checking for assembler global directive attribute...
checking if globals are prefixed by underscore... no
checking how to switch to read-only data section... .section .rodata
checking for assembler .type directive... .type $1,@$2
checking for assembler .size directive... .size $1,$2
checking for assembler local label prefix... .L
checking for assembler byte directive... .byte
checking if .align assembly directive is logarithmic... no
checking if the .align directive accepts an 0x90 fill in .text... yes
checking for assembler COFF type directives... no
creating config.m4
configure: creating ./config.status
config.status: creating Makefile
config.status: creating flint.pc
config.status: creating src/flint.h
config.status: creating src/config.h
config.status: creating src/flint-config.h
config.status: linking src/gmpcompat.h.in to src/gmpcompat.h
config.status: linking src/mpn_extras/x86_64/zen3/flint-mparam.h to src/flint-mparam.h
config.status: linking src/fmpz/link/fmpz_single.c to src/fmpz/fmpz.c
config.status: executing libtool commands
Additional context
Add any other context about the problem here.
Describe the bug
If we run the
configurescript from a symlinked directory but callconfigureusing the non-symlinked path (or vice versa), then flint compiles correctly, but fails at the linking step:The problem is that we link everything we've compiled in the source directory and the generated file
fmpz.cfrom the build directory. If we callconfigureusing the actual directory from the symlink or vice versa, then we think we're in an out of tree build, and so we end up linking the objects from the generated file twice, since it's really in the same directory.This is a problem when using spack in macOS since builds are in
/var, but that's really a symlink to/private/var.Steps to reproduce
Expected behavior
FLINT should link correctly :)
System (please complete the following information):
/tmp/flint/configure # no additional optionsOutput of
configureAdditional context
Add any other context about the problem here.