LDFLAGS not passed correctly?

I am trying to use LLVM linker (lld aka ld.lld). So I ran configure with LDFLAGS="-fuse-ld=lld -Wl,–threads=8". Configures runs OK and I at the end:

Octave is now configured for x86_64-pc-linux-gnu

  Source directory:              ..
  Installation prefix:           /usr/local
  C compiler:                    clang  -pthread -fopenmp  -Wall -W -Wshadow -Wformat -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wcast-align -Wcast-qual -O3 -march=native -mavx -mavx2
  C++ compiler:                  clang++  -pthread -fopenmp  -Wall -W -Wshadow -Woverloaded-virtual -Wold-style-cast -Wformat -Wpointer-arith -Wwrite-strings -Wcast-align -Wcast-qual -O3 -march=native -mavx -mavx2
  Fortran compiler:              gfortran -O3 -march=native -mavx -mavx2 -std=legacy
  CPPFLAGS:                      
  Fortran libraries:              -L/usr/lib/gcc/x86_64-redhat-linux/8 -L/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/8/../../.. -lgfortran -lm -lquadmath
  Lex libraries:                 
  LIBS:                          -lutil -lpthread -lm 
  LDFLAGS:                       -fuse-ld=lld -Wl,--threads=8
  Extra LDFLAGS:                 

Yet during the compile, it fais with (make -j1 V=1):

/bin/sh ./libtool  --tag=CXX   --mode=link clang++ -fPIC -pthread -fopenmp -Wall -W -Wshadow -Woverloaded-virtual -Wold-style-cast -Wformat -Wpointer-arith -Wwrite-strings -Wcast-align -Wcast-qual -fvisibility=hidden -O3 -march=native -mavx -mavx2 -avoid-version -module   -fuse-ld=lld -Wl,--threads=8  -fuse-ld=lld -Wl,--threads=8 -o libinterp/dldfcn/__delaunayn__.la -rpath /usr/local/lib/octave/7.0.0 libinterp/dldfcn/__delaunayn___la-__delaunayn__.lo  -lqhull_r -lutil -lpthread -lm 
libtool: link: clang++  -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/8/crtbeginS.o  libinterp/dldfcn/.libs/__delaunayn___la-__delaunayn__.o   -lqhull_r -lutil -L/usr/lib/gcc/x86_64-redhat-linux/8 -L/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/8/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib -lstdc++ -lm -lomp -lpthread -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-redhat-linux/8/crtendS.o /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crtn.o  -pthread -fopenmp -O3 -march=native -mavx -mavx2 -Wl,--threads=8 -Wl,--threads=8   -pthread -fopenmp -Wl,-soname -Wl,__delaunayn__.so -o libinterp/dldfcn/.libs/__delaunayn__.so
clang-12: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
clang-12: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
/usr/bin/ld: unrecognized option '--threads=8'
/usr/bin/ld: use the --help option for usage information
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Makefile:12763: libinterp/dldfcn/__delaunayn__.la] Error 1

Note in the libtool: link: clang++ … line “-fuse-ld=lld” option is missing, so the default ld
(/usr/bin/ld → /usr/bin/ld.bfd) is used and it does not understand --threads=8 options.

This does not look right to me.

IIUC, this is an issue with libtool 2.4.6. It doesn’t pass through the -fuse-ld flag.
See e.g.: slackbuilds/libtool-2.4.6-fuse-ld.patch at main · PhantomX/slackbuilds (github.com)

I’m not sure if Fedora applies a similar patch when packaging libtool. It looks like it is not…

Edit: Like I’ve already written in the other thread, it might be possible to override the command libtool is using for LD by setting lt_cv_path_LD=/usr/bin/ld.lld when configuring. I haven’t tested though.

I haven’t been able to determine when it was added, but that change appears to be included in libtool 2.4.6-15 on my Debian testing system.

That was probably this patch:
Package: libtool | Debian Sources

Finally found Fedora’s build repository:
Tree - rpms/libtool - src.fedoraproject.org

It indeed doesn’t look like they patch that libtool bug.

Thanks! I filled a bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=2024647

1 Like

Yes, that patch, but it wasn’t clear to me how to find when it was added to the Debian package. Are those packages in some kind of revision control system, or just each one is a separate collection of files. I can’t tell.

Looks like it was patched in Debian about 2 years ago:
From upstream: add support for --use-ld= flag. Closes: #920529 (26c23f95) · Commits · Alastair McKinstry / libtool · GitLab (debian.org)

Perhaps I am doing something wrong or may be some other tools involved here.
I patched libtool locally and it did not make any difference. Note the string passed to libtool
(from the error text above) does not contain -fuse-ld already, so something else sanitized it out?!

Did you build from a clean tree after patching libtool? I’m not sure which step re-creates the libtool script in the build tree. Maybe deleting it manually before configure helps?

I build off the source tree. So deleting this build directory and re-running bootstrap and configure
was not enough. But it worked when I re-cloned the entire source tree.

Thanks again.