Use CXXCOMPILE in gold/testsuite/Makefile for c++ testcases
[binutils-gdb.git] / gold / testsuite / Makefile.am
index b70a7d5a9f7dfeb4aaf8b1c52bdb4397471f2fde..ccbe47f22929820d274003f3b6cbc08d67107465 100644 (file)
@@ -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
@@ -278,6 +282,16 @@ icf_test: icf_test.o gcctestdir/ld
 icf_test.map: icf_test
        @touch icf_test.map
 
+check_SCRIPTS += icf_test_pr21066.sh
+check_DATA += icf_test_pr21066.map
+MOSTLYCLEANFILES += icf_test_pr21066 icf_test_pr21066.map
+icf_test_pr21066.o: icf_test_pr21066.cc
+       $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
+icf_test_pr21066: icf_test_pr21066.o gcctestdir/ld
+       $(CXXLINK) -o icf_test_pr21066 -Bgcctestdir/ -Wl,--icf=all,-Map,icf_test_pr21066.map icf_test_pr21066.o
+icf_test_pr21066.map: icf_test_pr21066
+       @touch icf_test_pr21066.map
+
 check_SCRIPTS += icf_keep_unique_test.sh
 check_DATA += icf_keep_unique_test.stdout
 MOSTLYCLEANFILES += icf_keep_unique_test
@@ -388,7 +402,7 @@ keep_text_section_prefix: keep_text_section_prefix.o gcctestdir/ld
 keep_text_section_prefix_readelf.stdout: keep_text_section_prefix
        $(TEST_READELF) -Wl $< >$@
 keep_text_section_prefix_nm.stdout: keep_text_section_prefix
-       $(TEST_NM) -n $< >$@
+       $(TEST_NM) -n --synthetic $< >$@
 
 check_PROGRAMS += icf_virtual_function_folding_test
 MOSTLYCLEANFILES += icf_virtual_function_folding_test icf_virtual_function_folding_test.map
@@ -727,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
 
@@ -1022,11 +1042,11 @@ if TLS_GNU2_DIALECT
 
 check_PROGRAMS += tls_shared_gnu2_gd_to_ie_test
 
-tls_test_gnu2.o: tls_test.cc
+tls_test_gnu2.o: tls_test.cc gcctestdir/as
        $(CXXCOMPILE) -c -fpic -mtls-dialect=gnu2 -o $@ $<
-tls_test_file2_gnu2.o: tls_test_file2.cc
+tls_test_file2_gnu2.o: tls_test_file2.cc gcctestdir/as
        $(CXXCOMPILE) -c -fpic -mtls-dialect=gnu2 -o $@ $<
-tls_test_c_gnu2.o: tls_test_c.c
+tls_test_c_gnu2.o: tls_test_c.c gcctestdir/as
        $(COMPILE) -c -fpic -mtls-dialect=gnu2 $(TLS_TEST_C_CFLAGS) -o $@ $<
 tls_test_gnu2_shared2.so: tls_test_file2_gnu2.o gcctestdir/ld
        $(CXXLINK) -shared tls_test_file2_gnu2.o
@@ -1192,6 +1212,17 @@ x86_64_indirect_jump_to_direct1: x86_64_indirect_jump_to_direct1.o gcctestdir/ld
 x86_64_indirect_jump_to_direct1.stdout: x86_64_indirect_jump_to_direct1
        $(TEST_OBJDUMP) -dw $< > $@
 
+check_SCRIPTS += x86_64_gd_to_le.sh
+check_DATA += x86_64_gd_to_le.stdout
+MOSTLYCLEANFILES += x86_64_gd_to_le
+
+x86_64_gd_to_le.o: x86_64_gd_to_le.s
+       $(TEST_AS) --64 -o $@ $<
+x86_64_gd_to_le: x86_64_gd_to_le.o gcctestdir/ld
+       gcctestdir/ld -o $@ $<
+x86_64_gd_to_le.stdout: x86_64_gd_to_le
+       $(TEST_OBJDUMP) -dw $< > $@
+
 check_SCRIPTS += x86_64_overflow_pc32.sh
 check_DATA += x86_64_overflow_pc32.err
 MOSTLYCLEANFILES += x86_64_overflow_pc32.err
@@ -2013,7 +2044,7 @@ MOSTLYCLEANFILES += justsyms_lib
 justsyms_lib.o: justsyms_lib.c
        $(COMPILE) -c -o $@ $<
 justsyms_lib: justsyms_lib.o gcctestdir/ld
-       gcctestdir/ld -o $@ -Ttext=0x1000200 -Tdata=0x2000000 -e exported_func justsyms_lib.o
+       gcctestdir/ld -o $@ -z norelro -Ttext=0x1000200 -Tdata=0x2000000 -e exported_func justsyms_lib.o
 
 check_PROGRAMS += binary_test
 MOSTLYCLEANFILES += binary.txt
@@ -2401,7 +2432,7 @@ MOSTLYCLEANFILES += plugin_test_12.err
 export_dynamic_plugin.o.syms: export_dynamic_plugin.o
        $(TEST_READELF) -sW $< >$@ 2>/dev/null
 export_dynamic_plugin.o: export_dynamic_plugin.cc
-       $(COMPILE) -c -o $@ $<
+       $(CXXCOMPILE) -c -o $@ $<
 plugin_test_12: export_dynamic_plugin.o gcctestdir/ld plugin_test.so export_dynamic_plugin.o.syms
        $(CXXLINK) -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z3foov" -Wl,--export-dynamic-symbol,"_Z3foov" export_dynamic_plugin.o.syms 2>plugin_test_12.err
 plugin_test_12.err: plugin_test_12
@@ -2412,9 +2443,9 @@ check_SCRIPTS += plugin_test_wrap_symbols.sh
 check_DATA += plugin_test_wrap_symbols.err
 MOSTLYCLEANFILES += plugin_test_wrap_symbols.err
 plugin_test_wrap_symbols_1.o: plugin_test_wrap_symbols_1.cc
-       $(COMPILE) -c -o $@ $<
+       $(CXXCOMPILE) -c -o $@ $<
 plugin_test_wrap_symbols_2.o: plugin_test_wrap_symbols_2.cc
-       $(COMPILE) -c -o $@ $<
+       $(CXXCOMPILE) -c -o $@ $<
 plugin_test_wrap_symbols: plugin_test_wrap_symbols_1.o plugin_test_wrap_symbols_2.o gcctestdir/ld plugin_test.so
        $(CXXLINK) -Wl,--plugin,"./plugin_test.so" -Wl,--wrap=hello,--wrap=jello plugin_test_wrap_symbols_1.o plugin_test_wrap_symbols_2.o 2>plugin_test_wrap_symbols.err
 plugin_test_wrap_symbols.err: plugin_test_wrap_symbols
@@ -2451,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
@@ -3235,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
@@ -3285,6 +3325,26 @@ pr22266: pr22266_main.o pr22266_ar.o gcctestdir/ld
 pr22266_ar.o: pr22266_a.o gcctestdir/ld
        gcctestdir/ld -r -T $(srcdir)/pr22266_script.t -o $@ pr22266_a.o
 
+if DEFAULT_TARGET_AARCH64
+
+check_PROGRAMS += aarch64_pr23870
+aarch64_pr23870_SOURCES = aarch64_pr23870_foo.c
+aarch64_pr23870_DEPENDENCIES = \
+       gcctestdir/ld gcctestdir/as aarch64_pr23870_main.o \
+       aarch64_pr23870_foo.o aarch64_pr23870_bar.so
+aarch64_pr23870_LDFLAGS = -Wl,-R,. -L. -Wl,-l:aarch64_pr23870_bar.so
+aarch64_pr23870_LDADD = aarch64_pr23870_main.o
+aarch64_pr23870_main.o: aarch64_pr23870_main.S
+       $(COMPILE) -c -o $@ $<
+aarch64_pr23870_foo.o: aarch64_pr23870_foo.c
+       $(COMPILE) -c -o $@ $<
+aarch64_pr23870_bar.o: aarch64_pr23870_bar.c
+       $(COMPILE) -c -fPIC -o $@ $<
+aarch64_pr23870_bar.so: aarch64_pr23870_bar.o
+       $(COMPILE) -shared -o $@ $<
+
+endif DEFAULT_TARGET_AARCH64
+
 endif GCC
 endif NATIVE_LINKER