# fix thread local variables for non\- position independent code · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/e4d595a8ba2e4466dc29bec7bc90a04420b34d4d)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: e4d595a8ba2e4466dc29bec7bc90a04420b34d4d

Requested commit: e4d595a8ba2e4466dc29bec7bc90a04420b34d4d

Commit: e4d595a8ba2e4466dc29bec7bc90a04420b34d4d

Tree: 4d062b3b3a2cb026b9f12b49b618e9d3a68ffc2e

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
fix thread local variables for non- position independent code

This fixes comes thanks to Rich Felker from the musl libc project,
who gave me this crucial information:

"to satisfy the abi, your init code has to write the same value
to that memory location as the value passed to the [arch_prctl]
syscall"

This commit also changes the rules for when to build statically
by default. When building objects and static libraries, position
independent code is disabled if no libraries will be dynamically
linked and the target does not require position independent code.

closes #2063

```

## Parents

- [70ae3222b54c05fc88e9c94a1ae12ead07fa4341](https://git.cafe/gitcafe/zig/commit/70ae3222b54c05fc88e9c94a1ae12ead07fa4341?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/e4d595a8ba2e4466dc29bec7bc90a04420b34d4d?format=markdown)
