Override other optimization settings with any -Os or -Oz found in CC
or CFLAGS.
libgcc/ChangeLog:
* Makefile.in: Use -Os or -Oz from CC or CFLAGS
Signed-off-by: Keith Packard <[email protected]>
---
libgcc/Makefile.in | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index ffc45f21267..25710636938 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -294,16 +294,20 @@ override CFLAGS := $(filter-out -fprofile-generate
-fprofile-use,$(CFLAGS))
# CFLAGS first is not perfect; normally setting CFLAGS should override any
# options in LIBGCC2_CFLAGS. But LIBGCC2_CFLAGS may contain -g0, and CFLAGS
# will usually contain -g, so for the moment CFLAGS goes first. We must
-# include CFLAGS - that's where multilib options live.
+# include CFLAGS - that's where multilib options live. If CC or CFLAGS
+# specify -Os or -Oz, we want that to override our local options as that
+# could be a multilib flag.
INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
- $(INCLUDES) @set_have_cc_tls@ @set_use_emutls@
+ $(INCLUDES) @set_have_cc_tls@ @set_use_emutls@ \
+ $(filter -Os -Oz,$(CC) $(CFLAGS))
# Options to use when compiling crtbegin/end.
CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
$(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \
-fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
-fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \
- $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY)
+ $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY) \
+ $(filter -Os -Oz,$(CC) $(CFLAGS))
# Extra flags to use when compiling crt{begin,end}.o.
CRTSTUFF_T_CFLAGS =
--
2.45.2