[haiku-bugs] [Haiku] #12451: Changes to buildtools results in libstdc++ with broken TLS support

  • From: "jessicah" <trac@xxxxxxxxxxxx>
  • Date: Mon, 09 Nov 2015 21:14:05 -0000

#12451: Changes to buildtools results in libstdc++ with broken TLS support
-----------------------------------+------------------------------
Reporter: jessicah | Owner: bonefish
Type: bug | Status: new
Priority: normal | Milestone: Unscheduled
Component: System/runtime_loader | Version: R1/Development
Keywords: | Blocked By:
Blocking: | Has a Patch: 0
Platform: All |
-----------------------------------+------------------------------
As a result of merging patches in #12430, which changed when the `-shared`
flag gets passed onto `ld`, has broken Haiku's TLS support when building
gcc4/libstdc++ on Haiku.

As a result of the changes, `gcc` generates `R_386_TLS_TPOFF32`
relocations in the configure test for TLS, instead of previously
`R_386_TLS_DTPMOD32` & `R_386_TLS_DTPOFF32`. Currently, `runtime_loader`
doesn't support `R_386_TLS_TPOFF32` relocations. Due to the failed test,
`libstdc++.so` is generated with different symbols (e.g. no
`std::__once_call`), which breaks apps that use TLS (WebPositive being
one).

Example test:
{{{
__thread int a;
int b;
int main() {
return a = b;
}
}}}

My only change to gcc/config/i386/haiku.h:
`s/%{shared:-shared;/%{!r:-shared;/` which was enough to make TLS support
work again, but obviously isn't ideal.

It looks like we have two options: continue to pass `-shared` onto the
linker in the `LINK_SPECS`, or to improve TLS support in `runtime_loader`.

--
Ticket URL: <https://dev.haiku-os.org/ticket/12451>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: