Skip to content

Zig does not provide __tls_get_addr when building PIC without libc #20625

@lamgea

Description

@lamgea

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

In the newly created Zig package (created with zig init):

  1. Referencing the add function in root.zig from main.zig either by extern fn or @import.
  2. Change the library to be dynamically linked and link the library in the build script.

A compilation error will be thrown when trying to build:
ld.lld: undefined reference due to --no-allow-shlib-undefined: __tls_get_addr

It seem to be specific to Linux. I tried cross compiling to Windows and it worked fine.
Related issue in earlier version: #4748

Additionally, append .single_threaded = true to the build option of the library could make it build, but it will give a seg fault when running.

Expected Behavior

It should build and run without errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.os-linuxstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions