@@ -293,16 +293,20 @@ override CFLAGS := $(filter-out -fprofile-generate -fprofile-use,$(CFLAGS))
293
293
# CFLAGS first is not perfect; normally setting CFLAGS should override any
294
294
# options in LIBGCC2_CFLAGS. But LIBGCC2_CFLAGS may contain -g0, and CFLAGS
295
295
# 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.
297
299
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 ) )
299
302
300
303
# Options to use when compiling crtbegin/end.
301
304
CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS ) $(INCLUDES ) $(MULTILIB_CFLAGS ) -g0 \
302
305
$(NO_PIE_CFLAGS ) -finhibit-size-directive -fno-inline -fno-exceptions \
303
306
-fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
304
307
-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 ) )
306
310
307
311
# Extra flags to use when compiling crt{begin,end}.o.
308
312
CRTSTUFF_T_CFLAGS =
0 commit comments