Skip to content

Commit c94c5d0

Browse files
keith-packardstephanosio
authored andcommitted
libgcc: Use -Os/-Oz from CC or CFLAGS
Override other optimization settings with any -Os or -Oz found in CC or CFLAGS. Signed-off-by: Keith Packard <keithp@keithp.com>
1 parent 428d8d7 commit c94c5d0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

libgcc/Makefile.in

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,20 @@ override CFLAGS := $(filter-out -fprofile-generate -fprofile-use,$(CFLAGS))
293293
# CFLAGS first is not perfect; normally setting CFLAGS should override any
294294
# options in LIBGCC2_CFLAGS. But LIBGCC2_CFLAGS may contain -g0, and CFLAGS
295295
# will usually contain -g, so for the moment CFLAGS goes first. We must
296-
# include CFLAGS - that's where multilib options live.
296+
# include CFLAGS - that's where multilib options live. If CC or CFLAGS
297+
# specify -Os or -Oz, we want that to override our local options as that
298+
# could be a multilib flag.
297299
INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
298-
$(INCLUDES) @set_have_cc_tls@ @set_use_emutls@
300+
$(INCLUDES) @set_have_cc_tls@ @set_use_emutls@ \
301+
$(filter -Os -Oz,$(CC) $(CFLAGS))
299302

300303
# Options to use when compiling crtbegin/end.
301304
CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
302305
$(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \
303306
-fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
304307
-fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \
305-
$(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY)
308+
$(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY) \
309+
$(filter -Os -Oz,$(CC) $(CFLAGS))
306310

307311
# Extra flags to use when compiling crt{begin,end}.o.
308312
CRTSTUFF_T_CFLAGS =

0 commit comments

Comments
 (0)