1688 Commits

Author SHA1 Message Date
Jacob Young
1c53f0a6b0 Dwarf: workaround crash 2023-05-08 07:36:20 -04:00
Jacob Young
3b1ea390a3 x86_64: cleanup lazy symbols
In theory fixes updating lazy symbols during incremental compilation.
2023-05-01 19:22:53 -04:00
Jakub Konka
565f8979cc link: fix accessing source atom's symbol index in codegen
Since the owner can either be a `Decl` or a `LazySymbol` we need
to preserve this information at the codegen generate function level
so that we can then correctly work out the corresponding `Atom`
in the linker.
2023-05-01 19:22:52 -04:00
Jacob Young
47a34d038d x86_64: implement tagName 2023-05-01 19:22:52 -04:00
Jacob Young
372bc960b8 link: update decl-specific lazy symbols 2023-05-01 19:22:52 -04:00
Jacob Young
f37ca3fa73 link: cleanup lazy alignment
This gets the alignment from the code that creates a lazy symbol instead
of guessing it at every use.
2023-05-01 19:22:52 -04:00
Andrew Kelley
42973d73e6 compiler: use @memcpy instead of std.mem.copy 2023-04-28 13:24:43 -07:00
Andrew Kelley
6261c13731 update codebase to use @memset and @memcpy 2023-04-28 13:24:43 -07:00
Jakub Konka
f56054d129 coff: invalidate GOT relocs after segment shift in memory 2023-04-26 19:08:38 -04:00
Jakub Konka
bc69d5a00f macho: invalidate GOT/stub relocs after segment shift in memory 2023-04-26 19:08:38 -04:00
Jacob Young
e485d00621 cbe: remove unused arena 2023-04-25 13:42:10 -04:00
Andrew Kelley
2dbcc03fb8
Merge pull request #15405 from Luukdegram/wasm
wasm: implement more runtime safety checks
2023-04-23 15:39:36 -07:00
zooster
bc8e1e1de4
Improvements to docs and text
* docs(std.math): elaborate on difference between absCast and absInt

* docs(std.rand.Random.weightedIndex): elaborate on likelihood

I think this makes it easier to understand.

* langref: add small reminder

* docs(std.fs.path.extension): brevity

* docs(std.bit_set.StaticBitSet): mention the specific types

* std.debug.TTY: explain what purpose this struct serves

This should also make it clearer that this struct is not supposed to provide unrelated terminal manipulation functionality such as setting the cursor position or something because terminals are complicated and we should keep this struct simple and focused on debugging.

* langref(package listing): brevity

* langref: explain what exactly `threadlocal` causes to happen

* std.array_list: link between swapRemove and orderedRemove

Maybe this can serve as a TLDR and make it easier to decide.

* PrefetchOptions.locality: clarify docs that this is a range

This confused me previously and I thought I can only use either 0 or 3.

* fix typos and more

* std.builtin.CallingConvention: document some CCs

* langref: explain possibly cryptic names

I think it helps knowing what exactly these acronyms (@clz and @ctz) and
abbreviations (@popCount) mean.

* variadic function error: add missing preposition

* std.fmt.format docs: nicely hyphenate

* help menu: say what to optimize for

I think this is slightly more specific than just calling it
"optimizations". These are speed optimizations. I used the word
"performance" here.
2023-04-23 21:06:21 +03:00
Luuk de Gram
6c1ab376dd
wasm: store __zig_lt_errors_len in linear data
Rather than using a function call to verify if an error fits within
the global error set's length, we now store the error set' size in
the .rodata segment of the linear memory and load that value onto
the stack to check with the integer value.
2023-04-22 21:57:38 +02:00
Luuk de Gram
c4b295bb6e
wasm: implement cmp_lt_errors_len instruction
Creates a global undefined symbol when this instruction is called.
The linker will then resolve it as a lazy symbol, ensuring it is
only generated when the symbol was created. In `flush` it will then
generate the function as only then, all errors are known and we can
generate the function body. This logic allows us to re-use the same
functionality of linker-synthetic-functions.
2023-04-22 21:16:23 +02:00
Casey Banner
c7067ef6e8
sema: fix memory corruption caused by resolveStructLayout 2023-04-22 17:12:35 +00:00
Jakub Konka
14dfbbc213 macho: rebase lazy pointers and apply corrected base offset 2023-04-21 22:44:28 +02:00
Jakub Konka
9a181f367d macho: mark relocs dirty by target when updating GOT/stubs 2023-04-21 22:44:28 +02:00
Jakub Konka
a596e48d8f coff: mark relocs dirty by target when updating GOT 2023-04-21 22:44:28 +02:00
Jakub Konka
dd300d92e1 coff: treat vmaddr of 0 as unallocated when checking if resolvable 2023-04-21 22:44:28 +02:00
Jakub Konka
bee35fe3f0 coff: add image base to GOT relocations
Sort base relocations by address for deterministic debugging.
2023-04-21 22:44:28 +02:00
Jakub Konka
ae8fb21514 coff: use TableSection for GOT 2023-04-21 22:44:28 +02:00
Jakub Konka
d6e66cff12 macho: fix dirtying of GOT entries 2023-04-21 22:44:28 +02:00
Jakub Konka
f9e9974c8f macho: skip GOT for TLVs; handle them separately when lowering 2023-04-21 22:44:27 +02:00
Jakub Konka
9530b95afe macho: refactor common codepath for collecting bindings from TableSection 2023-04-21 22:44:27 +02:00
Jakub Konka
cec4755310 macho: do not allocate atom for __stub_helper preamble 2023-04-21 22:44:27 +02:00
Jakub Konka
fa40267b04 macho: do not allocate atoms for stub entries 2023-04-21 22:44:27 +02:00
Jakub Konka
c55e821df6 macho: resolve relocs before writing to memory (fixes HCS) 2023-04-21 22:44:27 +02:00
Jakub Konka
91bb9302e5 macho: correctly dirty the GOT table after memory realloc 2023-04-21 22:44:27 +02:00
Jakub Konka
c6e916d7fe macho: fix runtime panics 2023-04-21 22:44:27 +02:00
Jakub Konka
711bc2cf39 macho: use generic TableSection for GOT mgmt 2023-04-21 22:44:27 +02:00
Jakub Konka
8e3100ae02 elf: make TableSection a generic construct 2023-04-21 22:44:27 +02:00
Jakub Konka
8a3ad3f620 elf: do not reserve a GOT slot for every Atom 2023-04-21 22:44:25 +02:00
kcbanner
d2a799c65a coff: support allow_shlib_undefined 2023-04-18 18:23:05 -07:00
Jakub Konka
5bc4417d2a tapi: fix memory bugs in yaml parser 2023-04-17 13:35:39 +02:00
Jakub Konka
5e19250a12
Merge pull request #15185 from ziglang/macho-tls
macho: add TLS support
2023-04-13 22:54:55 +02:00
Jakub Konka
1f6165f621 macho: reference TLV thunks via GOT table 2023-04-13 11:47:51 +02:00
Jakub Konka
094ff60252 macho: emit TLV pointers and variables 2023-04-13 11:47:51 +02:00
Jakub Konka
09b6bd86de macho: cleanup dirtying and writing GOT atoms 2023-04-13 11:47:51 +02:00
Jakub Konka
57f9304275 macho: improve reporting of missing symbols
Fix a typo in TLV bootstrap symbol: __tlv_bootstrap.
2023-04-13 11:47:51 +02:00
Jakub Konka
ef645ab175 macho: refactor common logic between synthetic tables 2023-04-13 11:47:51 +02:00
Jakub Konka
38ecaf3ab6 macho: add machinery for emitting TLV refs 2023-04-13 11:47:51 +02:00
Jakub Konka
eba280ce20 macho: refactor relocation type in incremental linker 2023-04-13 11:47:51 +02:00
Jakub Konka
1795b8eb4e macho: emit TLS sections 2023-04-13 11:47:51 +02:00
Jakub Konka
5154ece8b9 macho: fix incorrect DWARF subprogram generation 2023-04-13 11:47:50 +02:00
Luuk de Gram
370401cf60
wasm: generate unnamed constant for tag 2023-04-12 22:23:36 +02:00
Luuk de Gram
3c27df6b13
wasm: generate function to get tag name
When we lower the instruction for `@tagName` we generate a new
function if it doesn't exist yet for that decl. This function creates
an if-else chain to determine which value was provided. Each tag
generates a constant that contains its name as the value. For each
tag we generate a case where the pointer of the string is stored in
the result slice. The length of the tagname is comptime-known, therefore
will be stored in the slice directly without having it being part of
the tagname symbol. In the future this can use a jump table instead
of an if-else chain, similar to the `switch` instruction.
2023-04-12 22:23:32 +02:00
Robin Voetter
d1484bf4b9
spirv: emit nonsemantic info with zig errors
In order to be able to report nice errors in the test runner, and in order
to check SkipZigTest errors, we need to pass the error names to the consumer.
This kind of information can be passed via nonsemantic instructions - using
OpSourceExtension here.

All errors are concatenated into a single string, starting with 'zig_errors:'
for identification, separated by a colon (:). To ensure that we can represent
all error codes, even those which contain a colon, the error names are URI-
escaped. URI-escaping, rather than base64, allows us to see the error names
when viewing disassembled SPIR-V code.
2023-04-09 01:51:55 +02:00
Robin Voetter
e389f524c9
spirv: export functions with .Kernel callconv as entry point
Exported functions which have the .Kernel calling convention are now exported
as entry point. This also works with @export.
2023-04-09 01:51:54 +02:00
Robin Voetter
f12beb857a
amdgpu,nvptx: unify kernel calling conventions
AmdgpuKernel and NvptxKernel are unified into a Kernel calling convention.
There is really no reason for these to be separate; no backend is allowed to
emit the calling convention of the other. This is in the same spirit as the
.Interrupt calling convention lowering to different LLVM calling conventions,
and opens the way for SPIR-V kernels to be exported using the Kernel calling
convention.
2023-04-09 01:51:54 +02:00