13165 Commits

Author SHA1 Message Date
Jakub Konka
def7190e84 elf: hook up common symbols handler 2023-10-16 19:33:04 +02:00
Jakub Konka
f4c1b1d9ad elf: implement --verbose-link, and other fixes 2023-10-16 19:33:04 +02:00
Jakub Konka
4af5caa81f elf: add missing generators for special dynamic sections 2023-10-16 19:33:04 +02:00
Jakub Konka
5fa90afb64 elf: fix synthetic section handling and actually parse DSOs 2023-10-16 19:33:04 +02:00
Jakub Konka
d1446565a1 elf: re-enable dynamic linking codepaths 2023-10-16 19:33:04 +02:00
Jakub Konka
04a8f217c6 elf: fix COMDAT deduping logic 2023-10-16 19:33:04 +02:00
Jakub Konka
9a80ac0429 elf: add garbage collection of sections 2023-10-16 19:33:04 +02:00
Jakub Konka
f1b9c365f2 elf: add incomplete handling of build-obj -fllvm -fno-lld 2023-10-16 19:33:04 +02:00
Jakub Konka
727d9431c8 elf: link hello-world in c++ 2023-10-16 19:33:04 +02:00
Jakub Konka
d6cec5a586 elf: add more prepwork for linking c++ objects 2023-10-16 19:33:04 +02:00
Jakub Konka
66f34b15e8 elf: add symbols to .got section directly 2023-10-16 19:33:04 +02:00
Jakub Konka
2c2bc66ce1 elf: handle .eh_frame and non-alloc sections 2023-10-16 19:33:04 +02:00
Jakub Konka
9ccd94d560 elf: refactor object.shdrContents to never error out 2023-10-16 19:33:04 +02:00
Jakub Konka
53340544c6 elf: get hello-world with LLVM in Zig working 2023-10-16 19:33:04 +02:00
Jakub Konka
1b70ad622b elf: port zld's allocation mechanism 2023-10-16 19:33:04 +02:00
Jakub Konka
860beda55f elf: remove dirty from synthetic .got section 2023-10-16 19:33:04 +02:00
Jakub Konka
6faed6269f elf: update section sizes accumulated from objects 2023-10-16 19:33:04 +02:00
Jakub Konka
14cff77d87 elf: create atom lists indexed by section index 2023-10-16 19:33:04 +02:00
Jakub Konka
540ef3e010 elf: sort sections by their rank to combine them by segment flags
Currently this ignores ZigModule, however, I believe we can make it
so that this is done excluding sections/segments emitted by ZigModule
and everything should work out just fine.
2023-10-16 19:33:04 +02:00
Jakub Konka
679accd887 elf: initialize output sections from input objects in a separate step 2023-10-16 19:33:04 +02:00
Jakub Konka
509da2316c elf: run populateMissingMetadata only if ZigModule exists 2023-10-16 19:33:04 +02:00
Jakub Konka
f0f19e18c7 elf: write shdr_table in flush 2023-10-16 19:33:04 +02:00
Jakub Konka
87602092fa elf: write .got in bulk after scanning objects 2023-10-16 19:33:04 +02:00
Jakub Konka
d565f8bef2 elf: check for null atom in ZigModule 2023-10-16 19:33:04 +02:00
Jakub Konka
75f4420c2d elf: increase Atom.Index resolution to u32 2023-10-16 19:33:04 +02:00
Jakub Konka
605e3eb08c elf: clean up generating GOT symbol names 2023-10-16 19:33:03 +02:00
Jakub Konka
43406c0696 elf: update .strtab with GOT symbols 2023-10-16 19:33:03 +02:00
Jakub Konka
d06aa21e48 elf: for now always update .shstrtab and .strtab sections 2023-10-16 19:33:03 +02:00
Jakub Konka
ff1423c4ce elf: reuse addSection in alloc functions 2023-10-16 19:33:03 +02:00
Jakub Konka
c8c50a058e elf: do not prealloc space for .symtab 2023-10-16 19:33:03 +02:00
Jakub Konka
52f8a1a24c elf: move initializing string buffers out of populateMissingMetadata 2023-10-16 19:33:03 +02:00
Veikka Tuominen
14efbf5ed1 Sema: fix missing check for tuple default initializers
Closes #17525
2023-10-16 14:00:18 +03:00
Veikka Tuominen
78855bd218 make distinct error limit configurable
Closes #786
2023-10-16 04:08:45 -04:00
Andrew Kelley
ca690ffa22
Merge pull request #17448 from squeek502/win32-manifest
Add preliminary support for Windows `.manifest` files
2023-10-15 19:47:27 -07:00
Bogdan Romanyuk
ebde525cce
Sema: fix @extern error on function pointer 2023-10-16 01:30:39 +00:00
Ryan Liptak
b51147889f Add warning if .xml file is used, since it's likely intended to be a Windows manifest file
Example:

> zig build-exe test.zig test.xml
warning: embedded manifest files must have the extension '.manifest'
error: unrecognized file extension of parameter 'test.xml'
2023-10-15 13:33:16 -07:00
Ryan Liptak
5f15acc463 Add preliminary support for Windows .manifest files
An embedded manifest file is really just XML data embedded as a RT_MANIFEST resource (ID = 24). Typically, the Windows-only 'Manifest Tool' (`mt.exe`) is used to embed manifest files, and `mt.exe` also seems to perform some transformation of the manifest data before embedding, but in testing it doesn't seem like the transformations are necessary to get the intended result.

So, to handle embedding manifest files, Zig now takes the following approach:

- Generate a .rc file with the contents `1 24 "path-to-manifest.manifest"`
- Compile that generated .rc file into a .res file
- Link the .res file into the final binary

This effectively achieves the same thing as `mt.exe` minus the validation/transformations of the XML data that it performs.

How this is used:

On the command line:
```
zig build-exe main.zig main.manifest
```
(on the command line, specifying a .manifest file when the target object format is not COFF is an error)

or in build.zig:

```
const exe = b.addExecutable(.{
    .name = "manifest-test",
    .root_source_file = .{ .path = "main.zig" },
    .target = target,
    .optimize = optimize,
    .win32_manifest = .{ .path = "main.manifest" },
});
```
(in build.zig, the manifest file is ignored if the target object format is not COFF)

Note: Currently, only one manifest file can be specified per compilation. This is because the ID of the manifest resource is currently always 1. Specifying multiple manifests could be supported if a way for the user to specify an ID for each manifest is added (manifest IDs must be a u16).

Closes #17406

options
2023-10-15 13:33:16 -07:00
Robin Voetter
0552e504d0
spirv: work around OpSource parsing issue in llvm-spirv
The Khronos SPIRV-LLVM translator does not parse OpSource correctly. This
was causing tests to fail and other mysterious issues.

These are resolved by only generating a single OpSource instruction for now,
which does not have the source file locations also.

See https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/2188
2023-10-15 17:07:39 +02:00
Ali Chraghi
45a1945dc4
spirv: simple binary and comparison vector operations 2023-10-15 14:00:33 +02:00
Robin Voetter
9c20449cc5
wasm: lower min/max for floats to compiler_rt
The min and max builtins in Zig have some intricate behavior
related to floats, that is not replicated with the min and max
wasm instructions or using simple select operations. By lowering
these instructions to compiler_rt, handling around NaNs is done
correctly.

See also https://github.com/WebAssembly/design/issues/214
2023-10-15 14:00:32 +02:00
Ali Chraghi
2fe16e072a
spirv: emit vectors as arrays 2023-10-15 14:00:32 +02:00
Robin Voetter
f4064d98e2
spirv: optional comparison 2023-10-15 14:00:31 +02:00
Robin Voetter
10b8171466
spirv: handle errors in switch 2023-10-15 14:00:30 +02:00
Robin Voetter
e2e4e1f8b4
spirv: intcast, trunc for strange ints 2023-10-15 14:00:10 +02:00
Robin Voetter
b1499df1b8
spirv: sign-extension for strange integers 2023-10-15 14:00:09 +02:00
Robin Voetter
839a93a101
intern pool: fix float equality
We need to perform bitwise equality here, otherwise we get
two different entries for nan values.
2023-10-15 14:00:08 +02:00
Robin Voetter
4f279078c8
spirv: air min/max 2023-10-15 14:00:07 +02:00
Robin Voetter
f858bf1616
spirv: air bitcast for non-numeric non-pointer types 2023-10-15 14:00:07 +02:00
Robin Voetter
0af16a58a0
spirv: fix air is_null optional slice field type 2023-10-15 14:00:06 +02:00
Robin Voetter
d0e7a3596b
spirv: allow generation of *i0 2023-10-15 14:00:06 +02:00