diff --git a/aclocal.m4 b/aclocal.m4 index 20464eef535a..10b7e6a1ca46 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -7,7 +7,6 @@ builtin(include, build/autoconf/hooks.m4)dnl builtin(include, build/autoconf/config.status.m4)dnl builtin(include, build/autoconf/toolchain.m4)dnl builtin(include, build/autoconf/altoptions.m4)dnl -builtin(include, build/autoconf/arch.m4)dnl builtin(include, build/autoconf/clang-plugin.m4)dnl # Read the user's .mozconfig script. We can't do this in diff --git a/build/autoconf/arch.m4 b/build/autoconf/arch.m4 deleted file mode 100644 index 2d1158875e76..000000000000 --- a/build/autoconf/arch.m4 +++ /dev/null @@ -1,14 +0,0 @@ -dnl This Source Code Form is subject to the terms of the Mozilla Public -dnl License, v. 2.0. If a copy of the MPL was not distributed with this -dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. - -AC_DEFUN([MOZ_ARCH_OPTS], -[ -if test -n "$_ARM_FLAGS"; then - CFLAGS="$CFLAGS $_ARM_FLAGS" - CXXFLAGS="$CXXFLAGS $_ARM_FLAGS" - if test -n "$_THUMB_FLAGS"; then - LDFLAGS="$LDFLAGS $_THUMB_FLAGS" - fi -fi -]) diff --git a/build/moz.configure/arm.configure b/build/moz.configure/arm.configure index 5d26f4d73239..99c582748ef8 100644 --- a/build/moz.configure/arm.configure +++ b/build/moz.configure/arm.configure @@ -172,10 +172,6 @@ def all_arm_flags(flags, interwork): return flags + interwork -add_old_configure_assignment("_ARM_FLAGS", all_arm_flags) -add_old_configure_assignment("_THUMB_FLAGS", thumb_option) - - @depends(configure_cache, c_compiler, all_arm_flags) @checking("ARM version support in compiler", lambda x: x.arm_arch) @imports(_from="textwrap", _import="dedent") diff --git a/build/moz.configure/flags.configure b/build/moz.configure/flags.configure index 0c9ff0625cd2..d0c1e1b50d56 100644 --- a/build/moz.configure/flags.configure +++ b/build/moz.configure/flags.configure @@ -610,6 +610,32 @@ def os_cppflags(env_cppflags): return flags +@depends("CFLAGS", compilation_flags, android_flags, all_arm_flags) +@imports(_from="mozbuild.shellutil", _import="split") +def os_cflags(env_cflags, compilation_flags, android_flags, all_arm_flags): + flags = [] + if android_flags: + flags.extend(android_flags.cflags) + if all_arm_flags: + flags.extend(all_arm_flags) + flags.extend(compilation_flags.cflags) + flags.extend(split(env_cflags[0])) + return flags + + +@depends("CXXFLAGS", compilation_flags, android_flags, all_arm_flags) +@imports(_from="mozbuild.shellutil", _import="split") +def os_cxxflags(env_cxxflags, compilation_flags, android_flags, all_arm_flags): + flags = [] + if android_flags: + flags.extend(android_flags.cxxflags) + if all_arm_flags: + flags.extend(all_arm_flags) + flags.extend(compilation_flags.cxxflags) + flags.extend(split(env_cxxflags[0])) + return flags + + @depends( "ASFLAGS", asm_flags, @@ -642,12 +668,24 @@ def os_asflags( return flags -# Please keep these last in this file. -add_old_configure_assignment("_COMPILATION_LDFLAGS", linker_flags.ldflags) -add_old_configure_assignment("CPPFLAGS", os_cppflags) +@depends("LDFLAGS", linker_flags, android_flags, thumb_option) +@imports(_from="mozbuild.shellutil", _import="split") +def os_ldflags(env_ldflags, linker_flags, android_flags, thumb_option): + flags = [] + if android_flags: + flags.extend(android_flags.ldflags) + if thumb_option: + flags.extend(thumb_option) + flags.extend(split(env_ldflags[0])) + flags.extend(linker_flags.ldflags) + return flags -add_old_configure_assignment("_COMPILATION_CFLAGS", compilation_flags.cflags) -add_old_configure_assignment("_COMPILATION_CXXFLAGS", compilation_flags.cxxflags) + +# Please keep these last in this file. +add_old_configure_assignment("CPPFLAGS", os_cppflags) +add_old_configure_assignment("CFLAGS", os_cflags) +add_old_configure_assignment("CXXFLAGS", os_cxxflags) +add_old_configure_assignment("LDFLAGS", os_ldflags) set_config("HOST_CPPFLAGS", host_cppflags) set_config("HOST_CFLAGS", host_cflags) diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index 4c1d81c867db..cf9656cd8a38 100644 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -46,6 +46,22 @@ option( ) +option( + env="CFLAGS", + help="Extra flags for compiling C sources.", + nargs=1, + default="", +) + + +option( + env="CXXFLAGS", + help="Extra flags for compiling C++ sources.", + nargs=1, + default="", +) + + option( env="ASFLAGS", help="Extra flags for assembling sources.", @@ -54,6 +70,14 @@ option( ) +option( + env="LDFLAGS", + help="Extra flags for linking object files.", + nargs=1, + default="", +) + + option( env="MOZ_OPTIMIZE_FLAGS", help="Extra optimization flags.", @@ -61,6 +85,7 @@ option( default="", ) + # Code optimization # ============================================================== diff --git a/build/mozconfig.no-compile b/build/mozconfig.no-compile index 32890d0710f5..d34e9214039e 100644 --- a/build/mozconfig.no-compile +++ b/build/mozconfig.no-compile @@ -9,6 +9,10 @@ NO_CACHE=1 # Override any toolchain defines we've inherited from other mozconfigs. unset CC unset CXX +unset CPPFLAGS +unset CFLAGS +unset CXXFLAGS +unset LDFLAGS unset HOST_CC unset HOST_CXX unset HOST_CPPFLAGS diff --git a/js/src/aclocal.m4 b/js/src/aclocal.m4 index ee59549d0545..cb0936d006a7 100644 --- a/js/src/aclocal.m4 +++ b/js/src/aclocal.m4 @@ -7,7 +7,6 @@ builtin(include, ../../build/autoconf/hooks.m4)dnl builtin(include, ../../build/autoconf/config.status.m4)dnl builtin(include, ../../build/autoconf/toolchain.m4)dnl builtin(include, ../../build/autoconf/altoptions.m4)dnl -builtin(include, ../../build/autoconf/arch.m4)dnl builtin(include, ../../build/autoconf/clang-plugin.m4)dnl define([__MOZ_AC_INIT_PREPARE], defn([AC_INIT_PREPARE])) diff --git a/js/src/old-configure.in b/js/src/old-configure.in index 0a053654800c..8471d86ccfb5 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -11,27 +11,6 @@ AC_INIT(js/src/jsapi.h) AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf) AC_CANONICAL_SYSTEM -dnl ======================================================== -dnl = -dnl = Don't change the following lines. Doing so breaks: -dnl = -dnl = CFLAGS="-foo" ./configure -dnl = -dnl ======================================================== -CFLAGS="${CFLAGS=}" -CXXFLAGS="${CXXFLAGS=}" -LDFLAGS="${LDFLAGS=}" - -dnl Propagate extra android flags -dnl ============================= -case "$target" in -*-android*|*-linuxandroid*) - LDFLAGS="$ANDROID_LDFLAGS $LDFLAGS" - CFLAGS="$ANDROID_CFLAGS $CFLAGS" - CXXFLAGS="$ANDROID_CXXFLAGS $CXXFLAGS" - ;; -esac - dnl Set the minimum version of toolkit libs used by mozilla dnl ======================================================== @@ -70,10 +49,6 @@ fi fi # COMPILE_ENVIRONMENT -dnl Configure platform-specific CPU architecture compiler options. -dnl ============================================================== -MOZ_ARCH_OPTS - dnl ======================================================== dnl System overrides of the defaults for target dnl ======================================================== @@ -214,19 +189,6 @@ AC_SUBST(MOZ_POST_PROGRAM_COMMAND) AC_SUBST(MOZ_APP_DISPLAYNAME) -dnl Echo the CFLAGS to remove extra whitespace. -CFLAGS=`echo \ - $_COMPILATION_CFLAGS \ - $CFLAGS` - -CXXFLAGS=`echo \ - $_COMPILATION_CXXFLAGS \ - $CXXFLAGS` - -LDFLAGS=`echo \ - $LDFLAGS \ - $_COMPILATION_LDFLAGS` - OS_CFLAGS="$CFLAGS" OS_CXXFLAGS="$CXXFLAGS" OS_LDFLAGS="$LDFLAGS" diff --git a/old-configure.in b/old-configure.in index 3ac5248b6316..93e0c6d19e8b 100644 --- a/old-configure.in +++ b/old-configure.in @@ -11,29 +11,6 @@ AC_INIT(config/config.mk) AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf) AC_CANONICAL_SYSTEM -dnl ======================================================== -dnl = -dnl = Don't change the following lines. Doing so breaks: -dnl = -dnl = CFLAGS="-foo" ./configure -dnl = -dnl ======================================================== -CFLAGS="${CFLAGS=}" -CXXFLAGS="${CXXFLAGS=}" -LDFLAGS="${LDFLAGS=}" - - -dnl Propagate extra android flags -dnl ============================= -case "$target" in -*-android*|*-linuxandroid*) - LDFLAGS="$ANDROID_LDFLAGS $LDFLAGS" - CFLAGS="$ANDROID_CFLAGS $CFLAGS" - CXXFLAGS="$ANDROID_CXXFLAGS $CXXFLAGS" - ;; -esac - - dnl Set the minimum version of toolkit libs used by mozilla dnl ======================================================== @@ -64,12 +41,6 @@ fi fi # COMPILE_ENVIRONMENT -dnl Configure platform-specific CPU architecture compiler options. -dnl ============================================================== -if test "$COMPILE_ENVIRONMENT"; then - MOZ_ARCH_OPTS -fi # COMPILE_ENVIRONMENT - dnl ======================================================== dnl System overrides of the defaults for target dnl ======================================================== @@ -358,19 +329,6 @@ AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION") AC_SUBST(MOZ_APP_MAXVERSION) -dnl Echo the CFLAGS to remove extra whitespace. -CFLAGS=`echo \ - $_COMPILATION_CFLAGS \ - $CFLAGS` - -CXXFLAGS=`echo \ - $_COMPILATION_CXXFLAGS \ - $CXXFLAGS` - -LDFLAGS=`echo \ - $LDFLAGS \ - $_COMPILATION_LDFLAGS` - OS_CFLAGS="$CFLAGS" OS_CXXFLAGS="$CXXFLAGS" OS_LDFLAGS="$LDFLAGS"