mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1906599 - Move MOZ_OPTIMIZE_LDFLAGS from old-configure to moz.configure r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D215936
This commit is contained in:
parent
bd5f7c69a9
commit
47dffea6d9
24
build/moz.configure/finalize-flags.configure
Normal file
24
build/moz.configure/finalize-flags.configure
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- Mode: python; 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/.
|
||||
|
||||
|
||||
@depends(linker_optimize_flags, moz_optimize_flags, lto, c_compiler)
|
||||
def moz_optimize_ldflags(linker_optimize_flags, moz_optimize_flags, lto, c_compiler):
|
||||
flags = []
|
||||
if linker_optimize_flags:
|
||||
flags += linker_optimize_flags.ldflags
|
||||
flags += moz_optimize_flags
|
||||
|
||||
# When using llvm-based LTO, non numeric optimization levels are
|
||||
# not supported by the linker, so force the linker to use -O2 (
|
||||
# which doesn't influence the level compilation units are actually
|
||||
# compiled at).
|
||||
if lto and lto.enabled and c_compiler.type == "clang":
|
||||
flags = ["-O2" if flag in ("-Oz", "-Os") else flag for flag in flags]
|
||||
return flags
|
||||
|
||||
|
||||
set_config("MOZ_OPTIMIZE_LDFLAGS", moz_optimize_ldflags)
|
@ -644,10 +644,6 @@ def os_asflags(
|
||||
|
||||
# Please keep these last in this file.
|
||||
add_old_configure_assignment("_COMPILATION_LDFLAGS", linker_flags.ldflags)
|
||||
add_old_configure_assignment(
|
||||
"_COMPILATION_OPTIMIZE_LDFLAGS", linker_optimize_flags.ldflags
|
||||
)
|
||||
|
||||
add_old_configure_assignment("CPPFLAGS", os_cppflags)
|
||||
|
||||
add_old_configure_assignment("_COMPILATION_CFLAGS", compilation_flags.cflags)
|
||||
|
@ -54,6 +54,13 @@ option(
|
||||
)
|
||||
|
||||
|
||||
option(
|
||||
env="MOZ_OPTIMIZE_FLAGS",
|
||||
help="Extra optimization flags.",
|
||||
nargs=1,
|
||||
default="",
|
||||
)
|
||||
|
||||
# Code optimization
|
||||
# ==============================================================
|
||||
|
||||
@ -85,6 +92,16 @@ set_config("MOZ_OPTIMIZE", moz_optimize.optimize)
|
||||
add_old_configure_assignment("MOZ_OPTIMIZE", moz_optimize.optimize)
|
||||
add_old_configure_assignment("MOZ_CONFIGURE_OPTIMIZE_FLAGS", moz_optimize.flags)
|
||||
|
||||
|
||||
@depends("MOZ_OPTIMIZE_FLAGS")
|
||||
@imports(_from="mozbuild.shellutil", _import="split")
|
||||
def moz_optimize_flags(env_optimize_flags):
|
||||
return split(env_optimize_flags[0])
|
||||
|
||||
|
||||
add_old_configure_assignment("MOZ_OPTIMIZE_FLAGS", moz_optimize_flags)
|
||||
|
||||
|
||||
# Android NDK
|
||||
# ==============================================================
|
||||
|
||||
|
@ -78,8 +78,6 @@ dnl ========================================================
|
||||
dnl System overrides of the defaults for target
|
||||
dnl ========================================================
|
||||
|
||||
MOZ_OPTIMIZE_LDFLAGS="${_COMPILATION_OPTIMIZE_LDFLAGS} ${MOZ_OPTIMIZE_FLAGS}"
|
||||
|
||||
case "$target" in
|
||||
*-darwin*)
|
||||
MOZ_OPTIMIZE_FLAGS="-O3"
|
||||
@ -220,22 +218,10 @@ if test -n "$MOZ_OPTIMIZE"; then
|
||||
AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
|
||||
fi
|
||||
CFLAGS=$_SAVE_CFLAGS
|
||||
if test -n "$MOZ_LTO" -a "$CC_TYPE" = clang ; then
|
||||
# When using llvm-based LTO, non numeric optimization levels are
|
||||
# not supported by the linker, so force the linker to use -O2 (
|
||||
# which doesn't influence the level compilation units are actually
|
||||
# compiled at).
|
||||
case " $MOZ_OPTIMIZE_FLAGS " in
|
||||
*\ -Os\ *|*\ -Oz\ *)
|
||||
MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
fi # COMPILE_ENVIRONMENT
|
||||
|
||||
AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
|
||||
AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
|
||||
AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
|
||||
|
||||
dnl ========================================================
|
||||
|
@ -434,6 +434,15 @@ dmd = dependable(False)
|
||||
|
||||
include(include_project_configure)
|
||||
|
||||
# Final flags validation and gathering
|
||||
# -------------------------------------------------
|
||||
|
||||
include(
|
||||
"build/moz.configure/finalize-flags.configure", when="--enable-compile-environment"
|
||||
)
|
||||
|
||||
# -------------------------------------------------
|
||||
|
||||
|
||||
@depends("--help")
|
||||
@imports(_from="mozbuild.backend", _import="backends")
|
||||
|
@ -74,8 +74,6 @@ dnl ========================================================
|
||||
dnl System overrides of the defaults for target
|
||||
dnl ========================================================
|
||||
|
||||
MOZ_OPTIMIZE_LDFLAGS="${_COMPILATION_OPTIMIZE_LDFLAGS} ${MOZ_OPTIMIZE_FLAGS}"
|
||||
|
||||
case "$target" in
|
||||
*-darwin*)
|
||||
MOZ_OPTIMIZE_FLAGS="-O3"
|
||||
@ -269,22 +267,10 @@ if test -n "$MOZ_OPTIMIZE"; then
|
||||
AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
|
||||
fi
|
||||
CFLAGS=$_SAVE_CFLAGS
|
||||
if test -n "$MOZ_LTO" -a "$CC_TYPE" = clang ; then
|
||||
# When using llvm-based LTO, non numeric optimization levels are
|
||||
# not supported by the linker, so force the linker to use -O2 (
|
||||
# which doesn't influence the level compilation units are actually
|
||||
# compiled at).
|
||||
case " $MOZ_OPTIMIZE_FLAGS " in
|
||||
*\ -Os\ *|*\ -Oz\ *)
|
||||
MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
fi # COMPILE_ENVIRONMENT
|
||||
|
||||
AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
|
||||
AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
|
||||
AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
|
||||
|
||||
dnl ========================================================
|
||||
|
Loading…
Reference in New Issue
Block a user