public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] or1k: Only define TARGET_HAVE_TLS when HAVE_AS_TLS
@ 2022-09-29 14:57 Stafford Horne
  2022-10-01 11:35 ` Stafford Horne
  0 siblings, 1 reply; 3+ messages in thread
From: Stafford Horne @ 2022-09-29 14:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: openrisc, Yann Morin, Stafford Horne

This was found when testing buildroot with linuxthreads enabled.  In
this case, the build passes --disable-tls to the toolchain during
configuration.  After building the OpenRISC toolchain it was still
generating TLS code sequences and causing linker failures such as:

 ..../or1k-buildroot-linux-uclibc-gcc -o gpsd-3.24/gpsctl .... -lusb-1.0 -lm -lrt -lnsl
 ..../ld: ..../sysroot/usr/lib/libusb-1.0.so: undefined reference to `__tls_get_addr'

This patch fixes this by disabling tls for the OpenRISC target when requested
via --disable-tls.

Tested-by: Yann E. MORIN <yann.morin@orange.com>

gcc/ChangeLog:

	* config/or1k/or1k.cc (TARGET_HAVE_TLS): Only define if
	HAVE_AS_TLS is defined.
---
 gcc/config/or1k/or1k.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/config/or1k/or1k.cc b/gcc/config/or1k/or1k.cc
index da2f59062ba..0ce7b234417 100644
--- a/gcc/config/or1k/or1k.cc
+++ b/gcc/config/or1k/or1k.cc
@@ -2206,8 +2206,10 @@ or1k_output_mi_thunk (FILE *file, tree thunk_fndecl,
 #undef  TARGET_LEGITIMATE_ADDRESS_P
 #define TARGET_LEGITIMATE_ADDRESS_P or1k_legitimate_address_p
 
+#ifdef HAVE_AS_TLS
 #undef  TARGET_HAVE_TLS
 #define TARGET_HAVE_TLS true
+#endif
 
 #undef  TARGET_HAVE_SPECULATION_SAFE_VALUE
 #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
-- 
2.37.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] or1k: Only define TARGET_HAVE_TLS when HAVE_AS_TLS
  2022-09-29 14:57 [PATCH] or1k: Only define TARGET_HAVE_TLS when HAVE_AS_TLS Stafford Horne
@ 2022-10-01 11:35 ` Stafford Horne
  2022-10-01 17:53   ` [Buildroot] " Yann E. MORIN
  0 siblings, 1 reply; 3+ messages in thread
From: Stafford Horne @ 2022-10-01 11:35 UTC (permalink / raw)
  To: gcc-patches; +Cc: openrisc, Yann Morin, buildroot

On Thu, Sep 29, 2022 at 03:57:40PM +0100, Stafford Horne wrote:
> This was found when testing buildroot with linuxthreads enabled.  In
> this case, the build passes --disable-tls to the toolchain during
> configuration.  After building the OpenRISC toolchain it was still
> generating TLS code sequences and causing linker failures such as:
> 
>  ..../or1k-buildroot-linux-uclibc-gcc -o gpsd-3.24/gpsctl .... -lusb-1.0 -lm -lrt -lnsl
>  ..../ld: ..../sysroot/usr/lib/libusb-1.0.so: undefined reference to `__tls_get_addr'
> 
> This patch fixes this by disabling tls for the OpenRISC target when requested
> via --disable-tls.
> 
> Tested-by: Yann E. MORIN <yann.morin@orange.com>
> 
> gcc/ChangeLog:
> 
> 	* config/or1k/or1k.cc (TARGET_HAVE_TLS): Only define if
> 	HAVE_AS_TLS is defined.

I have pushed this upstream now.  Adding buildroot patches should be easy to do
now.

-Stafford

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Buildroot] [PATCH] or1k: Only define TARGET_HAVE_TLS when HAVE_AS_TLS
  2022-10-01 11:35 ` Stafford Horne
@ 2022-10-01 17:53   ` Yann E. MORIN
  0 siblings, 0 replies; 3+ messages in thread
From: Yann E. MORIN @ 2022-10-01 17:53 UTC (permalink / raw)
  To: Stafford Horne; +Cc: gcc-patches, openrisc, Yann Morin, buildroot

Stafford, All,

On 2022-10-01 11:35 +0000, Stafford Horne spake thusly:
> On Thu, Sep 29, 2022 at 03:57:40PM +0100, Stafford Horne wrote:
> > This was found when testing buildroot with linuxthreads enabled.  In
> > this case, the build passes --disable-tls to the toolchain during
> > configuration.  After building the OpenRISC toolchain it was still
> > generating TLS code sequences and causing linker failures such as:
> > 
> >  ..../or1k-buildroot-linux-uclibc-gcc -o gpsd-3.24/gpsctl .... -lusb-1.0 -lm -lrt -lnsl
> >  ..../ld: ..../sysroot/usr/lib/libusb-1.0.so: undefined reference to `__tls_get_addr'
> > 
> > This patch fixes this by disabling tls for the OpenRISC target when requested
> > via --disable-tls.
> > 
> > Tested-by: Yann E. MORIN <yann.morin@orange.com>
> > 
> > gcc/ChangeLog:
> > 
> > 	* config/or1k/or1k.cc (TARGET_HAVE_TLS): Only define if
> > 	HAVE_AS_TLS is defined.
> 
> I have pushed this upstream now.  Adding buildroot patches should be easy to do
> now.

That's great, thanks for fixing this! :-)

I'll poke my work alter-ego on Monday to look at providing the backports
for Buildroot.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-01 17:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29 14:57 [PATCH] or1k: Only define TARGET_HAVE_TLS when HAVE_AS_TLS Stafford Horne
2022-10-01 11:35 ` Stafford Horne
2022-10-01 17:53   ` [Buildroot] " Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).