Bug 1368083 - Pass -isysroot to bindgen. r=gps
When cross-compiling, rust-bindgen needs the -isysroot
flag we pass to the C++ compiler to find the correct
headers. Add a new BINDGEN_CFLAGS environment variable
for passing this and other relevant options, and reformat
its contents in toolchain.configure so we can use autoconf-
style template substitution to poke it into a bindgen.toml
file to be read by build scripts like build_gecko.rs.
Set this variable from the macosx/cross-mozconfig.common
to the same extra flags we pass to CXX so automation
builds work correctly with --enable-stylo.
MozReview-Commit-ID: 7wabObiFtVb
--- a/build/macosx/cross-mozconfig.common
+++ b/build/macosx/cross-mozconfig.common
@@ -24,16 +24,17 @@ CROSS_SYSROOT=$topsrcdir/MacOSX10.7.sdk
CROSS_PRIVATE_FRAMEWORKS=$CROSS_SYSROOT/System/Library/PrivateFrameworks
FLAGS="-target x86_64-apple-darwin11 -B $CROSS_CCTOOLS_PATH/bin -isysroot $CROSS_SYSROOT"
export CC="$topsrcdir/clang/bin/clang $FLAGS"
export CXX="$topsrcdir/clang/bin/clang++ $FLAGS"
export CPP="$topsrcdir/clang/bin/clang $FLAGS -E"
export LLVMCONFIG=$topsrcdir/clang/bin/llvm-config
export LDFLAGS="-Wl,-syslibroot,$CROSS_SYSROOT -Wl,-dead_strip"
+export BINDGEN_CFLAGS="$FLAGS"
export TOOLCHAIN_PREFIX=$CROSS_CCTOOLS_PATH/bin/x86_64-apple-darwin11-
export DSYMUTIL=$topsrcdir/clang/bin/llvm-dsymutil
export MKFSHFS=$topsrcdir/hfsplus-tools/newfs_hfs
export DMG_TOOL=$topsrcdir/dmg/dmg
export HFS_TOOL=$topsrcdir/dmg/hfsplus
export HOST_CC="$topsrcdir/clang/bin/clang"
export HOST_CXX="$topsrcdir/clang/bin/clang++"
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -892,16 +892,30 @@ include('compile-checks.configure')
@depends(have_64_bit,
try_compile(body='static_assert(sizeof(void *) == 8, "")',
check_msg='for 64-bit OS'))
def check_have_64_bit(have_64_bit, compiler_have_64_bit):
if have_64_bit != compiler_have_64_bit:
configure_error('The target compiler does not agree with configure '
'about the target bitness.')
+option(env='BINDGEN_CFLAGS',
+ nargs=1,
+ help='Options bindgen should pass to the C/C++ parser')
+
+@depends('BINDGEN_CFLAGS')
+@checking('bindgen cflags', lambda s: s if s and s.strip() else 'no')
+def bindgen_cflags(value):
+ if value and len(value):
+ # Reformat the env value for substitution into a toml list.
+ flags = value[0].split()
+ return ', '.join('"' + flag + '"' for flag in flags)
+ return ''
+
+set_config('BINDGEN_CFLAGS', bindgen_cflags)
@depends(c_compiler)
def default_debug_flags(compiler_info):
# Debug info is ON by default.
if compiler_info.type in ('msvc', 'clang-cl'):
return '-Zi'
return '-g'
new file mode 100644
--- /dev/null
+++ b/layout/style/bindgen.toml.in
@@ -0,0 +1,4 @@
+[build]
+args = [
+ @BINDGEN_CFLAGS@
+]
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -310,8 +310,12 @@ if CONFIG['COMPILE_ENVIRONMENT']:
'nsCSSPropsGenerated.inc',
]
css_props = GENERATED_FILES['nsCSSPropsGenerated.inc']
css_props.script = 'GenerateCSSPropsGenerated.py:generate'
css_props.inputs = [
'nsCSSPropsGenerated.inc.in',
'PythonCSSProps.h',
]
+
+ CONFIGURE_SUBST_FILES += [
+ 'bindgen.toml',
+ ]