93dc2d
commit ef7c6d42fe163a5e49a478c43e655ce4633fa5ba
93dc2d
Author: Florian Weimer <fweimer@redhat.com>
93dc2d
Date:   Fri Jan 14 16:09:20 2022 +0100
93dc2d
93dc2d
    Generate gcc-macros.h
93dc2d
    
93dc2d
    The file can be used to check the effect of the default compiler
93dc2d
    flags on code generation even in areas of the build that uses
93dc2d
    non-default compiler flags.
93dc2d
    
93dc2d
    Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
93dc2d
93dc2d
diff --git a/Makeconfig b/Makeconfig
93dc2d
index 8bc5540292c7b6fa..99898a632a64be91 100644
93dc2d
--- a/Makeconfig
93dc2d
+++ b/Makeconfig
93dc2d
@@ -1202,6 +1202,15 @@ $(common-objpfx)dl-tunable-list.stmp: \
93dc2d
 	touch $@
93dc2d
 endif
93dc2d
 
93dc2d
+# Dump the GCC macros used by the default compiler flags to a header
93dc2d
+# file, so that they can be inspected when using different compiler
93dc2d
+# flags.  Add the GCCMACRO prefix to make these macro names unique.
93dc2d
+$(common-objpfx)gcc-macros.h.in: $(common-objpfx)config.status
93dc2d
+	$(CC) $(CFLAGS) $(CPPFLAGS) -E -dM -x c -o $@ /dev/null
93dc2d
+$(common-objpfx)gcc-macros.h: $(common-objpfx)gcc-macros.h.in
93dc2d
+	sed 's/^#define /#define GCCMACRO/' < $< > $@
93dc2d
+before-compile += $(common-objpfx)gcc-macros.h
93dc2d
+
93dc2d
 # Generate version maps, but wait until sysdep-subdirs is known
93dc2d
 ifeq ($(sysd-sorted-done),t)
93dc2d
 ifeq ($(build-shared),yes)