config/tls.m4: Use the general dynamic model for the crossed case

Paolo Bonzini bonzini@gnu.org
Tue Oct 16 15:22:00 GMT 2007


> +      dnl Add -fPIC so that the general dynamic model is used as the
> +      dnl compiler may support TLS, but __tls_get_addr() may be absent
> +      dnl from the C library if not supported there.
> +      CFLAGS="$CFLAGS -fPIC"
> +      dnl Similarly, ask the linker to build a shared object and forbid
> +      dnl unresolved symbol references.  This is so that the linker
> +      dnl does not try to convert the object to the local exec model
> +      dnl and the lack of __tls_get_addr() is actually seen.
> +      LDFLAGS="$LDFLAGS -shared -Wl,-z,defs"

I would like to hear from other people if this makes sense but anyway 
this patch is not enough.  You have to do this only when GNU binutils or 
another linker that supports -Wl,-z,defs is being used.  So you should 
split the test in two, one for -Wl,-z,defs and one for TLS.  It might 
also be that -fPIC or -shared is not supported at all in some 
configurations, some of which may support TLS in standalone programs.

Paolo



More information about the Gcc-patches mailing list