summaryrefslogtreecommitdiffstats
path: root/build/moz.configure
diff options
context:
space:
mode:
Diffstat (limited to 'build/moz.configure')
-rw-r--r--build/moz.configure/android-ndk.configure17
-rw-r--r--build/moz.configure/bootstrap.configure76
-rw-r--r--build/moz.configure/compile-checks.configure18
-rw-r--r--build/moz.configure/flags.configure48
-rw-r--r--build/moz.configure/init.configure29
-rw-r--r--build/moz.configure/libraries.configure55
-rw-r--r--build/moz.configure/lto-pgo.configure10
-rw-r--r--build/moz.configure/memory.configure23
-rw-r--r--build/moz.configure/nss.configure2
-rw-r--r--build/moz.configure/pkg.configure2
-rw-r--r--build/moz.configure/toolchain.configure251
-rw-r--r--build/moz.configure/update-programs.configure6
-rw-r--r--build/moz.configure/windows.configure48
13 files changed, 451 insertions, 134 deletions
diff --git a/build/moz.configure/android-ndk.configure b/build/moz.configure/android-ndk.configure
index c19023a1ea..dd09142e4b 100644
--- a/build/moz.configure/android-ndk.configure
+++ b/build/moz.configure/android-ndk.configure
@@ -184,7 +184,7 @@ def android_lldb_server(target, host, ndk, lldb):
if lldb:
return lldb[0]
else:
- clang_format = "toolchains/llvm/prebuilt/%s-%s/lib64/clang"
+ clang_format = "toolchains/llvm/prebuilt/%s-%s/lib/clang"
llvm_lib = "lib/linux"
host_kernel = "windows" if host.kernel == "WINNT" else host.kernel.lower()
@@ -196,12 +196,21 @@ def android_lldb_server(target, host, ndk, lldb):
x for x in listdir(clang_path) if isdir(os.path.join(clang_path, x))
]
log.debug("Got %r" % clang_subdirs)
- if len(clang_subdirs) != 1:
+ if len(clang_subdirs) == 0:
die(
"Could not resolve lldb-server in %s. Please specify --with-android-lldb-server=/path/to/android/lldb-server"
% quote(clang_path)
)
- log.debug("Found version %s" % quote(clang_subdirs[0]))
+ sorted_versions = sorted(clang_subdirs, key=Version)
+ highest_version = sorted_versions[-1]
+ log.warning("Using highest version available: %s" % quote(highest_version))
+ log.warning(
+ " Available versions: "
+ + ", ".join(str(version) for version in sorted_versions)
+ )
+ log.warning(
+ "(To use an older version, please specify --with-android-lldb-server=/path/to/desired/android/lldb-server)"
+ )
if target.cpu == "x86":
target_cpu = "i386"
@@ -209,7 +218,7 @@ def android_lldb_server(target, host, ndk, lldb):
target_cpu = target.cpu
full_path = os.path.join(
- clang_path, clang_subdirs[0], llvm_lib, target_cpu, "lldb-server"
+ clang_path, highest_version, llvm_lib, target_cpu, "lldb-server"
)
log.debug("Trying %s" % quote(full_path))
diff --git a/build/moz.configure/bootstrap.configure b/build/moz.configure/bootstrap.configure
index daaff7cdaa..d8deddbb9e 100644
--- a/build/moz.configure/bootstrap.configure
+++ b/build/moz.configure/bootstrap.configure
@@ -36,10 +36,12 @@ option(
@depends_if("--enable-bootstrap")
-def enable_bootstrap(bootstrap):
+def want_bootstrap(bootstrap):
include = set()
exclude = set()
for item in bootstrap:
+ if item == "no-update":
+ continue
if item.startswith("-"):
exclude.add(item.lstrip("-"))
else:
@@ -55,34 +57,6 @@ def enable_bootstrap(bootstrap):
return match
-@depends(developer_options, "--enable-bootstrap", moz_fetches_dir)
-def bootstrap_search_path_order(developer_options, bootstrap, moz_fetches_dir):
- if moz_fetches_dir:
- log.debug("Prioritizing MOZ_FETCHES_DIR in toolchain path.")
- return "prepend"
-
- if bootstrap:
- log.debug(
- "Prioritizing mozbuild state dir in toolchain paths because "
- "bootstrap mode is enabled."
- )
- return "maybe-prepend"
-
- if developer_options:
- log.debug(
- "Prioritizing mozbuild state dir in toolchain paths because "
- "you are not building in release mode."
- )
- return "prepend"
-
- log.debug(
- "Prioritizing system over mozbuild state dir in "
- "toolchain paths because you are building in "
- "release mode."
- )
- return "append"
-
-
toolchains_base_dir = moz_fetches_dir | mozbuild_state_path
@@ -145,7 +119,8 @@ def bootstrap_path(path, **kwargs):
)
@depends(
- enable_bootstrap,
+ "--enable-bootstrap",
+ want_bootstrap,
toolchains_base_dir,
moz_fetches_dir,
bootstrap_toolchain_tasks,
@@ -163,7 +138,8 @@ def bootstrap_path(path, **kwargs):
@imports(_from="__builtin__", _import="open")
@imports(_from="__builtin__", _import="Exception")
def bootstrap_path(
- bootstrap,
+ enable_bootstrap,
+ want_bootstrap,
toolchains_base_dir,
moz_fetches_dir,
tasks,
@@ -294,20 +270,26 @@ def bootstrap_path(path, **kwargs):
return True
path = os.path.join(toolchains_base_dir, path_prefix, *path_parts)
- if bootstrap and bootstrap(path_parts[0]):
+ if enable_bootstrap and want_bootstrap(path_parts[0]):
+ exists = os.path.exists(path)
try:
- if not try_bootstrap(os.path.exists(path)):
+ # With --enable-bootstrap=no-update, we don't `try_bootstrap`, except
+ # when the toolchain can't be found.
+ if (
+ "no-update" not in enable_bootstrap or not exists
+ ) and not try_bootstrap(exists):
# If there aren't toolchain artifacts to use for this build,
# don't return a path.
return None
except Exception as e:
log.error("%s", e)
die("If you can't fix the above, retry with --disable-bootstrap.")
- # We re-test whether the path exists because it may have been created by
- # try_bootstrap. Automation will not have gone through the bootstrap
- # process, but we want to return the path if it exists.
- if os.path.exists(path):
- return path
+ if enable_bootstrap or enable_bootstrap.origin == "default":
+ # We re-test whether the path exists because it may have been created by
+ # try_bootstrap. Automation will not have gone through the bootstrap
+ # process, but we want to return the path if it exists.
+ if os.path.exists(path):
+ return path
return bootstrap_path
@@ -315,27 +297,15 @@ def bootstrap_path(path, **kwargs):
@template
def bootstrap_search_path(path, paths=original_path, **kwargs):
@depends(
- enable_bootstrap,
- dependable(path),
bootstrap_path(path, **kwargs),
- bootstrap_search_path_order,
paths,
original_path,
)
- def bootstrap_search_path(
- bootstrap, path, bootstrap_path, order, paths, original_path
- ):
+ def bootstrap_search_path(path, paths, original_path):
if paths is None:
paths = original_path
- if not bootstrap_path:
+ if not path:
return paths
- if order == "maybe-prepend":
- if bootstrap(path.split("/")[0]):
- order = "prepend"
- else:
- order = "append"
- if order == "prepend":
- return [bootstrap_path] + paths
- return paths + [bootstrap_path]
+ return [path] + paths
return bootstrap_search_path
diff --git a/build/moz.configure/compile-checks.configure b/build/moz.configure/compile-checks.configure
index a639a012f1..1dddc684da 100644
--- a/build/moz.configure/compile-checks.configure
+++ b/build/moz.configure/compile-checks.configure
@@ -436,6 +436,24 @@ def check_and_add_linker_flag(flag, compiler=None, when=None, check=True):
)
+# Like the compilation checks above, but for linker optimization flags.
+@dependable
+def linker_optimize_flags():
+ return namespace(ldflags=[])
+
+
+@template
+def check_and_add_linker_optimize_flag(flag, compiler=None, when=None, check=True):
+ return check_and_add_flags(
+ flag,
+ linker_optimize_flags,
+ [flag],
+ when=when,
+ check=check,
+ mode="link",
+ )
+
+
# Add the given flag to the list of linker flags for the build.
# - `flag` is the flag (e.g. -fno-sized-deallocation)
# - `when` (optional) is a @depends function or option name conditioning
diff --git a/build/moz.configure/flags.configure b/build/moz.configure/flags.configure
index 8354b9af34..d07d31f713 100644
--- a/build/moz.configure/flags.configure
+++ b/build/moz.configure/flags.configure
@@ -145,42 +145,43 @@ def file_prefix_map_flags(path_remapping, path_remappings, compiler):
set_config("MOZ_FILE_PREFIX_MAP_FLAGS", file_prefix_map_flags)
-@depends(c_compiler)
-def is_gcc(c_compiler):
- return c_compiler.type == "gcc"
-
-
-@depends(c_compiler)
-def is_gnu_cc(c_compiler):
- return c_compiler.type != "clang-cl"
-
-
-@depends(developer_options, when=is_gnu_cc)
+@depends(developer_options, when=building_with_gnu_cc)
def check_build_id_uuid(developer_options):
return developer_options
-@depends(developer_options, when=is_gnu_cc)
+@depends(developer_options, when=building_with_gnu_cc)
def check_build_id_sha1(developer_options):
return not developer_options
-check_and_add_flag("-pipe", when=is_gcc)
+check_and_add_flag("-pipe", when=building_with_gcc)
check_and_add_linker_flag("-Wl,--build-id=uuid", when=check_build_id_uuid)
check_and_add_linker_flag("-Wl,--build-id=sha1", when=check_build_id_sha1)
-check_and_add_asm_flag("-Wa,--noexecstack", when=is_gnu_cc)
-check_and_add_linker_flag("-Wl,-z,noexecstack", when=is_gnu_cc)
-check_and_add_linker_flag("-Wl,-z,text", when=is_gnu_cc)
-check_and_add_linker_flag("-Wl,-z,relro", when=is_gnu_cc)
-check_and_add_linker_flag("-Wl,-z,now", when=is_gnu_cc)
-check_and_add_linker_flag("-Wl,-z,nocopyreloc", when=is_gnu_cc)
+check_and_add_asm_flag("-Wa,--noexecstack", when=building_with_gnu_cc)
+check_and_add_linker_flag("-Wl,-z,noexecstack", when=building_with_gnu_cc)
+check_and_add_linker_flag("-Wl,-z,text", when=building_with_gnu_cc)
+check_and_add_linker_flag("-Wl,-z,relro", when=building_with_gnu_cc)
+check_and_add_linker_flag("-Wl,-z,now", when=building_with_gnu_cc)
+check_and_add_linker_flag("-Wl,-z,nocopyreloc", when=building_with_gnu_cc)
+check_and_add_linker_optimize_flag("-Wl,-dead_strip", when=target_is_darwin & ~dtrace)
-@depends("--enable-address-sanitizer", is_gnu_cc)
-def check_Bsymbolic(enable_asan, is_gnu_cc):
- return enable_asan and is_gnu_cc
+have_linker_support_ignore_unresolved = try_link(
+ flags=["-Wl,--ignore-unresolved-symbol,environ"],
+ check_msg="for --ignore-unresolved-symbol option to the linker",
+ when=building_with_gnu_cc & gcc_use_gnu_ld,
+)
+add_old_configure_assignment(
+ "HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED", have_linker_support_ignore_unresolved
+)
+
+
+@depends("--enable-address-sanitizer", building_with_gnu_cc)
+def check_Bsymbolic(enable_asan, building_with_gnu_cc):
+ return enable_asan and building_with_gnu_cc
# ASan assumes no symbols are being interposed, and when that happens,
@@ -195,4 +196,7 @@ check_and_add_linker_flag("-Wl,-Bsymbolic", when=check_Bsymbolic)
add_old_configure_assignment("_COMPILATION_ASFLAGS", asm_flags.asflags)
add_old_configure_assignment("_COMPILATION_HOST_ASFLAGS", asm_flags.host_asflags)
add_old_configure_assignment("_COMPILATION_LDFLAGS", linker_flags.ldflags)
+add_old_configure_assignment(
+ "_COMPILATION_OPTIMIZE_LDFLAGS", linker_optimize_flags.ldflags
+)
add_old_configure_assignment("_COMPILATION_HOST_LDFLAGS", linker_flags.host_ldflags)
diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure
index 11e22ee536..87120573a0 100644
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -525,6 +525,16 @@ def split_triplet(triplet, allow_wasi=False):
elif os.startswith("darwin"):
canonical_kernel = "Darwin"
canonical_os = "OSX"
+ elif os.startswith("ios"):
+ canonical_kernel = "Darwin"
+ canonical_os = "iOS"
+ # old-configure does plenty of tests against $target and $target_os
+ # and expects darwin for iOS, so make it happy.
+ sub_configure_alias = sub_configure_alias[: -len(os)] + "darwin"
+ # rust knows ios-sim, clang knows ios-simulator. We only take the
+ # former as --target, but we need to make clang happy.
+ if os == "ios-sim":
+ os = "ios-simulator"
elif os.startswith("dragonfly"):
canonical_os = canonical_kernel = "DragonFly"
elif os.startswith("freebsd"):
@@ -603,7 +613,7 @@ def split_triplet(triplet, allow_wasi=False):
# prefixes. We need to be more specific about the LLVM target on Mac
# so cross-language LTO will work correctly.
- if os.startswith("darwin"):
+ if os.startswith(("darwin", "ios")):
toolchain = "%s-apple-%s" % (cpu, os)
else:
toolchain = "%s-%s" % (cpu, os)
@@ -647,12 +657,13 @@ def help_host_target(help, host, target):
def config_sub(shell, triplet):
config_sub = os.path.join(os.path.dirname(__file__), "..", "autoconf", "config.sub")
- # Config.sub doesn't like the *-windows-msvc/*-windows-gnu triplets, so
+ # Config.sub doesn't like the *-windows-msvc/*-windows-gnu/*-ios-sim triplets, so
# munge those before and after calling config.sub.
suffix = None
munging = {
"-windows-msvc": "-mingw32",
"-windows-gnu": "-mingw32",
+ "-ios-sim": "-ios",
}
for check_suffix, replacement in munging.items():
if triplet.endswith(check_suffix):
@@ -734,6 +745,8 @@ def real_target(value, host, shell, project, application):
else ("arm", "androideabi")
)
return split_triplet(f"{target_cpu}-unknown-linux-{target_system}")
+ if project == "mobile/ios":
+ return split_triplet("aarch64-apple-ios")
return host
# If --target was only given a cpu arch, expand it with the
# non-cpu part of the host. For mobile/android, expand it with
@@ -744,6 +757,8 @@ def real_target(value, host, shell, project, application):
rest = "unknown-linux-android"
if target.startswith("arm"):
rest += "eabi"
+ elif project == "mobile/ios":
+ rest = "apple-ios"
else:
cpu, rest = host.alias.split("-", 1)
target = "-".join((target, rest))
@@ -832,6 +847,7 @@ add_old_configure_assignment("TARGET_CPU", target.cpu)
set_config("TARGET_RAW_CPU", target.raw_cpu)
set_config("TARGET_OS", target.os)
set_config("TARGET_RAW_OS", target.raw_os)
+set_config("TARGET_KERNEL", target.kernel)
set_config("TARGET_ENDIANNESS", target.endianness)
@@ -903,6 +919,15 @@ set_define("XP_MACOSX", target_is_osx)
@depends(target)
+def target_is_ios(target):
+ if target.kernel == "Darwin" and target.os == "iOS":
+ return True
+
+
+set_define("XP_IOS", target_is_ios)
+
+
+@depends(target)
def target_has_linux_kernel(target):
if target.kernel == "Linux":
return True
diff --git a/build/moz.configure/libraries.configure b/build/moz.configure/libraries.configure
new file mode 100644
index 0000000000..cac37e0ae5
--- /dev/null
+++ b/build/moz.configure/libraries.configure
@@ -0,0 +1,55 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+@template
+def check_clock_monotonic_support(lib=None, when=None):
+ check_msg = "for clock_gettime(CLOCK_MONOTONIC)"
+ flags = []
+
+ if lib is not None:
+ check_msg += f" in {lib}"
+ flags.append(f"-l{lib}")
+
+ check_when = building_with_gnu_cc
+ if when is not None:
+ check_when &= when
+
+ return try_link(
+ includes=["time.h"],
+ body="struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);",
+ check_msg=check_msg,
+ flags=flags,
+ when=check_when,
+ )
+
+
+have_raw_clock_monotonic_support = check_clock_monotonic_support()
+have_rt_clock_monotonic_support = check_clock_monotonic_support(
+ lib="rt", when=~have_raw_clock_monotonic_support
+)
+
+set_define(
+ "HAVE_CLOCK_MONOTONIC",
+ have_raw_clock_monotonic_support | have_rt_clock_monotonic_support,
+)
+set_config(
+ "HAVE_CLOCK_MONOTONIC",
+ have_raw_clock_monotonic_support | have_rt_clock_monotonic_support,
+)
+
+set_config("REALTIME_LIBS", ["-lrt"], when=have_rt_clock_monotonic_support)
+
+
+have_res_ninit = try_link(
+ includes=["sys/types.h", "netinet/in.h", "arpa/nameser.h", "resolv.h"],
+ body="int foo = res_ninit(&_res);",
+ check_msg="for res_ninit()",
+ flags=depends(when=building_linux)(["-D_BSD_SOURCE=1"]),
+ when=building_with_gnu_cc & ~target_is_netbsd & ~target_is_openbsd,
+)
+
+set_define("HAVE_RES_NINIT", have_res_ninit)
diff --git a/build/moz.configure/lto-pgo.configure b/build/moz.configure/lto-pgo.configure
index ab6a527fe4..5048b367e2 100644
--- a/build/moz.configure/lto-pgo.configure
+++ b/build/moz.configure/lto-pgo.configure
@@ -148,7 +148,10 @@ def pgo_flags(
use_ldflags = []
if orderfile:
if compiler.type == "clang-cl":
- use_ldflags += ["-ORDER:@" + orderfile]
+ use_ldflags += [
+ "-ORDER:@" + orderfile,
+ "/ignore:4037", # Disable warn missing order symbol
+ ]
elif linker.KIND == "ld64" or (linker.KIND == "lld" and target.os == "OSX"):
use_ldflags += ["-Wl,-order_file", orderfile]
elif linker.KIND == "lld":
@@ -316,7 +319,6 @@ def lto(
if (
target.kernel == "Darwin"
- and target.os == "OSX"
and "cross" in values
and select_linker.KIND == "ld64"
and not ld64_known_good
@@ -392,7 +394,7 @@ def lto(
# (For hot functions, PGO will put a multiplier on this limit.)
if target.os == "WINNT":
ldflags.append("-mllvm:-import-instr-limit=10")
- elif target.os == "OSX":
+ elif target.kernel == "Darwin":
ldflags.append("-Wl,-mllvm,-import-instr-limit=10")
elif c_compiler.type == "clang":
ldflags.append("-Wl,-plugin-opt=-import-instr-limit=10")
@@ -406,7 +408,7 @@ def lto(
ldflags.append("-opt:ltonewpassmanager")
if c_compiler.version >= "12.0.0":
ldflags.append("-mllvm:-import-hot-multiplier=30")
- elif target.os == "OSX":
+ elif target.kernel == "Darwin":
ldflags.append("-Wl,-mllvm,-import-hot-multiplier=30")
else:
if c_compiler.version < "13.0.0":
diff --git a/build/moz.configure/memory.configure b/build/moz.configure/memory.configure
index 4368ad8c86..477c9c58a4 100644
--- a/build/moz.configure/memory.configure
+++ b/build/moz.configure/memory.configure
@@ -25,6 +25,14 @@ set_define("MOZ_MEMORY", True, when="--enable-jemalloc")
add_old_configure_assignment("MOZ_MEMORY", True, when="--enable-jemalloc")
+@depends("--enable-jemalloc", moz_debug, win32_redist_dir)
+def check_redist(jemalloc, debug, win32_redist_dir):
+ if not jemalloc and not win32_redist_dir and not debug:
+ log.warning(
+ "When not building jemalloc, you need to build with --with-redist or set WIN32_REDIST_DIR."
+ )
+
+
@depends(milestone, build_project)
def replace_malloc_default(milestone, build_project):
if build_project == "memory":
@@ -63,16 +71,27 @@ set_config("MOZ_REPLACE_MALLOC_STATIC", replace_malloc_static)
# crash reporter.
@depends(
build_project,
+ milestone,
target,
when="--enable-jemalloc",
)
-def phc_default(build_project, target):
+def phc_default(build_project, milestone, target):
if build_project == "js":
return False
+ # PHC has a performance bottleneck on aarch64 (Bug 1874022) it's okay
+ # for nightly but not for release yet. To support unified builds on
+ # MacOS the x86_64 and aarch64 builds must match, so we disable PHC for
+ # x86_64 on MacOS late beta and release.
+ cpu_support = ("x86_64",)
+ if milestone.is_early_beta_or_earlier:
+ cpu_support = ("x86_64", "aarch64")
+ elif target.os == "OSX":
+ cpu_support = ()
+
# Both Linux32 and Win32 have frequent crashes when stack tracing (for
# unclear reasons), so PHC is enabled only on 64-bit only in both cases.
- return (target.cpu in ("x86_64", "aarch64")) and (
+ return (target.cpu in cpu_support) and (
(target.os == "GNU" and target.kernel == "Linux")
or (target.kernel == "WINNT")
or (target.os == "OSX")
diff --git a/build/moz.configure/nss.configure b/build/moz.configure/nss.configure
index 9e4802774a..2765a6502d 100644
--- a/build/moz.configure/nss.configure
+++ b/build/moz.configure/nss.configure
@@ -9,7 +9,7 @@ system_lib_option("--with-system-nss", help="Use system NSS")
imply_option("--with-system-nspr", True, when="--with-system-nss")
nss_pkg = pkg_check_modules(
- "NSS", "nss >= 3.98", when="--with-system-nss", config=False
+ "NSS", "nss >= 3.99", when="--with-system-nss", config=False
)
set_config("MOZ_SYSTEM_NSS", True, when="--with-system-nss")
diff --git a/build/moz.configure/pkg.configure b/build/moz.configure/pkg.configure
index 6beed205f1..44ef101ab0 100644
--- a/build/moz.configure/pkg.configure
+++ b/build/moz.configure/pkg.configure
@@ -16,7 +16,7 @@ pkg_config = check_prog(
bootstrap=depends(when=target_sysroot.bootstrapped)(lambda: "pkgconf"),
allow_missing=True,
when=compile_environment
- & depends(target.os)(lambda os: os not in ("WINNT", "OSX", "Android")),
+ & depends(target.os)(lambda os: os not in ("WINNT", "OSX", "iOS", "Android")),
)
diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure
index a8ab8bd698..5ab79daf24 100644
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -71,6 +71,24 @@ with only_when(target_is_osx):
return value[0]
+@imports("plistlib")
+@imports(_from="__builtin__", _import="open")
+@imports(_from="__builtin__", _import="Exception")
+def get_sdk_version(sdk):
+ with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as plist:
+ obj = plistlib.load(plist)
+ if not obj:
+ raise Exception(
+ "Error parsing SDKSettings.plist in the SDK directory: %s" % sdk
+ )
+ if "Version" not in obj:
+ raise Exception(
+ "Error finding Version information in SDKSettings.plist from the SDK: %s"
+ % sdk
+ )
+ return Version(obj["Version"])
+
+
with only_when(host_is_osx | target_is_osx):
# MacOS SDK
# =========
@@ -81,31 +99,14 @@ with only_when(host_is_osx | target_is_osx):
help="Location of platform SDK to use",
)
- @imports("plistlib")
- @imports(_from="__builtin__", _import="open")
- @imports(_from="__builtin__", _import="Exception")
- def get_sdk_version(sdk):
- with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as plist:
- obj = plistlib.load(plist)
- if not obj:
- raise Exception(
- "Error parsing SDKSettings.plist in the SDK directory: %s" % sdk
- )
- if "Version" not in obj:
- raise Exception(
- "Error finding Version information in SDKSettings.plist from the SDK: %s"
- % sdk
- )
- return Version(obj["Version"])
-
- def sdk_min_version():
+ def mac_sdk_min_version():
return "14.2"
@depends(
"--with-macos-sdk",
host,
bootstrap_path(
- "MacOSX{}.sdk".format(sdk_min_version()),
+ "MacOSX{}.sdk".format(mac_sdk_min_version()),
when=depends("--with-macos-sdk")(lambda x: not x),
allow_failure=True,
),
@@ -155,10 +156,10 @@ with only_when(host_is_osx | target_is_osx):
"tools are selected during the Xcode/Developer Tools installation."
% sdk
)
- if version < Version(sdk_min_version()):
+ if version < Version(mac_sdk_min_version()):
die(
'SDK version "%s" is too old. Please upgrade to at least %s. Try '
- "updating your system Xcode." % (version, sdk_min_version())
+ "updating your system Xcode." % (version, mac_sdk_min_version())
)
return sdk
@@ -195,6 +196,105 @@ with only_when(target_is_osx):
set_config("MACOS_PRIVATE_FRAMEWORKS_DIR", macos_private_frameworks)
+with only_when(target_is_ios):
+ # iOS deployment target version
+ # ==============================================================
+ # This needs to happen before any compilation test is done.
+
+ option(
+ "--enable-ios-target",
+ env="IPHONEOS_DEPLOYMENT_TARGET",
+ nargs=1,
+ default="17.4",
+ help="Set the minimum iOS version needed at runtime",
+ )
+
+ @depends_if("--enable-ios-target")
+ def ios_target(value):
+ return value[0]
+
+
+with only_when(target_is_ios):
+ # MacOS SDK
+ # =========
+ option(
+ "--with-ios-sdk",
+ env="IPHONEOS_SDK_DIR",
+ nargs=1,
+ help="Location of platform SDK to use",
+ )
+
+ def ios_sdk_min_version():
+ return "17.4"
+
+ @depends(target)
+ def ios_sdk_name(target):
+ return "iPhone{}{}.sdk".format(
+ "Simulator" if target.raw_os == "ios-sim" else "OS",
+ ios_sdk_min_version(),
+ )
+
+ @depends(
+ "--with-ios-sdk",
+ host,
+ target,
+ bootstrap_path(ios_sdk_name, when=depends("--with-ios-sdk")(lambda x: not x)),
+ )
+ @imports(_from="__builtin__", _import="Exception")
+ @imports(_from="os.path", _import="isdir")
+ @imports(_from="os", _import="listdir")
+ def ios_sdk(sdk, host, target, bootstrapped):
+ if bootstrapped:
+ sdk = [bootstrapped]
+ if sdk:
+ sdk = sdk[0]
+ try:
+ version = get_sdk_version(sdk)
+ except Exception as e:
+ die(e)
+ elif host.os == "OSX":
+ sdk_name = "iphonesimulator" if target.raw_os == "ios-sim" else "iphoneos"
+ sdk = check_cmd_output(
+ "xcrun", "--show-sdk-path", "--sdk", sdk_name, onerror=lambda: ""
+ ).rstrip()
+ if not sdk:
+ die(
+ "Could not find the iOS SDK. Please use --with-ios-sdk to give "
+ "the path to a iOS SDK."
+ )
+ # Scan the parent directory xcrun returns for the most recent SDK.
+ sdk_dir = os.path.dirname(sdk)
+ versions = []
+ for d in listdir(sdk_dir):
+ if d.lower().startswith(sdk_name):
+ try:
+ sdk = os.path.join(sdk_dir, d)
+ versions.append((get_sdk_version(sdk), sdk))
+ except Exception:
+ pass
+ version, sdk = max(versions)
+ else:
+ die(
+ "Need an iOS SDK when targeting iOS. Please use --with-ios-sdk "
+ "to give the path to a iOS SDK."
+ )
+
+ if not isdir(sdk):
+ die(
+ "SDK not found in %s. When using --with-ios-sdk, you must specify a "
+ "valid SDK. SDKs are installed when the optional cross-development "
+ "tools are selected during the Xcode installation." % sdk
+ )
+ if version < Version(ios_sdk_min_version()):
+ die(
+ 'SDK version "%s" is too old. Please upgrade to at least %s. Try '
+ "updating your system Xcode." % (version, ios_sdk_min_version())
+ )
+ return sdk
+
+ set_config("IPHONEOS_SDK_DIR", ios_sdk)
+
+
# GC rooting and hazard analysis.
# ==============================================================
option(env="MOZ_HAZARD", help="Build for the GC rooting hazard analysis")
@@ -467,7 +567,11 @@ def check_compiler(configure_cache, compiler, language, target, android_version)
if "--target=arm64-apple-darwin" not in compiler:
flags.append("--target=arm64-apple-darwin")
has_target = True
-
+ elif target.os == "iOS":
+ target_flag = "--target=%s" % toolchain
+ if target_flag not in compiler:
+ flags.append(target_flag)
+ has_target = True
elif (
not info.kernel
or info.kernel != target.kernel
@@ -673,14 +777,6 @@ def vc_compiler_version(vc_compiler_path):
@depends_if(vc_compiler_version)
-def is_vs2019_or_more(vc_compiler_version):
- return vc_compiler_version >= Version("19.20")
-
-
-add_old_configure_assignment("IS_VS2019_OR_MORE", is_vs2019_or_more)
-
-
-@depends_if(vc_compiler_version)
def msvs_version(vc_compiler_version):
# clang-cl emulates the same version scheme as cl. And MSVS_VERSION needs to
# be set for GYP on Windows.
@@ -688,8 +784,7 @@ def msvs_version(vc_compiler_version):
return "2022"
if vc_compiler_version >= Version("19.20"):
return "2019"
- if vc_compiler_version >= Version("19.10"):
- return "2017"
+ configure_error("Only Visual Studio 2019 or newer are supported")
return ""
@@ -702,12 +797,11 @@ clang_search_path = bootstrap_search_path("clang/bin")
@depends(
bootstrap_search_path("rustc/bin", when="MOZ_AUTOMATION"),
- bootstrap_search_path_order,
original_path,
)
@imports("os")
@imports(_from="os", _import="environ")
-def rust_search_path(rust_path, search_order, original_path):
+def rust_search_path(rust_path, original_path):
result = list(rust_path or original_path)
# Also add the rustup install directory for cargo/rustc.
cargo_home = environ.get("CARGO_HOME", "")
@@ -716,10 +810,7 @@ def rust_search_path(rust_path, search_order, original_path):
else:
cargo_home = os.path.expanduser(os.path.join("~", ".cargo"))
rustup_path = os.path.join(cargo_home, "bin")
- if search_order == "prepend":
- result.insert(0, rustup_path)
- else:
- result.append(rustup_path)
+ result.insert(0, rustup_path)
return result
@@ -1078,18 +1169,21 @@ def sysroot(host_or_target, target_sysroot=None):
sysroot_input,
host_or_target,
macos_sdk,
+ ios_sdk,
bootstrap_path(
depends(host_or_target)(lambda t: "sysroot-{}".format(t.toolchain)),
when=bootstrap_sysroot,
),
)
@imports("os")
- def sysroot(sysroot_input, host_or_target, macos_sdk, path):
+ def sysroot(sysroot_input, host_or_target, macos_sdk, ios_sdk, path):
version = None
if sysroot_input:
path = sysroot_input[0]
- elif host_or_target.kernel == "Darwin" and macos_sdk:
+ elif host_or_target.os == "OSX" and macos_sdk:
path = macos_sdk
+ elif host_or_target.os == "iOS" and ios_sdk:
+ path = ios_sdk
if path:
# Find the version of libstdc++ headears in the sysroot
include = os.path.join(path, "usr/include/c++")
@@ -1242,6 +1336,7 @@ def compiler(
host_or_target,
sysroot,
macos_target,
+ ios_target,
android_version,
vc_compiler_version,
multiarch_dir,
@@ -1259,6 +1354,7 @@ def compiler(
host_or_target,
sysroot,
macos_target,
+ ios_target,
android_version,
vc_compiler_version,
multiarch_dir,
@@ -1289,6 +1385,8 @@ def compiler(
if host_or_target.os == "OSX" and macos_target:
flags.append("-mmacosx-version-min=%s" % macos_target)
+ if host_or_target.os == "iOS" and ios_target:
+ flags.append("-mios-version-min=%s" % ios_target)
# When not given an explicit compatibility version, clang-cl tries
# to get one from MSVC, which might not even be the one used by the
@@ -1624,6 +1722,7 @@ host_windows_abi = windows_abi(host, host_c_compiler)
# Generic compiler-based conditions.
building_with_gcc = depends(c_compiler)(lambda info: info.type == "gcc")
+building_with_gnu_cc = depends(c_compiler)(lambda info: info.type != "clang-cl")
@depends(cxx_compiler, ccache_prefix)
@@ -2212,6 +2311,38 @@ set_config("WRAP_SYSTEM_INCLUDES", wrap_system_includes)
set_config("VISIBILITY_FLAGS", visibility_flags)
+# try harder, when checking for __thread support, see bug 521750 comment #33 and below
+# We pass linker_optimize_flags to the linker because if dead_strip is
+# enabled, the linker in xcode 4.1 will crash. Without this it would crash when
+# linking XUL.
+
+
+@depends(target, c_compiler)
+def check_thread(target, c_compiler):
+ if target.cpu in ("mips32", "mips64"):
+ # mips builds fail with TLS variables because of a binutils bug.
+ # See bug 528687
+ return False
+ if target.os == "Android":
+ # The custom dynamic linker doesn't support TLS variables
+ return False
+ if target.kernel == "OpenBSD":
+ # OpenBSD doesn't have TLS support, and the test succeeds with clang++
+ return False
+ return c_compiler.type != "clang-cl"
+
+
+set_define(
+ "HAVE_THREAD_TLS_KEYWORD",
+ try_link(
+ body="static __thread bool tlsIsMainThread = false; return tlsIsMainThread;",
+ flags=linker_optimize_flags.ldflags,
+ check_msg="for __thread keyword for TLS variables",
+ when=check_thread,
+ ),
+)
+
+
@template
def depend_cflags(host_or_target_c_compiler):
@depends(host_or_target_c_compiler)
@@ -3257,6 +3388,16 @@ def path_remappings(target, build_env, sysroot_path, windows_sdk_dir, vc_path):
return path_remappings
+@depends(target)
+def is_intel_target(target):
+ return target.cpu in ("x86", "x86_64")
+
+
+@depends(target)
+def is_aarch64_target(target):
+ return target.cpu == "aarch64"
+
+
set_config("MMX_FLAGS", ["-mmmx"])
set_config("SSE_FLAGS", ["-msse"])
set_config("SSE2_FLAGS", ["-msse2"])
@@ -3267,7 +3408,9 @@ set_config("AVX2_FLAGS", ["-mavx2"])
set_config(
"AVXVNNI_FLAGS",
["-mavxvnni"],
- try_compile(check_msg="for -mavxvnni support", flags=["-mavxvnni"]),
+ try_compile(
+ check_msg="for -mavxvnni support", flags=["-mavxvnni"], when=is_intel_target
+ ),
)
set_config(
"AVX512BW_FLAGS",
@@ -3275,6 +3418,7 @@ set_config(
try_compile(
check_msg="for -mavx512bw support",
flags=["-mavx512bw", "-mavx512f", "-mavx512dq", "-mavx512cd"],
+ when=is_intel_target,
),
)
@@ -3286,5 +3430,30 @@ set_config(
try_compile(
check_msg="for -mavx512vnni support",
flags=["-mavx512vnni", "-mavx512bw", "-mavx512f", "-mavx512dq", "-mavx512cd"],
+ when=is_intel_target,
+ ),
+)
+
+
+set_config(
+ "NEON_I8MM_FLAGS",
+ ["-march=armv8.2-a+i8mm"],
+ try_compile(
+ check_msg="for i8mm target feature",
+ flags=["-march=armv8.2-a+i8mm"],
+ when=is_aarch64_target,
),
)
+
+# dtrace support
+##
+option("--enable-dtrace", help="Build with dtrace support")
+
+dtrace = check_header(
+ "sys/sdt.h",
+ when="--enable-dtrace",
+ onerror=lambda: die("dtrace enabled but sys/sdt.h not found"),
+)
+
+set_config("HAVE_DTRACE", True, when=dtrace)
+set_define("INCLUDE_MOZILLA_DTRACE", True, when=dtrace)
diff --git a/build/moz.configure/update-programs.configure b/build/moz.configure/update-programs.configure
index 3be098308d..9db6ac18e5 100644
--- a/build/moz.configure/update-programs.configure
+++ b/build/moz.configure/update-programs.configure
@@ -7,9 +7,9 @@
# Updater
# ==============================================================
-@depends(build_project)
-def updater_default(build_project):
- return build_project != "mobile/android"
+@depends(build_project, target)
+def updater_default(build_project, target):
+ return build_project != "mobile/android" and target.os != "iOS"
option(
diff --git a/build/moz.configure/windows.configure b/build/moz.configure/windows.configure
index f23aa2a499..66b3a2bbfc 100644
--- a/build/moz.configure/windows.configure
+++ b/build/moz.configure/windows.configure
@@ -383,7 +383,7 @@ def lib_path_for(host_or_target):
compiler.compiler,
"/clang:--print-runtime-dir",
*compiler.flags,
- onerror=lambda: None
+ onerror=lambda: None,
).strip()
if runtime_dir and os.path.exists(runtime_dir):
# Put the clang runtime directory first, in case there is
@@ -479,3 +479,49 @@ host_link = check_prog(
)
add_old_configure_assignment("LINKER", link)
+
+option(
+ "--with-redist",
+ env="WIN32_REDIST_DIR",
+ nargs="?",
+ help="{Package|Don't package} redistributable MSVCRT",
+)
+
+
+@depends("--with-redist", "MOZ_AUTOMATION", c_compiler, vc_path, target)
+@imports("os")
+def win32_redist_dir(redist, automation, c_compiler, vc_path, target):
+ if len(redist):
+ if os.path.isdir(redist[0]):
+ return redist[0]
+ configure_error(f"Invalid Win32 Redist directory: {redist[0]}")
+ if redist or (
+ automation and redist.origin == "default" and c_compiler.type == "clang-cl"
+ ):
+ if not vc_path:
+ configure_error("Cannot ship redistributable MSVCRT without MSVC")
+ # It would be too simple if the Redist dir had the same version number as
+ # the MSVC one.
+ base_redist_path = os.path.join(
+ os.path.dirname(os.path.dirname(os.path.dirname(vc_path))), "Redist", "MSVC"
+ )
+ redist_target = {
+ "x86": "x86",
+ "x86_64": "x64",
+ "aarch64": "arm64",
+ }.get(target.cpu)
+ if redist_target and os.path.isdir(base_redist_path):
+ versions = [Version(v) for v in os.listdir(base_redist_path)]
+ redist_path = os.path.join(
+ base_redist_path,
+ str(max(v for v in versions if v.major)),
+ redist_target,
+ )
+ if os.path.isdir(redist_path):
+ crt_path = max(p for p in os.listdir(redist_path) if p.endswith("CRT"))
+ if crt_path:
+ return os.path.join(redist_path, crt_path)
+ configure_error("Could not find redistributable MSVCRT files")
+
+
+set_config("WIN32_REDIST_DIR", win32_redist_dir)