Bug 1293840 - Determine HAVE_64BIT_BUILD from --target. r?chmanchester
Until now, HAVE_64BIT_BUILD was entirely determined by a compiler check.
But we didn't run the check on e.g. artifact builds, while relying on
its result for some non-compilation related things, leading to subtle
discrepancies.
This changes the configure check to derive HAVE_64BIT_BUILD from bitness
determined by the target CPU, and double checked with a compiler check.
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -316,16 +316,17 @@ def shell(value, mozillabuild):
# ==============================================================
option('--host', nargs=1, help='Define the system type performing the build')
option('--target', nargs=1,
help='Define the system type where the resulting executables will be '
'used')
@imports(_from='mozbuild.configure.constants', _import='CPU')
+@imports(_from='mozbuild.configure.constants', _import='CPU_bitness')
@imports(_from='mozbuild.configure.constants', _import='Endianness')
@imports(_from='mozbuild.configure.constants', _import='Kernel')
@imports(_from='mozbuild.configure.constants', _import='OS')
def split_triplet(triplet):
# The standard triplet is defined as
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# There is also a quartet form:
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
@@ -414,16 +415,17 @@ def split_triplet(triplet):
canonical_cpu = 'aarch64'
endianness = 'little'
else:
die('Unknown CPU type: %s' % cpu)
return namespace(
alias=triplet,
cpu=CPU(canonical_cpu),
+ bitness=CPU_bitness[canonical_cpu],
kernel=Kernel(canonical_kernel),
os=OS(canonical_os),
endianness=Endianness(endianness),
raw_cpu=cpu,
raw_os=os,
# Toolchains, most notably for cross compilation may use cpu-os
# prefixes.
toolchain='%s-%s' % (cpu, os),
@@ -464,16 +466,26 @@ def target(value, host, shell):
def cross_compiling(host, target):
return host != target
set_config('CROSS_COMPILE', cross_compiling)
set_define('CROSS_COMPILE', cross_compiling)
add_old_configure_assignment('CROSS_COMPILE', cross_compiling)
+@depends(target)
+def have_64_bit(target):
+ if target.bitness == 64:
+ return True
+
+set_config('HAVE_64BIT_BUILD', have_64_bit)
+set_define('HAVE_64BIT_BUILD', have_64_bit)
+add_old_configure_assignment('HAVE_64BIT_BUILD', have_64_bit)
+
+
# Autoconf needs these set
@depends(host)
def host_for_old_configure(host):
return '--host=%s' % host.alias
add_old_configure_arg(host_for_old_configure)
@depends(host, target)
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -761,22 +761,24 @@ c_compiler = compiler('C', target)
cxx_compiler = compiler('C++', target, c_compiler=c_compiler)
host_c_compiler = compiler('C', host, other_compiler=c_compiler)
host_cxx_compiler = compiler('C++', host, c_compiler=host_c_compiler,
other_compiler=cxx_compiler,
other_c_compiler=c_compiler)
include('compile-checks.configure')
-have_64_bit = try_compile(body='static_assert(sizeof(void *) == 8, "")',
- check_msg='for 64-bit OS')
+@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.')
-set_config('HAVE_64BIT_BUILD', have_64_bit)
-set_define('HAVE_64BIT_BUILD', have_64_bit)
-add_old_configure_assignment('HAVE_64BIT_BUILD', have_64_bit)
@depends(c_compiler)
def default_debug_flags(compiler_info):
# Debug info is ON by default.
if compiler_info.type == 'msvc':
return '-Zi'
return '-g'
--- a/python/mozbuild/mozbuild/configure/constants.py
+++ b/python/mozbuild/mozbuild/configure/constants.py
@@ -33,33 +33,35 @@ Kernel = EnumString.subclass(
'FreeBSD',
'kFreeBSD',
'Linux',
'NetBSD',
'OpenBSD',
'WINNT',
)
-CPU = EnumString.subclass(
- 'aarch64',
- 'Alpha',
- 'arm',
- 'hppa',
- 'ia64',
- 'mips32',
- 'mips64',
- 'ppc',
- 'ppc64',
- 's390',
- 's390x',
- 'sparc',
- 'sparc64',
- 'x86',
- 'x86_64',
-)
+CPU_bitness = {
+ 'aarch64': 64,
+ 'Alpha': 32,
+ 'arm': 32,
+ 'hppa': 32,
+ 'ia64': 64,
+ 'mips32': 32,
+ 'mips64': 64,
+ 'ppc': 32,
+ 'ppc64': 64,
+ 's390': 32,
+ 's390x': 64,
+ 'sparc': 32,
+ 'sparc64': 64,
+ 'x86': 32,
+ 'x86_64': 64,
+}
+
+CPU = EnumString.subclass(*CPU_bitness.keys())
Endianness = EnumString.subclass(
'big',
'little',
)
# The order of those checks matter
CPU_preprocessor_checks = OrderedDict((