From 28c2dc53b1e00b9d677e0624dca4fead934705da Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Fri, 2 Aug 2024 06:59:32 +0000 Subject: [PATCH] Bug 1906817 - Move MOZ_CONFIGURE_OPTIMIZE_FLAGS check from old-configure to moz.configure r=glandium This only checks MOZ_CONFIGURE_OPTIMIZE_FLAGS while previous version was also checking -O2 / -O3 flags, which is probably not necessary. Differential Revision: https://phabricator.services.mozilla.com/D216097 --- build/moz.configure/toolchain.configure | 17 +++++++++++++++++ js/src/old-configure.in | 17 ----------------- old-configure.in | 17 ----------------- 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index 269d52f3bc63..cda2258981d9 100644 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -3878,3 +3878,20 @@ dtrace = check_header( set_config("HAVE_DTRACE", True, when=dtrace) set_define("INCLUDE_MOZILLA_DTRACE", True, when=dtrace) + + +@depends( + try_compile( + includes=["stdio.h"], + body='puts("demat");', + flags=moz_optimize_flags, + language="C", + check_msg="for valid C compiler optimization flags", + ), + moz_optimize_flags, + when=moz_optimize, +) +@imports(_from="mozbuild.shellutil", _import="quote") +def check_optimization_flags(check_result, moz_optimize_flags): + if not check_result: + die(f"Invalid C compiler optimization flags: {quote(*moz_optimize_flags)}") diff --git a/js/src/old-configure.in b/js/src/old-configure.in index 3350aec582b9..9baff651572d 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -90,23 +90,6 @@ if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS} fi -if test "$COMPILE_ENVIRONMENT"; then -if test -n "$MOZ_OPTIMIZE"; then - AC_MSG_CHECKING([for valid optimization flags]) - _SAVE_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS" - AC_TRY_COMPILE([#include ], - [printf("Hello World\n");], - _results=yes, - _results=no) - AC_MSG_RESULT([$_results]) - if test "$_results" = "no"; then - AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS]) - fi - CFLAGS=$_SAVE_CFLAGS -fi -fi # COMPILE_ENVIRONMENT - AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS) dnl ======================================================== diff --git a/old-configure.in b/old-configure.in index a90ee16ce77b..1af75c496b15 100644 --- a/old-configure.in +++ b/old-configure.in @@ -134,23 +134,6 @@ if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS} fi -if test "$COMPILE_ENVIRONMENT"; then -if test -n "$MOZ_OPTIMIZE"; then - AC_MSG_CHECKING([for valid C compiler optimization flags]) - _SAVE_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS" - AC_TRY_COMPILE([#include ], - [printf("Hello World\n");], - _results=yes, - _results=no) - AC_MSG_RESULT([$_results]) - if test "$_results" = "no"; then - AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS]) - fi - CFLAGS=$_SAVE_CFLAGS -fi -fi # COMPILE_ENVIRONMENT - AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)