Bug 1902211 - Don't add compiler flags to host linker flags. r=firefox-build-system-reviewers,sergesanspaille

On clang-cl builds, the compiler and the linker are two completely different
things. The linker thankfully ignores the flags it doesn't know but
it's not optimal that it has to complain about them.

The historical reason we add compiler flags to linker flags is that some
flags, mostly related to optimization, such as -flto or --profile-generate,
need to be applied to both. This generally keeps being true for builds
using clang or GCC, although ideally we'd set things separately.

Anyways, generally speaking, we don't expect such flags to be necessary
for host linking, so let's start by cleaning up those. This does affect
all builds, but shouldn't matter.

It is worth noting that commands to link target things on clang-cl
builds actually use a different set of flags, so the linker doesn't end
up complaining about unknown arguments there.

Differential Revision: https://phabricator.services.mozilla.com/D213524
This commit is contained in:
Mike Hommey 2024-06-13 20:21:56 +00:00
parent 8732fa9c1d
commit 297fff3aa4

View File

@ -349,22 +349,22 @@ class HostCompileFlags(BaseCompileFlags):
(
"HOST_CXXFLAGS",
context.config.substs.get("HOST_CXXFLAGS"),
("HOST_CXXFLAGS", "HOST_CXX_LDFLAGS"),
("HOST_CXXFLAGS",),
),
(
"HOST_CFLAGS",
context.config.substs.get("HOST_CFLAGS"),
("HOST_CFLAGS", "HOST_C_LDFLAGS"),
("HOST_CFLAGS",),
),
(
"HOST_OPTIMIZE",
self._optimize_flags(),
("HOST_CFLAGS", "HOST_CXXFLAGS", "HOST_C_LDFLAGS", "HOST_CXX_LDFLAGS"),
("HOST_CFLAGS", "HOST_CXXFLAGS"),
),
("RTL", None, ("HOST_CFLAGS", "HOST_C_LDFLAGS")),
("RTL", None, ("HOST_CFLAGS",)),
("HOST_DEFINES", None, ("HOST_CFLAGS", "HOST_CXXFLAGS")),
("MOZBUILD_HOST_CFLAGS", [], ("HOST_CFLAGS", "HOST_C_LDFLAGS")),
("MOZBUILD_HOST_CXXFLAGS", [], ("HOST_CXXFLAGS", "HOST_CXX_LDFLAGS")),
("MOZBUILD_HOST_CFLAGS", [], ("HOST_CFLAGS",)),
("MOZBUILD_HOST_CXXFLAGS", [], ("HOST_CXXFLAGS",)),
(
"BASE_INCLUDES",
["-I%s" % main_src_dir, "-I%s" % context.objdir],