Commit Graph

31720 Commits

Author SHA1 Message Date
Linus Groh
5769592cdd std.os.uefi: Fix calling convention build error
```
std/os/uefi/protocol/simple_text_input.zig:10:63: error: no field named 'Win64' in enum '@typeInfo(builtin.CallingConvention).@"union".tag_type.?'
std/builtin.zig:169:31: note: enum declared here
std/os/uefi/protocol/simple_text_output.zig:9:64: error: no field named 'Win64' in enum '@typeInfo(builtin.CallingConvention).@"union".tag_type.?'
std/builtin.zig:169:31: note: enum declared here
std/os/uefi/tables/runtime_services.zig:26:86: error: no field named 'Win64' in enum '@typeInfo(builtin.CallingConvention).@"union".tag_type.?'
std/builtin.zig:169:31: note: enum declared here
```
2024-10-25 10:45:55 +02:00
David Rubin
97e584a6b9
use cCallingConvention instead of .C in Sema
using `.C` in Sema is incorrect since it will be resolved under the target that Zig was compiled with, not the target build configuration. This is easily solved by just calling `cCallingConvention` on the target to resolve it.
2024-10-25 00:08:41 -07:00
Andrew Kelley
cc671a2d40 std.Build.Watch: implement removing watches for kqueue 2024-10-24 23:31:56 -07:00
David Rubin
0d83304228
remove leak from linker 2024-10-24 23:23:15 -07:00
Andrew Kelley
8819d8b061 std.Build.Watch: limit to one switch on os tag
DRY
2024-10-24 16:29:02 -07:00
Andrew Kelley
7a46ba73ce implement --watch for kqueue
it doesn't detect and remove no longer watched things yet

it also isn't aware of any file names reported by kqueue. I'm unsure if
that functionality exists.
2024-10-24 16:24:56 -07:00
Jakub Konka
56996a2809
link/Coff: simplify file structure by collapsing all files into Coff.zig (#21761)
* coff: collapse Coff/lld.zig logic into Coff.zig

* coff: rename std.coff uses to coff_util

* coff: rename self to coff for *Coff references

* coff: collapse Coff/Atom.zig logic into Coff.zig

* coff: collapse Coff/Relocation.zig logic into Coff.zig

* coff: collapse Coff/ImportTable.zig logic into Coff.zig

* coff: remove unused Coff/Object.zig

* link/Coff: fix rebase gone wrong
2024-10-24 13:50:02 +00:00
Veikka Tuominen
9ffee5abed
Sema: fix check for whether current AnalUnit is a test function
Closes #21159
2024-10-24 13:34:07 +03:00
Andrew Kelley
c563ba6b15
Merge pull request #21700 from ziglang/cli-lib-dirs
move linker input file parsing to the frontend
2024-10-23 22:56:04 -07:00
Andrew Kelley
4bdc2d3871 avoid unnecessarily building Scrt1.o when cross-compiling glibc
which, in this branch causes a miscompilation because it would get sent
to the linker.
2024-10-23 16:27:39 -07:00
Andrew Kelley
5e11790c7b mutex protect comp.arena in --verbose-link 2024-10-23 16:27:39 -07:00
Andrew Kelley
2530d638d6 more helpful message when testTlsOffsetAlignment fails 2024-10-23 16:27:39 -07:00
Andrew Kelley
504ad56815 link.flushTaskQueue: move safety lock
The safety lock needs to happen after check()
2024-10-23 16:27:39 -07:00
Andrew Kelley
ba71079837 combine codegen work queue and linker task queue
these tasks have some shared data dependencies so they cannot be done
simultaneously. Future work should untangle these data dependencies so
that more can be done in parallel.

for now this commit ensures correctness by making linker input parsing
and codegen tasks part of the same queue.
2024-10-23 16:27:39 -07:00
Andrew Kelley
9a511b4b27 work on compiler_rt and fuzzer libs earlier in the pipeline
don't wait for AstGen and C source files to complete before starting to
build compiler_rt and libfuzzer
2024-10-23 16:27:39 -07:00
Andrew Kelley
989e782a01 link.Elf.ZigObject.updateFunc: reduce data dependencies
Unfortunately it's not a complete solution, so a follow-up commit will
need to do something more drastic like not do the linker task queue at
the same time as codegen task queue.

From that point, it is possible to do more work at the same time but
that should be a separate branch. This one has gotten big enough.
2024-10-23 16:27:39 -07:00
Andrew Kelley
e0623df9f7 Compilation.create: skip libc_installation on darwin
If the "is darwin" check is moved below the libc_installation check
below, error.LibCInstallationMissingCrtDir is returned from
lci.resolveCrtPaths().

This should be revisited because it makes sense to check
libc_installation first even on darwin.

Anyway for now this more closely matches logic from master branch.
2024-10-23 16:27:39 -07:00
Andrew Kelley
f2efe05155 use deterministic order in relocatable-eh-frame tests
This test does not pass in master branch either if you flip the object
order around.
2024-10-23 16:27:39 -07:00
Andrew Kelley
3deb9ab30a use unstable sort in relocatable writeSyntheticSections
unstable sort is always better if you have no ties
2024-10-23 16:27:39 -07:00
Andrew Kelley
336466c9df glibc sometimes makes archives be ld scripts
it is incredible how many bad ideas glibc is bundled into one project.
2024-10-23 16:27:39 -07:00
Andrew Kelley
ccac11196b link.Elf: unstable sort for section headers
using name as tie-breaker.
2024-10-23 16:27:39 -07:00
Andrew Kelley
1c45903274 handle _fltused in compiler_rt
so we don't have to do an entire compilation unit for just this silly
symbol
2024-10-23 16:27:39 -07:00
Andrew Kelley
22948616ff split a fat test case 2024-10-23 16:27:39 -07:00
Andrew Kelley
5d75d8f6fc also find static libc files on the host
and don't look for glibc files on windows
2024-10-23 16:27:39 -07:00
Andrew Kelley
2d8ea78249 link.Elf: remove ZigObject from files
By making it a field of link.Elf, it is now accessible without a data
dependency on `files`, fixing a race condition with the codegen thread
and linker thread.
2024-10-23 16:27:38 -07:00
Andrew Kelley
ab33d2e7a9 add missing check for output mode in tsan logic 2024-10-23 16:27:38 -07:00
Andrew Kelley
3cc19cd865 better error messages 2024-10-23 16:27:38 -07:00
Andrew Kelley
d1ecb742ec don't create unused musl crt objects 2024-10-23 16:27:38 -07:00
Andrew Kelley
de0f7fcf52 unify parsing codepaths between relocatable and non 2024-10-23 16:27:38 -07:00
Andrew Kelley
12f3a7c3c2 fix wasm crt logic 2024-10-23 16:27:38 -07:00
Andrew Kelley
3f6b6b1bcd revert macos target version bump 2024-10-23 16:27:38 -07:00
Andrew Kelley
c2898c436f branch fixes 2024-10-23 16:27:38 -07:00
Andrew Kelley
5ca54036ca move linker input file parsing to the compilation pipeline 2024-10-23 16:27:38 -07:00
Andrew Kelley
2dcfa72376 link.Elf: untangle parseObject and parseArchive
from link.Elf, so that they can be used earlier in the pipeline
2024-10-23 16:27:38 -07:00
Andrew Kelley
b510c5719f refactor Compilation.crtFilePath 2024-10-23 16:27:38 -07:00
Andrew Kelley
353d3023c0 fix windows build 2024-10-23 16:27:38 -07:00
Andrew Kelley
e331e81719 link.Elf: refactor output mode checking 2024-10-23 16:27:38 -07:00
Andrew Kelley
cbcd67ea90 link.MachO: fix missing input classification 2024-10-23 16:27:38 -07:00
Andrew Kelley
65d42086ff CLI: dylibs provided by path act as inferred root module 2024-10-23 16:27:38 -07:00
Andrew Kelley
e2a71b37d8 fix MachO linking regression 2024-10-23 16:27:38 -07:00
Andrew Kelley
8cfe303da9 fix resolving link inputs 2024-10-23 16:27:38 -07:00
Andrew Kelley
7656903518 CLI: fix detection of link inputs 2024-10-23 16:27:38 -07:00
Andrew Kelley
861df93768 link.Elf: fix double free of header in parseDso 2024-10-23 16:27:38 -07:00
Andrew Kelley
e567abb339 rework linker inputs
* Compilation.objects changes to Compilation.link_inputs which stores
  objects, archives, windows resources, shared objects, and strings
  intended to be put directly into the dynamic section. Order is now
  preserved between all of these kinds of linker inputs. If it is
  determined the order does not matter for a particular kind of linker
  input, that item should be moved to a different array.
* rename system_libs to windows_libs
* untangle library lookup from CLI types
* when doing library lookup, instead of using access syscalls, go ahead
  and open the files and keep the handles around for passing to the
  cache system and the linker.
* during library lookup and cache file hashing, use positioned reads to
  avoid affecting the file seek position.
* library directories are opened in the CLI and converted to Directory
  objects, warnings emitted for those that cannot be opened.
2024-10-23 16:27:38 -07:00
Andrew Kelley
4706ec81d4 introduce a CLI flag to enable .so scripts; default off
The compiler defaults this value to off so that users whose system
shared libraries are all ELF files don't have to pay the cost of
checking every file to find out if it is a text file instead.

When a GNU ld script is encountered, the error message instructs users
about the CLI flag that will immediately solve their problem.
2024-10-23 16:27:38 -07:00
Andrew Kelley
5b016e290a move ld script processing to the frontend
along with the relevant logic, making the libraries within subject to
the same search criteria as all the other libraries.

this unfortunately means doing file system access on all .so files when
targeting ELF to determine if they are linker scripts, however, I have a
plan to address this.
2024-10-23 16:27:38 -07:00
Andrew Kelley
a4cc344aa0 std.Build.Step.Compile: add a way to expect an error message
other than a compile error, specifically
2024-10-23 16:27:38 -07:00
Andrew Kelley
1e785409bb move link.Elf.LdScript to link.LdScript 2024-10-23 16:27:38 -07:00
Andrew Kelley
028a9a1054 link.Elf.LdScript: eliminate dependency on Elf.File
this allows it to be used by the frontend
2024-10-23 16:27:38 -07:00
Andrew Kelley
33d07f4b6e
Merge pull request #21779 from ziglang/avoid-data-races
link.MachO: remove buggy multi-threading
2024-10-23 16:27:09 -07:00