From c8dc28bcc04532f3074a827dc940c033be4be4e7 Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Tue, 19 Jun 2018 18:57:28 -0700 Subject: Replace thread config with automatic config using ax_pthread.m4. The autotools library macro (AX_PTHREAD) is now used to detect if pthreads is present and multi-threaded linking in gold is automatically enabled if it is found. This enables multi-threaded gold on platforms where pthreads is enabled via other methods than just -lpthread (e.g., MinGW). 2018-06-19 Joshua Watt Cary Coutant gold/ * configure.ac: Replace manual thread configuration with AX_PTHREAD. Add --enable-threads=auto. * Makefile.am (THREADFLAGS, THREADLIBS): New defines. (AM_CFLAGS, AM_CXXFLAGS): Add $(THREADFLAGS. (THREADSLIB): Remove; change all references to THREADLIBS. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * config.in: Regenerate. * configure: Regenerate. * testsuite/Makefile.am (THREADSLIB): Replace with... (THREADFLAGS, THREADLIBS): ... these. (LDADD): Remove; add as individual defines for... (object_unittest, binary_unittest, leb128_unittest) (overflow_unittest): ... these tests. (tls_test, tls_pic_test, tls_pie_test, tls_pie_pic_test) (tls_shared_test, tls_shared_ie_test, tls_shared_gd_to_ie_test) (tls_shared_gnu2_gd_to_ie_test, tls_shared_gnu2_test_LDFLAGS) (tls_shared_nonpic_test_LDFLAGS): Add $(THREADFLAGS) and ($THREADLIBS). * testsuite/Makefile.in: Regenerate. --- gold/testsuite/Makefile.am | 54 +++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'gold/testsuite/Makefile.am') diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 99006c5..e019bfa 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -70,7 +70,8 @@ LIBDL = -ldl endif if THREADS -THREADSLIB = -lpthread +THREADFLAGS = @PTHREAD_CFLAGS@ +THREADLIBS = @PTHREAD_LIBS@ endif if OMP_SUPPORT @@ -106,9 +107,6 @@ libgoldtest_a_SOURCES = test.cc testmain.cc testfile.cc DEPENDENCIES = \ libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL_DEP) -LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ - $(THREADSLIB) $(LIBDL) $(ZLIB) - # The unittests themselves if NATIVE_OR_CROSS_LINKER @@ -131,15 +129,27 @@ endif GCC check_PROGRAMS += object_unittest object_unittest_SOURCES = object_unittest.cc +object_unittest_LDFLAGS = $(THREADFLAGS) +object_unittest_LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ + $(THREADLIBS) $(LIBDL) $(ZLIB) check_PROGRAMS += binary_unittest binary_unittest_SOURCES = binary_unittest.cc +binary_unittest_LDFLAGS = $(THREADFLAGS) +binary_unittest_LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ + $(THREADLIBS) $(LIBDL) $(ZLIB) check_PROGRAMS += leb128_unittest leb128_unittest_SOURCES = leb128_unittest.cc +leb128_unittest_LDFLAGS = $(THREADFLAGS) +leb128_unittest_LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ + $(THREADLIBS) $(LIBDL) $(ZLIB) check_PROGRAMS += overflow_unittest overflow_unittest_SOURCES = overflow_unittest.cc +overflow_unittest_LDFLAGS = $(THREADFLAGS) +overflow_unittest_LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ + $(THREADLIBS) $(LIBDL) $(ZLIB) overflow_unittest.o: overflow_unittest.cc $(CXXCOMPILE) -O3 -c -o $@ $< @@ -953,17 +963,17 @@ tls_test_ie_shared.so: tls_test_pic_ie.o tls_test_file2_pic_ie.o tls_test_c_pic_ tls_test_SOURCES = tls_test.cc tls_test_file2.cc tls_test_main.cc tls_test.h tls_test_DEPENDENCIES = gcctestdir/ld tls_test_c.o -tls_test_LDFLAGS = -Bgcctestdir/ -tls_test_LDADD = tls_test_c.o -lpthread +tls_test_LDFLAGS = -Bgcctestdir/ $(THREADFLAGS) +tls_test_LDADD = tls_test_c.o $(THREADLIBS) tls_test_c.o: tls_test_c.c $(COMPILE) -c $(TLS_TEST_C_CFLAGS) -o $@ $< tls_pic_test_SOURCES = tls_test_main.cc tls_pic_test_DEPENDENCIES = gcctestdir/ld tls_test_pic.o tls_test_file2_pic.o \ tls_test_c_pic.o -tls_pic_test_LDFLAGS = -Bgcctestdir/ +tls_pic_test_LDFLAGS = -Bgcctestdir/ $(THREADFLAGS) tls_pic_test_LDADD = tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o \ - -lpthread + $(THREADLIBS) tls_test_main_pie.o: tls_test_main.cc tls_test.h $(CXXCOMPILE) -c -fpie -o $@ $< @@ -975,7 +985,7 @@ tls_test_c_pie.o: tls_test_c.c $(COMPILE) -c -fpic $(TLS_TEST_C_CFLAGS) -o $@ $< tls_pie_test: tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o \ tls_test_c_pie.o gcctestdir/ld - $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o tls_test_c_pie.o -lpthread + $(CXXLINK) -Bgcctestdir/ $(THREADFLAGS) -pie tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o tls_test_c_pie.o $(THREADLIBS) check_SCRIPTS += tls_pie_test.sh check_DATA += tls_pie_test.stdout @@ -984,24 +994,24 @@ tls_pie_test.stdout: tls_pie_test tls_pie_pic_test: tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o \ tls_test_c_pic.o gcctestdir/ld - $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o -lpthread + $(CXXLINK) -Bgcctestdir/ $(THREADFLAGS) -pie tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o $(THREADLIBS) tls_shared_test_SOURCES = tls_test_main.cc tls_shared_test_DEPENDENCIES = gcctestdir/ld tls_test_shared.so -tls_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -tls_shared_test_LDADD = tls_test_shared.so -lpthread +tls_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. $(THREADFLAGS) +tls_shared_test_LDADD = tls_test_shared.so $(THREADLIBS) tls_shared_ie_test_SOURCES = tls_test_main.cc tls_shared_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_ie_shared.so -tls_shared_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -tls_shared_ie_test_LDADD = tls_test_ie_shared.so -lpthread +tls_shared_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. $(THREADFLAGS) +tls_shared_ie_test_LDADD = tls_test_ie_shared.so $(THREADLIBS) tls_shared_gd_to_ie_test_SOURCES = tls_test_main.cc tls_shared_gd_to_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_pic.o \ tls_test_c_pic.o tls_test_shared2.so -tls_shared_gd_to_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. +tls_shared_gd_to_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. $(THREADFLAGS) tls_shared_gd_to_ie_test_LDADD = tls_test_pic.o tls_test_c_pic.o \ - tls_test_shared2.so -lpthread + tls_test_shared2.so $(THREADLIBS) if TLS_GNU2_DIALECT @@ -1019,9 +1029,9 @@ tls_test_gnu2_shared2.so: tls_test_file2_gnu2.o gcctestdir/ld tls_shared_gnu2_gd_to_ie_test_SOURCES = tls_test_main.cc tls_shared_gnu2_gd_to_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_gnu2.o \ tls_test_c_gnu2.o tls_test_gnu2_shared2.so -tls_shared_gnu2_gd_to_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. +tls_shared_gnu2_gd_to_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. $(THREADFLAGS) tls_shared_gnu2_gd_to_ie_test_LDADD = tls_test_gnu2.o tls_test_c_gnu2.o \ - tls_test_gnu2_shared2.so -lpthread + tls_test_gnu2_shared2.so $(THREADLIBS) if TLS_DESCRIPTORS @@ -1032,8 +1042,8 @@ tls_test_gnu2_shared.so: tls_test_gnu2.o tls_test_file2_gnu2.o tls_test_c_gnu2.o tls_shared_gnu2_test_SOURCES = tls_test_main.cc tls_shared_gnu2_test_DEPENDENCIES = gcctestdir/ld tls_test_gnu2_shared.so -tls_shared_gnu2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -tls_shared_gnu2_test_LDADD = tls_test_gnu2_shared.so -lpthread +tls_shared_gnu2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. $(THREADFLAGS) +tls_shared_gnu2_test_LDADD = tls_test_gnu2_shared.so $(THREADLIBS) endif TLS_DESCRIPTORS @@ -1063,8 +1073,8 @@ tls_test_shared_nonpic.so: tls_test.o tls_test_file2.o tls_test_c.o gcctestdir/l tls_shared_nonpic_test_SOURCES = tls_test_main.cc tls_shared_nonpic_test_DEPENDENCIES = gcctestdir/ld tls_test_shared_nonpic.so -tls_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -tls_shared_nonpic_test_LDADD = tls_test_shared_nonpic.so -lpthread +tls_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. $(THREADFLAGS) +tls_shared_nonpic_test_LDADD = tls_test_shared_nonpic.so $(THREADLIBS) endif FN_PTRS_IN_SO_WITHOUT_PIC endif TLS -- cgit v1.1