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:
serge-sans-paille 2024-07-16 22:14:35 +00:00
Родитель bd5f7c69a9
Коммит 47dffea6d9
6 изменённых файлов: 50 добавлений и 32 удалений

Просмотреть файл

@ -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. # Please keep these last in this file.
add_old_configure_assignment("_COMPILATION_LDFLAGS", linker_flags.ldflags) 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("CPPFLAGS", os_cppflags)
add_old_configure_assignment("_COMPILATION_CFLAGS", compilation_flags.cflags) 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 # 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_OPTIMIZE", moz_optimize.optimize)
add_old_configure_assignment("MOZ_CONFIGURE_OPTIMIZE_FLAGS", moz_optimize.flags) 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 # Android NDK
# ============================================================== # ==============================================================

Просмотреть файл

@ -78,8 +78,6 @@ dnl ========================================================
dnl System overrides of the defaults for target dnl System overrides of the defaults for target
dnl ======================================================== dnl ========================================================
MOZ_OPTIMIZE_LDFLAGS="${_COMPILATION_OPTIMIZE_LDFLAGS} ${MOZ_OPTIMIZE_FLAGS}"
case "$target" in case "$target" in
*-darwin*) *-darwin*)
MOZ_OPTIMIZE_FLAGS="-O3" 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]) AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
fi fi
CFLAGS=$_SAVE_CFLAGS 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
fi # COMPILE_ENVIRONMENT fi # COMPILE_ENVIRONMENT
AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS) AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS) AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
dnl ======================================================== dnl ========================================================

Просмотреть файл

@ -434,6 +434,15 @@ dmd = dependable(False)
include(include_project_configure) include(include_project_configure)
# Final flags validation and gathering
# -------------------------------------------------
include(
"build/moz.configure/finalize-flags.configure", when="--enable-compile-environment"
)
# -------------------------------------------------
@depends("--help") @depends("--help")
@imports(_from="mozbuild.backend", _import="backends") @imports(_from="mozbuild.backend", _import="backends")

Просмотреть файл

@ -74,8 +74,6 @@ dnl ========================================================
dnl System overrides of the defaults for target dnl System overrides of the defaults for target
dnl ======================================================== dnl ========================================================
MOZ_OPTIMIZE_LDFLAGS="${_COMPILATION_OPTIMIZE_LDFLAGS} ${MOZ_OPTIMIZE_FLAGS}"
case "$target" in case "$target" in
*-darwin*) *-darwin*)
MOZ_OPTIMIZE_FLAGS="-O3" 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]) AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
fi fi
CFLAGS=$_SAVE_CFLAGS 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
fi # COMPILE_ENVIRONMENT fi # COMPILE_ENVIRONMENT
AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS) AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS) AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
dnl ======================================================== dnl ========================================================