Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 909771 - sys-devel/binutils: does not build, "unrecognized option '--undefined-version'"
Summary: sys-devel/binutils: does not build, "unrecognized option '--undefined-version'"
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-06 13:53 UTC by wolfgang
Modified: 2023-08-13 14:10 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build log (binutils-2.50-r5-build.log,43.98 KB, text/x-log)
2023-07-06 13:53 UTC, wolfgang
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wolfgang 2023-07-06 13:53:13 UTC
Created attachment 865210 [details]
build log

From the build log:

```
 439   │ /bin/sh ./libtool  --tag=CC   --mode=link clang -Wall -Wextra -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -O2 -pipe -march=znver3      -Wl,-O1 -Wl,--as-needed -fuse-ld=lld -Wl,--as-needed -Wl,--undefined-version -o libsframe.la -rpath /usr/lib64/binutils/x86_64-pc-linux-gnu/2.40 libsframe_la-sfram
       │ e.lo libsframe_la-sframe-dump.lo libsframe_la-sframe-error.lo  
 440   │ libtool: link: clang -shared  -fPIC -DPIC  .libs/libsframe_la-sframe.o .libs/libsframe_la-sframe-dump.o .libs/libsframe_la-sframe-error.o   -Wl,--as-needed  -march=znver3 -Wl,-O1 -Wl,--undefined-version   -Wl,-soname -Wl,libsframe.so.0 -o .libs/libsframe.so.0.0.0
 441   │ /usr/bin/x86_64-pc-linux-gnu-ld.bfd: unrecognized option '--undefined-version'
 442   │ /usr/bin/x86_64-pc-linux-gnu-ld.bfd: use the --help option for usage information
 443   │ clang-16: [0m0;1;31merror: linker command failed with exit code 1 (use -v to see invocation)
```

My take from this is that for some reason the gnu linker is being used instead of the requested clang one, but I'm not really sure.
Comment 1 wolfgang 2023-07-06 19:00:28 UTC
Comment on attachment 865210 [details]
build log

The filename on the attachment is wrong, as seen in the logs this is for 2.40-r5
Comment 2 Luca Santarelli 2023-07-07 07:07:53 UTC
I have the same issue. It looks like libtool is calling directly clang as a linker, without passing the extra arguments present in LDFLAGS.

/etc/portage/make.conf:
LDFLAGS="-Wl,-O2 -Wl,--as-needed -fuse-ld=lld"

relevant build line:
libtool: link: clang -shared  -fPIC -DPIC  .libs/libsframe_la-sframe.o .libs/libsframe_la-sframe-dump.o .libs/libsframe_la-sframe-error.o   -Wl,--as-needed  -march=native -Wl,-O2 -Wl,--undefined-version   -Wl,-soname -Wl,libsframe.so.0 -o .libs/libsframe.so.0.0.0
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: unrecognized option '--undefined-version'

FWIW:
- forcing the environment variable LD=ld.lld for the merge, yields the same error.
- forcing the compilation (via package.env) through gcc, yelds the same error (as expected, since it would have used ld.bfd by default)
- forcing gcc to use mold (via LDFLAGS in package.env) yields the same error (it still calls ld.bfd)
- I have no idea why the running binutils (2.39-r5) was built w/o the option --undefined-version.
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-08-13 04:07:36 UTC
You need to put -fuse-ld=lld in CFLAGS/CXXFLAGS too.
Comment 4 Dennis Nezic 2023-08-13 13:34:50 UTC
That didn't work here. Did it work for anyone else?
Comment 5 Dennis Nezic 2023-08-13 13:38:33 UTC
(Ie. even though I was trying to use lld, it was still trying to use my gnu ld, and failing with that message.)
Comment 6 Dennis Nezic 2023-08-13 14:10:27 UTC
I got it to work using the standard gnu ld ... ie. by removing -fuse-ld=lld from {C,LD}FLAGS