Commit graph

32267 commits

Author SHA1 Message Date
mlugg
b6abe1dbf7
compiler: make it easier to apply breaking changes to std.builtin
Documentation for this will be on the wiki shortly.

Resolves: #21842
2025-01-16 12:49:48 +00:00
mlugg
d00e05f186
all: update to std.builtin.Type.Pointer.Size field renames
This was done by regex substitution with `sed`. I then manually went
over the entire diff and fixed any incorrect changes.

This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since
my regex happened to also trigger here. I opted to leave these changes
in, since they *are* a correct migration, even if they're not the one I
was trying to do!
2025-01-16 12:46:29 +00:00
mlugg
af6bad46cd
std.builtin.Type: rename Pointer.Size fields to lowercase
This matches established naming conventions. Now is an opportune time to
make this change, since we're already performing breaking changes to
`std.builtin.Type`.
2025-01-16 11:37:46 +00:00
Andrew Kelley
d4fe4698d9
Merge pull request #22220 from ziglang/wasm-linker
wasm linker: aggressive rewrite towards Data-Oriented Design
2025-01-16 04:20:41 -05:00
Andrew Kelley
eda8b6e137 link.MachO: fix error reporting in flushModule 2025-01-15 20:21:33 -08:00
Andrew Kelley
ed810eeb06 link.Elf: fix error reporting for failed hot swap 2025-01-15 20:16:40 -08:00
Andrew Kelley
e4868693a5 Compilation: windows doesn't prelink yet 2025-01-15 19:59:53 -08:00
Andrew Kelley
24bdb42a23 test/link/wasm/shared-memory: update to better linker behavior
now it's smarter about omitting tls stuff if there end up being no
TLS data sections
2025-01-15 19:44:20 -08:00
Andrew Kelley
cf898e242a std.Build.Step.CheckObject: better EOF handling
when unexpected end of stream occurs, just add that as a token into the
text
2025-01-15 19:43:46 -08:00
Andrew Kelley
605311211b wasm linker: omit data count section when value is zero 2025-01-15 19:43:31 -08:00
Andrew Kelley
744bb5d16a wasm linker: change rules about symbol visibility
export by default means export, as expected. if you want hidden
visibility then use hidden visibility.
2025-01-15 18:31:44 -08:00
Andrew Kelley
dcb4134835 wasm linker: delete commented out code
this logic has not yet been ported to the new design, but the logic is
safe and sound in the git history and does not need to also live as
commented out code
2025-01-15 18:19:46 -08:00
Andrew Kelley
9dd6efb7e4 wasm linker: fix TLS data segments
fix calculation of alignment and size

include __tls_align and __tls_size globals along with __tls_base

include them only if the TLS segment is emitted

add missing reloc logic for memory_addr_tls_sleb

fix name of data segments to include only the prefix
2025-01-15 18:17:37 -08:00
Andrew Kelley
10db1b9eda wasm linker: fix explicit exports not affecting object files 2025-01-15 18:17:20 -08:00
Andrew Kelley
a4b7e9b97d fix compiler unit tests 2025-01-15 15:22:57 -08:00
Andrew Kelley
ae16414121 wasm linker: ability to get data and functions from objects 2025-01-15 15:11:37 -08:00
Andrew Kelley
a7bd1a631b wasm codegen: fix mistaking extern data as function 2025-01-15 15:11:37 -08:00
Andrew Kelley
204e689bdb tests: remove dead code 2025-01-15 15:11:37 -08:00
Andrew Kelley
42602dc96b test/link/wasm/export-data: update expected behavior
Object being linked has neither functions nor globals named "foo" or
"bar" and so these names correctly fail to be exported when creating an
executable.
2025-01-15 15:11:37 -08:00
Andrew Kelley
50d053f31c test/wasm/infer-features: update to expected behavior
I intentionally simplified the target features functionality to use the
target features that are explicitly specified to the linker and ignore
the "tooling conventions"

this makes the wasm linker behave the same as ELF, COFF, and MachO.
2025-01-15 15:11:37 -08:00
Andrew Kelley
9ddb1c5092 wasm linker: implement --export-table 2025-01-15 15:11:37 -08:00
Andrew Kelley
ec5fc6a2a8 test/link/wasm/function-table: delete bad test
this tests for importing a function table, but the example source does
not try to use an imported table, so it's a useless check. it's unclear
what the behavior is even supposed to do in this case.

the other two cases are left alone.
2025-01-15 15:11:37 -08:00
Andrew Kelley
ae119e395a test/link/wasm/segment: delete bad test
- doesn't run the exe
- checks for data segment named .rodata which is not a thing
- checks for data segment named .bss which is not needed
2025-01-15 15:11:37 -08:00
Andrew Kelley
c565191f30 test/link/wasm/type: remove redundant tests
This test passes now, but let's not run it for the other optimization
modes since they don't affect linker behavior.
2025-01-15 15:11:36 -08:00
Andrew Kelley
617eca13eb wasm-linker: remap function types during flush
this is technically not necessary, and loses value the bigger the output
binary is, however it means a smaller output file, so let's do it.
2025-01-15 15:11:36 -08:00
Andrew Kelley
c2a918b7a3 wasm linker: implement __wasm_init_tls synthetic function 2025-01-15 15:11:36 -08:00
Andrew Kelley
f7f8878716 wasm linker: correct export visibility logic
exports are hidden unless protected or rdynamic or explicitly asked for,
matching master branch
2025-01-15 15:11:36 -08:00
Andrew Kelley
9143575ec3 test/wasm/export: delete redundant tests
the other optimization modes don't affect linking
2025-01-15 15:11:36 -08:00
Andrew Kelley
7ae2f21e2b delete bad linker test: bss
The purpose of this test is unclear. It checks for the existence of bss
section which is completely unnecessary since those zeroes can be
omitted from the binary.

Furthermore the code generated for __wasm_init_memory looks wrong.
Finally, the CheckObject DSL is brittle, it only checks for exact
matches of entire lines in an ad-hoc text format. Conclusion, it's a bad
test, delete it.
2025-01-15 15:11:36 -08:00
Andrew Kelley
b37ad5110c wasm linker: always passive when importing memory
and detect passive inits from Zcu

don't forget to intern function type for __wasm_init_memory

make that function the start function if it is present

don't skip emitting passive data segment data to the binary
2025-01-15 15:11:36 -08:00
Andrew Kelley
c535422423 wasm linker: implement hidden visibility 2025-01-15 15:11:36 -08:00
Andrew Kelley
f89ef2f7cd Compilation.saveState implement saving wasm linker state 2025-01-15 15:11:36 -08:00
Andrew Kelley
9285f91ccc wasm linker: incremental test coverage 2025-01-15 15:11:36 -08:00
Andrew Kelley
1fe1d55c7b wasm linker: reset function exports after flush 2025-01-15 15:11:36 -08:00
Andrew Kelley
1afa6e260e build: respect -Duse-llvm option when doing behavior tests 2025-01-15 15:11:36 -08:00
Andrew Kelley
4cc9cfa7e8 wasm linker: track overaligned uavs 2025-01-15 15:11:36 -08:00
Andrew Kelley
ba4521ac85 wasm linker: fix data segment names 2025-01-15 15:11:36 -08:00
Andrew Kelley
0cf163089e wasm linker: fix @tagName for auto-numbered non-exhaustive enums 2025-01-15 15:11:36 -08:00
Andrew Kelley
cde84c8795 wasm linker: fix missed addend for uav and nav fixups 2025-01-15 15:11:36 -08:00
Andrew Kelley
dd9a647210 wasm linker: fix bad export index math 2025-01-15 15:11:36 -08:00
Andrew Kelley
8abdebecdc wasm linker: implement @tagName for sparse enums 2025-01-15 15:11:36 -08:00
Andrew Kelley
b5261599d7 wasm linker: implement @tagName functions when tags are autoassigned 2025-01-15 15:11:36 -08:00
Andrew Kelley
d0d0847cd0 wasm linker: don't crash on ref to void 2025-01-15 15:11:36 -08:00
Andrew Kelley
e5d78f0b55 codegen: empty tuple can be stored in a runtime var 2025-01-15 15:11:36 -08:00
Andrew Kelley
fbdcb2289b wasm linker: don't pretend it's possible to export data symbols 2025-01-15 15:11:36 -08:00
Andrew Kelley
0dd0ebb6e2 frontend: don't increment remaining_prelink_tasks for windows implibs
yet because they aren't hooked up to the new linker API
2025-01-15 15:11:36 -08:00
Andrew Kelley
220af3f446 wasm-linker: add updateFunc log 2025-01-15 15:11:36 -08:00
Andrew Kelley
7b255235d6 wasm linker: fix off-by-one in function table indexes 2025-01-15 15:11:36 -08:00
Andrew Kelley
e44bafe5ff wasm linker: mark symbol deps on intrinsics 2025-01-15 15:11:36 -08:00
Andrew Kelley
e18a397c85 wasm linker: fix corruption of string bytes
if any fixups are emitted in lowering data, keep the string bytes
allocated even if all zeroes because it is used as a fixup staging area.
2025-01-15 15:11:36 -08:00