-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meson ignores LDFLAGS when finding the linker #6377
Comments
You can put The reason that we don't look in LDFLAGS is that LDFLAGS is passed to every compiler, and passing a bogus flag This is closely related to #6413 |
No, CC and CFLAGS don't really work. Putting
|
I have a vague memory of reporting this to libgsl ML but got no response. This is error-prone how they have these libraries. |
Don't set compiler flags, use the overriding kwarg instead: target(..., override_options: ['b_asneeded=false'] |
fuzz-introspector passes -fuse-ld=gold and -flto using CFLAGS/LDFLAGS and due to mesonbuild/meson#6377 (comment) and mesonbuild/meson#6377 it doesn't mix well with meson. It's possible to build systemd with duct tape there using something like google/oss-fuzz#7583 (comment) but apparently even with gold and lto some parts of systemd are missing from reports (presumably due to google/oss-fuzz#7598). Let's just fail here for now to make it clear that fuzz-introspector isn't supported.
fuzz-introspector passes -fuse-ld=gold and -flto using CFLAGS/LDFLAGS and due to mesonbuild/meson#6377 (comment) and mesonbuild/meson#6377 it doesn't mix well with meson. It's possible to build systemd with duct tape there using something like google/oss-fuzz#7583 (comment) but apparently even with gold and lto some parts of systemd are missing from reports (presumably due to google/oss-fuzz#7598). Let's just fail here for now to make it clear that fuzz-introspector isn't supported.
I think this is related to an issue I've hit today (reported by @unhappy-ending) when using a linker-specific argument (like
For example, with
And from meson-log.txt:
I guess there's two solutions:
|
In general you should not have linker args in This ticket was originally reported about passing -fuse-ld in LDFLAGS instead, which is correct and proper use of the two. This works, although meson's log status doesn't notice it in compiler/linker detection. |
It's hard because if setting this globally as a user, you can't get it right. Meson is right to distinguish between CFLAGS and LDFLAGS in this way and for Meson packages, you can assume it's done correctly, but you can't in general assume LDFLAGS will be passed to the driver, and not e.g. LD directly for all packages (cheesy old Makefiles, blah blah). I guess on our end (Gentoo's), we could possibly do some mangling of CFLAGS in meson.eclass when it contains things like this instead, as we know the handling is right already there. |
Lol, ouch. Is it viable in this case to have those cheesy old Makefiles get hacks applied to them i.e. |
Workarounds the issue where compile tests would fail with `-Werror=ignored-optimization-argument` because Meson doesn't allow linker flags in `CFLAGS` or `CXXFLAGS`. See: mesonbuild/meson#6377 (comment) Thanks to @evverx for the idea: google#7583 (comment) This is a fragile workaround, but it looks like there isn't much else we can do.
Workarounds the issue where compile tests would fail with `-Werror=ignored-optimization-argument` because Meson doesn't allow linker flags in `CFLAGS` or `CXXFLAGS`. See: mesonbuild/meson#6377 (comment) Thanks to @evverx for the idea: #7583 (comment) This is a fragile workaround, but it looks like there isn't much else we can do.
Describe the bug
Sometimes
LDFLAGS
includes options which can affect how the compiler chooses the linker. However, Meson seems to ignoreLDFLAGS
when determining the linker, causing wrong values to be shown when options such as-B
and-fuse-ld
exist inLDFLAGS
.To Reproduce
Create a dummy project:
Run meson with the default environment.
Run meson with
-fuse-ld
option added toCC
. This is OK.Run meson with
-fuse-ld
option added toLDFLAGS
. This is not OK.You can also use
-B
to test the problem.Expected behavior
Meson should show the same value regardless of how options are added. Putting
-fuse-ld=bfd
into eitherCC
orLDFLAGS
should make meson showGNU ld.bfd
instead of the defaultlld
.system parameters
FreeBSD 12.1 amd64 (with clang 8.0.1 and lld 8.0.1 as the default compiler and linker), Python 3.7.5, Meson 0.52.999 (commit 7981308), Ninja 1.9.0.
GNU ld.bfd 2.33.1 is installed in
/usr/local
as an alternative linker.The text was updated successfully, but these errors were encountered: