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"], "GNU": ["-DOS_LINUX=1"],
"NetBSD": ["-DOS_BSD=1", "-DOS_NETBSD=1"], "NetBSD": ["-DOS_BSD=1", "-DOS_NETBSD=1"],
"OpenBSD": ["-DOS_BSD=1", "-DOS_OPENBSD=1"], "OpenBSD": ["-DOS_BSD=1", "-DOS_OPENBSD=1"],
"OSX": ["-DOS_MACOSX=1", "-stdlib=libc++"], "OSX": ["-DOS_MACOSX=1"],
"SunOS": ["-DOS_SOLARIS=1"], "SunOS": ["-DOS_SOLARIS=1"],
"WINNT": [ "WINNT": [
"-DOS_WIN=1", "-DOS_WIN=1",

View file

@ -1149,6 +1149,9 @@ def compiler(
info = check_compiler(wrapper + [compiler] + flags, language, host_or_target) 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 # 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 # 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 # invalid command-line flags, which means the compiler we're checking

View file

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

View file

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

View file

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