From 4be9c3acc017351aaa3eea8ffce8a05ff8bb62ad Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Wed, 3 Jul 2024 19:50:05 +0000 Subject: [PATCH] Bug 1904869 - Move HOST_CFLAGS from old-configure to moz.configure r=glandium Differential Revision: https://phabricator.services.mozilla.com/D214986 --- build/moz.configure/flags.configure | 24 ++++++++++++++++++++++-- build/moz.configure/toolchain.configure | 10 ++++++++++ build/mozconfig.no-compile | 1 + js/src/old-configure.in | 25 ------------------------- old-configure.in | 25 ------------------------- 5 files changed, 33 insertions(+), 52 deletions(-) diff --git a/build/moz.configure/flags.configure b/build/moz.configure/flags.configure index f423c2d65b26..db4f499934e2 100644 --- a/build/moz.configure/flags.configure +++ b/build/moz.configure/flags.configure @@ -542,7 +542,7 @@ set_config("OS_COMPILE_CMFLAGS", compilation_flags.cmflags) set_config("OS_COMPILE_CMMFLAGS", compilation_flags.cmmflags) -# Default host optimization flags +# Final flags settings # --------------------------------- @depends(host_c_compiler) def host_optimize_flags(compiler): @@ -554,6 +554,26 @@ def host_optimize_flags(compiler): set_config("HOST_OPTIMIZE_FLAGS", host_optimize_flags) + +@depends("HOST_CFLAGS", compilation_flags, host, host_c_compiler) +@imports(_from="mozbuild.shellutil", _import="split") +def host_cflags(base_cflags, compilation_flags, host, compiler): + flags = list(compilation_flags.host_cflags) + flags += split(base_cflags[0]) + + if host.kernel == "WINNT": + if compiler.type != "clang-cl": + flags += ["-mwindows"] + flags += ["-DXP_WIN", "-DWIN32", "-D_WIN32", "-D_CRT_SECURE_NO_WARNINGS"] + if host.cpu == "x86_64": + flags += ["-D_AMD64_"] + elif host.kernel == "Darwin": + flags += ["-DXP_UNIX", "-DXP_MACOSX"] + else: + flags += ["-DXP_UNIX"] + return flags + + # Please keep these last in this file. add_old_configure_assignment("_COMPILATION_ASFLAGS", asm_flags.asflags) add_old_configure_assignment("_COMPILATION_HOST_ASFLAGS", asm_flags.host_asflags) @@ -565,9 +585,9 @@ add_old_configure_assignment("_COMPILATION_HOST_LDFLAGS", linker_flags.host_ldfl add_old_configure_assignment("_COMPILATION_CFLAGS", compilation_flags.cflags) add_old_configure_assignment("_COMPILATION_CXXFLAGS", compilation_flags.cxxflags) -add_old_configure_assignment("_COMPILATION_HOST_CFLAGS", compilation_flags.host_cflags) add_old_configure_assignment( "_COMPILATION_HOST_CXXFLAGS", compilation_flags.host_cxxflags ) +set_config("HOST_CFLAGS", host_cflags) set_config("DSO_LDOPTS", dso_flags.ldopts) diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index a6476f1575e3..2a92567151a9 100644 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -4,6 +4,16 @@ # 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/. +# Environment variables that impact the compilation step +# ============================================================== +option( + env="HOST_CFLAGS", + help="Extra flags for compiling host C sources.", + nargs=1, + default="", +) + + # Code optimization # ============================================================== diff --git a/build/mozconfig.no-compile b/build/mozconfig.no-compile index 68dc06fb12ec..cd4c43795a04 100644 --- a/build/mozconfig.no-compile +++ b/build/mozconfig.no-compile @@ -11,6 +11,7 @@ unset CC unset CXX unset HOST_CC unset HOST_CXX +unset HOST_CFLAGS unset LINKER unset RUSTFLAGS unset TOOLCHAIN_PREFIX diff --git a/js/src/old-configure.in b/js/src/old-configure.in index 23e4860f6eaa..f42cfc869553 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -22,7 +22,6 @@ CFLAGS="${CFLAGS=}" CPPFLAGS="${CPPFLAGS=}" CXXFLAGS="${CXXFLAGS=}" LDFLAGS="${LDFLAGS=}" -HOST_CFLAGS="${HOST_CFLAGS=}" HOST_CXXFLAGS="${HOST_CXXFLAGS=}" HOST_LDFLAGS="${HOST_LDFLAGS=}" @@ -160,12 +159,6 @@ dnl System overrides of the defaults for host dnl ======================================================== case "$host" in *mingw*) - if test "$HOST_CC_TYPE" = clang-cl; then - HOST_CFLAGS="$HOST_CFLAGS" - else - HOST_CFLAGS="$HOST_CFLAGS -mwindows" - fi - HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS" HOST_BIN_SUFFIX=.exe case "${host_cpu}" in @@ -178,22 +171,9 @@ case "$host" in if test "$HOST_CC_TYPE" = clang-cl; then HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64" fi - HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_" ;; esac ;; - -*-darwin*) - HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX" - ;; - -*-linux*|*-kfreebsd*-gnu|*-gnu*) - HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX" - ;; - -*) - HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX" - ;; esac dnl ======================================================== @@ -401,10 +381,6 @@ ASFLAGS=`echo \ $_COMPILATION_ASFLAGS \ $ASFLAGS` -HOST_CFLAGS=`echo \ - $_COMPILATION_HOST_CFLAGS \ - $HOST_CFLAGS` - HOST_CXXFLAGS=`echo \ $_COMPILATION_HOST_CXXFLAGS \ $HOST_CXXFLAGS` @@ -428,7 +404,6 @@ AC_SUBST_LIST(OS_LDFLAGS) AC_SUBST(HOST_CC) AC_SUBST(HOST_CXX) -AC_SUBST_LIST(HOST_CFLAGS) AC_SUBST_LIST(HOST_CPPFLAGS) AC_SUBST_LIST(HOST_CXXFLAGS) AC_SUBST(HOST_LDFLAGS) diff --git a/old-configure.in b/old-configure.in index c4ad1742b22d..20d765983dd7 100644 --- a/old-configure.in +++ b/old-configure.in @@ -22,7 +22,6 @@ CFLAGS="${CFLAGS=}" CPPFLAGS="${CPPFLAGS=}" CXXFLAGS="${CXXFLAGS=}" LDFLAGS="${LDFLAGS=}" -HOST_CFLAGS="${HOST_CFLAGS=}" HOST_CXXFLAGS="${HOST_CXXFLAGS=}" HOST_LDFLAGS="${HOST_LDFLAGS=}" @@ -164,12 +163,6 @@ dnl System overrides of the defaults for host dnl ======================================================== case "$host" in *mingw*) - if test "$HOST_CC_TYPE" = clang-cl; then - HOST_CFLAGS="$HOST_CFLAGS" - else - HOST_CFLAGS="$HOST_CFLAGS -mwindows" - fi - HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS" HOST_BIN_SUFFIX=.exe case "${host_cpu}" in @@ -182,22 +175,9 @@ case "$host" in if test "$HOST_CC_TYPE" = clang-cl; then HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64" fi - HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_" ;; esac ;; - -*-darwin*) - HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX" - ;; - -*-linux*|*-kfreebsd*-gnu|*-gnu*) - HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX" - ;; - -*) - HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX" - ;; esac dnl ======================================================== @@ -554,10 +534,6 @@ ASFLAGS=`echo \ $_COMPILATION_ASFLAGS \ $ASFLAGS` -HOST_CFLAGS=`echo \ - $_COMPILATION_HOST_CFLAGS \ - $HOST_CFLAGS` - HOST_CXXFLAGS=`echo \ $_COMPILATION_HOST_CXXFLAGS \ $HOST_CXXFLAGS` @@ -581,7 +557,6 @@ AC_SUBST_LIST(OS_LDFLAGS) AC_SUBST(HOST_CC) AC_SUBST(HOST_CXX) -AC_SUBST_LIST(HOST_CFLAGS) AC_SUBST_LIST(HOST_CPPFLAGS) AC_SUBST_LIST(HOST_CXXFLAGS) AC_SUBST(HOST_LDFLAGS)