URL:
  <https://savannah.gnu.org/support/?111353>

                 Summary: _AC_FC_LIBRARY_LDFLAGS detects target feature flags
and linked libraries
                   Group: Autoconf
               Submitter: None
               Submitted: Wed 03 Dec 2025 12:18:40 PM UTC
                Priority: 5 - Unprioritized
                Severity: 3 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: [email protected]
             Open/Closed: Open
         Discussion Lock: Unlocked
        Operating System: GNU/Linux


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Wed 03 Dec 2025 12:18:40 PM UTC By: Anonymous
When building applications with LLVM/Clang, one might pass the flag
'-march=native' to configure to later on create an optimized build for his
machine.

Depending on the underlying system, this can lead to the following flag
showing up in a verbose compiler output:

-target-feature -lwp

The Autoconf macro _AC_FC_LIBRARY_LDFLAGS detects the -lwp as a linker flag,
and uses this one for further tests. Depending on the tests being done, this
can either fail during configure itself, or later during the application
build.

A build failure was e.g. discovered with ELPA:
https://gist.github.com/Crivella/e872817c7b5adcd1d238e17727b5b7d9

where this flag was being found in the linker step:

ld.lld: error: unable to find library -lwp
clang: error: linker command failed with exit code 1 (use -v to see
invocation)

---

As a fix, Autoconf should likely ignore all flags being passed via
'-target-feature', as these are CPU feature flags, and do not represent actual
libraries being linked. A proposed patch is attached.

---

For completeness, this is how a verbose output of LLVM 20.1.8 looks when
building with '-march=native':

clang version 20.1.8
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/EasyBuild/apps/software/LLVM/20.1.8-GCCcore-14.3.0/bin
Configuration file:
/opt/EasyBuild/apps/software/LLVM/20.1.8-GCCcore-14.3.0/bin/clang.cfg
Selected GCC installation:
/opt/EasyBuild/apps/software/GCCcore/14.3.0/lib/gcc/x86_64-pc-linux-gnu/14.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/opt/EasyBuild/apps/software/LLVM/20.1.8-GCCcore-14.3.0/bin/clang-20" -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free
-clear-ast-before-backend -disable-llvm-verifier -discard-value-names
-main-file-name test.c -mrelocation-model pic -pic-level 2 -pic-is-pie
-mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math
-mconstructor-aliases -funwind-tables=2 -target-cpu alderlake -target-feature
+prfchw -target-feature -cldemote -target-feature +avx -target-feature +aes
-target-feature +sahf -target-feature +pclmul -target-feature -xop
-target-feature +crc32 -target-feature -amx-fp8 -target-feature +xsaves
-target-feature -avx512fp16 -target-feature -usermsr -target-feature -sm4
-target-feature -egpr -target-feature +sse4.1 -target-feature -avx512ifma
-target-feature +xsave -target-feature +sse4.2 -target-feature -tsxldtrk
-target-feature -sm3 -target-feature +ptwrite -target-feature -widekl
-target-feature -movrs -target-feature +invpcid -target-feature +64bit
-target-feature +xsavec -target-feature -avx10.1-512 -target-feature
-avx512vpopcntdq -target-feature +cmov -target-feature -avx512vp2intersect
-target-feature -avx512cd -target-feature +movbe -target-feature -avxvnniint8
-target-feature -ccmp -target-feature -amx-int8 -target-feature -kl
-target-feature -avx10.1-256 -target-feature -sha512 -target-feature +avxvnni
-target-feature -rtm -target-feature +adx -target-feature +avx2
-target-feature +hreset -target-feature +movdiri -target-feature +serialize
-target-feature +vpclmulqdq -target-feature -avx512vl -target-feature -uintr
-target-feature -cf -target-feature +clflushopt -target-feature -raoint
-target-feature -cmpccxadd -target-feature +bmi -target-feature -amx-tile
-target-feature +sse -target-feature -avx10.2-256 -target-feature +gfni
-target-feature -avxvnniint16 -target-feature -amx-fp16 -target-feature -zu
-target-feature -ndd -target-feature +xsaveopt -target-feature +rdrnd
-target-feature -avx512f -target-feature -amx-bf16 -target-feature -avx512bf16
-target-feature -avx512vnni -target-feature -push2pop2 -target-feature +cx8
-target-feature -avx512bw -target-feature +sse3 -target-feature +pku
-target-feature -nf -target-feature -amx-tf32 -target-feature -amx-avx512
-target-feature +fsgsbase -target-feature -clzero -target-feature -mwaitx
-target-feature -lwp -target-feature +lzcnt -target-feature +sha
-target-feature +movdir64b -target-feature -ppx -target-feature -wbnoinvd
-target-feature -enqcmd -target-feature -amx-transpose -target-feature
-avx10.2-512 -target-feature -avxneconvert -target-feature -tbm
-target-feature -pconfig -target-feature -amx-complex -target-feature +ssse3
-target-feature +cx16 -target-feature +bmi2 -target-feature +fma
-target-feature +popcnt -target-feature -avxifma -target-feature +f16c
-target-feature -avx512bitalg -target-feature -rdpru -target-feature +clwb
-target-feature +mmx -target-feature +sse2 -target-feature +rdseed
-target-feature -avx512vbmi2 -target-feature -prefetchi -target-feature
-amx-movrs -target-feature +rdpid -target-feature -fma4 -target-feature
-avx512vbmi -target-feature +shstk -target-feature +vaes -target-feature
+waitpkg -target-feature -sgx -target-feature +fxsr -target-feature -avx512dq
-target-feature -sse4a -debugger-tuning=gdb [...] -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1
-fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig
-D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-9d970f.o -x c test.c
[...]
End of search list.
 "/opt/EasyBuild/apps/software/LLVM/20.1.8-GCCcore-14.3.0/bin/ld.lld" -z relro
--hash-style=gnu --eh-frame-hdr -m elf_x86_64 -pie -dynamic-linker
/lib64/ld-linux-x86-64.so.2 -o a.out /lib/x86_64-linux-gnu/Scrt1.o
/lib/x86_64-linux-gnu/crti.o
/opt/EasyBuild/apps/software/GCCcore/14.3.0/lib/gcc/x86_64-pc-linux-gnu/14.3.0/crtbeginS.o
[...] -L. -L. /tmp/test-9d970f.o -lgcc --as-needed -lgcc_s --no-as-needed -lc
-lgcc --as-needed -lgcc_s --no-as-needed
/opt/EasyBuild/apps/software/GCCcore/14.3.0/lib/gcc/x86_64-pc-linux-gnu/14.3.0/crtendS.o
/lib/x86_64-linux-gnu/crtn.o







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/support/?111353>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to