Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 751835 - usr-ldscript.eclass: ld: unknown option: --version on MacOS
Summary: usr-ldscript.eclass: ld: unknown option: --version on MacOS
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: AMD64 OS X
: High trivial (vote)
Assignee: Gentoo Prefix
Keywords: PATCH
Depends on:
Blocks: 755644
  Show dependency tree
Reported: 2020-10-30 04:21 UTC by Alexander Bezrukov
Modified: 2021-08-29 13:43 UTC (History)
3 users (show)

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

A fix for querying ld kind (gold-check.patch,718 bytes, patch)
2020-10-30 04:21 UTC, Alexander Bezrukov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Bezrukov 2020-10-30 04:21:27 UTC
Created attachment 669239 [details, diff]
A fix for querying ld kind

I am trying to bootstrap prefix on MacOS 10.14 and 10.15. Stage2 bootstrapping produces a bunch of errors and similar noise and I am trying to fix at least some of error messages. The previous bug reports in the series are these: bug 751037, bug 751067, bug 751406, bug 751412, bug 751421, bug 751511.

This bug report deals with the
   ld: unknown option: --version
error message which pollutes the build log.

After superficial analysis it becomes clear that the error message is indeed benign but it is also easy to fix and fixing it hopefully will save some time for people analysing build failures on non-GNU/Linux platforms. The error is produced by the gen_usr_ldscript() function from the usr-ldscript.eclass. This function checks if the ld is the GNU gold and for this purpose it calls $(tc-getLD) --version.

The problem is that Xcode's ld doesn't accept --version option, -v is used instead. GNU ld also accepts -v (synonymous to --version) but replacing --version to -v is a wrong thing to do, for if I remember correctly, Sun's ld accepts --version but does not accept -v (it uses -V instead). FreeBSD version of ld accepts all three -v, -V and --version with subtle differences (-v does not prevent ld from linking is object files are specified). But as far as GNU ld is only concerned, I suggest to just do a minimal change which would mute the error. The patch is attached.

I am not sure about -Wl,--verbose behaviour w.r.t. all ever existed variants of gold linkers on all platforms and the comment in the eclass looks misleading (it discusses gold linker at large but the check is for the GNU packaged only). But at least this change wouldn't add breakage and wouldn't hide error messages should these appear.

Note: A similar problem exists in tc-ld-is-gold() in the toolchain-funcs.eclass.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-10-30 07:38:38 UTC
Could you submit this patch to gentoo-dev mailing list for review?
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-11-20 01:29:42 UTC
Yes, could you?
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-03-16 15:58:25 UTC
Ping - Alexander, would you mind posting this to the gentoo-dev mailing list?
Comment 4 Fabian Groffen gentoo-dev 2021-08-29 13:43:17 UTC
the xtools ld we currently use supports --version (was specifically added to be more compatible with GNU)