[m-rev.] for review: TLS and --no-undefined

Peter Wang wangp at students.cs.mu.oz.au
Fri Aug 4 12:38:08 AEST 2006


This shows up on saturn now that shared libraries are enabled on x86-64.
See also http://gcc.gnu.org/ml/gcc/2006-06/msg00493.html 


Estimated hours taken: 0.5
Branches: main

configure.in:
	Check that the `--no-undefined' linker option is compatible with
	thread-local storage.  If not, disable use of that option.  In older
	glibc versions, a reference to a thread-local variable results in a
	reference to an undefined symbol `__tls_get_addr'.


Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.459
diff -u -r1.459 configure.in
--- configure.in	3 Aug 2006 06:26:08 -0000	1.459
+++ configure.in	3 Aug 2006 12:18:13 -0000
@@ -3277,8 +3277,17 @@
 			EXT_FOR_SHARED_LIB=so
 			AC_MSG_CHECKING(if linker supports --no-undefined)
 			rm -f conftest*
-			echo "int main(void) { return 0; }" > conftest.c
-			$CC -Wl,--no-undefined -o conftest conftest.c
+			if test "$mercury_cv_thread_local_storage" = yes; then
+				# --no-undefined doesn't work with TLS
+				# and older versions of glibc.
+				echo "__thread int x;
+				int main(void) { return x; }" > conftest.c
+				$CC -Wl,--no-undefined -fPIC -shared \
+					-o conftest conftest.c 2>/dev/null
+			else
+				echo "int main(void) { return 0; }" > conftest.c
+				$CC -Wl,--no-undefined -o conftest conftest.c
+			fi
 			if test -f conftest; then
 				AC_MSG_RESULT(yes)
 				ERROR_UNDEFINED="-Wl,--no-undefined"
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list