gold: Compile common tests with -fcommon

Message ID 20200502134400.229663-1-hjl.tools@gmail.com
State New
Headers show
Series
  • gold: Compile common tests with -fcommon
Related show

Commit Message

Since GCC 10 defaults to -fno-common, add -fcommon to common tests to
force common behavior.

I am checking in this patch.

H.J.
---
	PR gold/25904
	* testsuite/Makefile.am (COMMON_TEST_C_CFLAGS): New.
	(common_test_1.o): New rule.
	(common_test_2.o): Likewise.
	(common_test_3.o): Likewise.
	(plugin_common_test_1.o): Likewise.
	(plugin_common_test_2.o): Likewise.
	(common_test_1_v1.o): Likewise.
	(common_test_1_v2.o): Likewise.
	(common_test_2_pic.o): Compile with $(COMMON_TEST_C_CFLAGS).
	(common_test_3_pic.o): Likewise.
	* testsuite/Makefile.in: Regenerated.
---
 gold/testsuite/Makefile.am | 23 +++++++++++++++++++++--
 gold/testsuite/Makefile.in | 23 +++++++++++++++++++++--
 2 files changed, 42 insertions(+), 4 deletions(-)

-- 
2.26.2

Patch

diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 5c5679657f..aff896a060 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -86,6 +86,10 @@  if OMP_SUPPORT
 TLS_TEST_C_CFLAGS = -fopenmp
 endif
 
+# Since GCC 10 defaults to -fno-common, add -fcommon to common tests to
+# force common behavior.
+COMMON_TEST_C_CFLAGS = -fcommon
+
 # 'make clean' is good about deleting some intermediate files (such as
 # .o's), but not all of them (such as .so's and .err files).  We
 # improve on that here.  automake-1.9 info docs say "mostlyclean" is
@@ -737,18 +741,24 @@  check_PROGRAMS += common_test_1
 common_test_1_SOURCES = common_test_1.c
 common_test_1_DEPENDENCIES = gcctestdir/ld
 common_test_1_LDADD =
+common_test_1.o: common_test_1.c
+	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
 
 check_PROGRAMS += common_test_2
 common_test_2_SOURCES = common_test_1.c
 common_test_2_DEPENDENCIES = common_test_2.so common_test_3.so gcctestdir/ld
 common_test_2_LDFLAGS = -Wl,-R,.
 common_test_2_LDADD = common_test_2.so common_test_3.so
+common_test_2.o: common_test_2.c
+	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
 common_test_2_pic.o: common_test_2.c
-	$(COMPILE) -c -fpic -o $@ $<
+	$(COMPILE) -c -fpic $(COMMON_TEST_C_CFLAGS) -o $@ $<
 common_test_2.so: common_test_2_pic.o common_test_3.so gcctestdir/ld
 	$(LINK) -shared common_test_2_pic.o common_test_3.so
+common_test_3.o: common_test_3.c
+	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
 common_test_3_pic.o: common_test_3.c
-	$(COMPILE) -c -fpic -o $@ $<
+	$(COMPILE) -c -fpic $(COMMON_TEST_C_CFLAGS) -o $@ $<
 common_test_3.so: common_test_3_pic.o ver_test_2.script gcctestdir/ld
 	$(LINK) -shared common_test_3_pic.o -Wl,--version-script,$(srcdir)/ver_test_2.script
 
@@ -2472,6 +2482,11 @@  plugin_test.so: plugin_test.o gcctestdir/ld
 plugin_test.o: plugin_test.c
 	$(COMPILE) -O0 -c -fpic -o $@ $<
 
+plugin_common_test_1.o: plugin_common_test_1.c
+	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
+plugin_common_test_2.o: plugin_common_test_2.c
+	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
+
 two_file_test_main.o.syms: two_file_test_main.o
 	$(TEST_READELF) -sW $< >$@ 2>/dev/null
 two_file_test_1.o.syms: two_file_test_1.o
@@ -3256,6 +3271,10 @@  incremental_common_test_1: common_test_1_v1.o common_test_1_v2.o gcctestdir/ld
 	@sleep 1
 	cp -f common_test_1_v2.o common_test_1_tmp.o
 	$(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro,-no-pie common_test_1_tmp.o
+common_test_1_v1.o: common_test_1_v1.c
+	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
+common_test_1_v2.o: common_test_1_v2.c
+	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
 
 #check_PROGRAMS += incremental_comdat_test_1
 incremental_comdat_test_1: incr_comdat_test_1.o incr_comdat_test_2_v1.o incr_comdat_test_2_v2.o incr_comdat_test_2_v3.o gcctestdir/ld
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index fdbabcf3cd..8b55f72561 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -2767,6 +2767,10 @@  TEST_AS = $(top_builddir)/../gas/as-new
 @THREADS_TRUE@THREADLIBS = @PTHREAD_LIBS@
 @OMP_SUPPORT_TRUE@TLS_TEST_C_CFLAGS = -fopenmp
 
+# Since GCC 10 defaults to -fno-common, add -fcommon to common tests to
+# force common behavior.
+COMMON_TEST_C_CFLAGS = -fcommon
+
 # 'make clean' is good about deleting some intermediate files (such as
 # .o's), but not all of them (such as .so's and .err files).  We
 # improve on that here.  automake-1.9 info docs say "mostlyclean" is
@@ -7974,12 +7978,18 @@  uninstall-am:
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	$(TEST_STRIP) -o two_file_strip_test two_file_test
 @GCC_TRUE@@NATIVE_LINKER_TRUE@two_file_shared_strip.so: two_file_shared.so
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	$(TEST_STRIP) -S -o two_file_shared_strip.so two_file_shared.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@common_test_1.o: common_test_1.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@common_test_2.o: common_test_2.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
 @GCC_TRUE@@NATIVE_LINKER_TRUE@common_test_2_pic.o: common_test_2.c
-@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c -fpic $(COMMON_TEST_C_CFLAGS) -o $@ $<
 @GCC_TRUE@@NATIVE_LINKER_TRUE@common_test_2.so: common_test_2_pic.o common_test_3.so gcctestdir/ld
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	$(LINK) -shared common_test_2_pic.o common_test_3.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@common_test_3.o: common_test_3.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
 @GCC_TRUE@@NATIVE_LINKER_TRUE@common_test_3_pic.o: common_test_3.c
-@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c -fpic $(COMMON_TEST_C_CFLAGS) -o $@ $<
 @GCC_TRUE@@NATIVE_LINKER_TRUE@common_test_3.so: common_test_3_pic.o ver_test_2.script gcctestdir/ld
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	$(LINK) -shared common_test_3_pic.o -Wl,--version-script,$(srcdir)/ver_test_2.script
 @GCC_TRUE@@NATIVE_LINKER_TRUE@exception_test_1_pic.o: exception_test_1.cc
@@ -8895,6 +8905,11 @@  uninstall-am:
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test.o: plugin_test.c
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@	$(COMPILE) -O0 -c -fpic -o $@ $<
 
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_common_test_1.o: plugin_common_test_1.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_common_test_2.o: plugin_common_test_2.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
+
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@two_file_test_main.o.syms: two_file_test_main.o
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@	$(TEST_READELF) -sW $< >$@ 2>/dev/null
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@two_file_test_1.o.syms: two_file_test_1.o
@@ -9324,6 +9339,10 @@  uninstall-am:
 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	@sleep 1
 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	cp -f common_test_1_v2.o common_test_1_tmp.o
 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro,-no-pie common_test_1_tmp.o
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@common_test_1_v1.o: common_test_1_v1.c
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@common_test_1_v2.o: common_test_1_v2.c
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c $(COMMON_TEST_C_CFLAGS) -o $@ $<
 
 #check_PROGRAMS += incremental_comdat_test_1
 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@incremental_comdat_test_1: incr_comdat_test_1.o incr_comdat_test_2_v1.o incr_comdat_test_2_v2.o incr_comdat_test_2_v3.o gcctestdir/ld