-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
acceptedThis proposal is planned.This proposal is planned.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Description
Proposal
Allow e.g. this:
comptime {
@export(@as(*void, @ptrFromInt(0x2C)), .{ .name = "__tls_array" });
}
Motivated by this std code:
zig/lib/std/os/windows/tls.zig
Lines 11 to 20 in 80f2aeb
comptime { | |
if (builtin.cpu.arch == .x86 and !builtin.abi.isGnu() and builtin.zig_backend != .stage2_c) { | |
// The __tls_array is the offset of the ThreadLocalStoragePointer field | |
// in the TEB block whose base address held in the %fs segment. | |
asm ( | |
\\ .global __tls_array | |
\\ __tls_array = 0x2C | |
); | |
} | |
} |
Presumably it'll also be useful in certain embedded and OS scenarios.
Implementation
- Lowering is straightforward for self-hosted backends.
- Lowering in the LLVM backend will probably emit global assembly that's roughly equivalent to the above std code.
- Lowering in the C backend is an open question. For GCC-compatible compilers, we can obviously just emit global assembly like the LLVM backend, but there doesn't seem to be anything usable for MSVC.
- Fortunately the motivating use case is not relevant here.
nektro
Metadata
Metadata
Assignees
Labels
acceptedThis proposal is planned.This proposal is planned.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.