Bug 1729760 - Set -stdlib=libc++ for mac builds at the toolchain level. r=firefox-build-system-reviewers,nalexander

It's currently added manually to CXXFLAGS and bindgen flags, and is
notably missing from HOST_CXXFLAGS. However, setting it at the toolchain
level makes it inherited anywhere it's needed, including host builds and
bindgen.

Differential Revision: https://phabricator.services.mozilla.com/D126153
This commit is contained in:
Mike Hommey 2021-09-21 04:45:34 +00:00
parent d0e17ac0f5
commit e19e94bc52
5 changed files with 7 additions and 4 deletions

View File

@ -338,7 +338,7 @@ def basic_bindgen_cflags(target, is_unix, compiler_info, android_cflags, clang_f
"GNU": ["-DOS_LINUX=1"],
"NetBSD": ["-DOS_BSD=1", "-DOS_NETBSD=1"],
"OpenBSD": ["-DOS_BSD=1", "-DOS_OPENBSD=1"],
"OSX": ["-DOS_MACOSX=1", "-stdlib=libc++"],
"OSX": ["-DOS_MACOSX=1"],
"SunOS": ["-DOS_SOLARIS=1"],
"WINNT": [
"-DOS_WIN=1",

View File

@ -1149,6 +1149,9 @@ def compiler(
info = check_compiler(wrapper + [compiler] + flags, language, host_or_target)
if info.type == "clang" and language == "C++" and host_or_target.os == "OSX":
flags.append("-stdlib=libc++")
# Check that the additional flags we got are enough to not require any
# more flags. If we get an exception, just ignore it; it's liable to be
# invalid command-line flags, which means the compiler we're checking

View File

@ -417,7 +417,7 @@ case "$target" in
*-darwin*)
MOZ_OPTIMIZE_FLAGS="-O3"
CFLAGS="$CFLAGS -fno-common"
CXXFLAGS="$CXXFLAGS -fno-common -stdlib=libc++"
CXXFLAGS="$CXXFLAGS -fno-common"
DSO_LDOPTS=''
LDFLAGS="$LDFLAGS -lobjc"
# The ExceptionHandling framework is needed for Objective-C exception

View File

@ -493,7 +493,6 @@ dnl ========================================================
case "$target" in
*-darwin*)
MOZ_OPTIMIZE_FLAGS="-O3"
CXXFLAGS="$CXXFLAGS -stdlib=libc++"
DSO_LDOPTS=''
# The ExceptionHandling framework is needed for Objective-C exception
# logging code in nsObjCExceptions.h. Currently we only use that in debug

View File

@ -874,7 +874,7 @@ class OSXToolchainTest(BaseToolchainTest):
language="C",
)
DEFAULT_CLANGXX_RESULT = CompilerResult(
flags=["-std=gnu++17"],
flags=["-stdlib=libc++", "-std=gnu++17"],
version="5.0.2",
type="clang",
compiler="/usr/bin/clang++",
@ -1455,6 +1455,7 @@ class OSXCrossToolchainTest(BaseToolchainTest):
+ OSXToolchainTest.SYSROOT_FLAGS
+ {"flags": ["--target=i686-apple-darwin11.2.0"]},
"cxx_compiler": self.DEFAULT_CLANGXX_RESULT
+ {"flags": PrependFlags(["-stdlib=libc++"])}
+ OSXToolchainTest.SYSROOT_FLAGS
+ {"flags": ["--target=i686-apple-darwin11.2.0"]},
"host_c_compiler": self.DEFAULT_CLANG_RESULT,