From 297fff3aa468782693f2ddd099f9d0f6d85fa8f5 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 13 Jun 2024 20:21:56 +0000 Subject: [PATCH] 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 --- python/mozbuild/mozbuild/frontend/context.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index 621404d55461..05dd2a4e0d7d 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -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],