Commit graph

88 commits

Author SHA1 Message Date
Jakub Konka
66253e5b51 link/elf: populate current Zig version in .comment; test 2024-04-20 23:36:42 +02:00
Jakub Konka
bc0d84be0b test/link/elf: add merge strings test for -r mode 2024-04-20 23:36:42 +02:00
Jakub Konka
342235e5eb test/link/elf: enhance merge strings tests 2024-04-20 23:36:42 +02:00
Jakub Konka
457d84f45a link/elf: remove link.link.build as unused; add some merge strings tests 2024-04-20 23:36:42 +02:00
Jakub Konka
7ba2453b8e test/link/elf: do not check for $thunk in thunks tests for now
Andrew and I have discovered that on Linux max peak rss value
is taken to be `max(build_runner, test_suite)` and since the thunks
test emit a huge binary, we will easily exceed the declared maximum
for any of the test suites. This can be worked around for now by not
checking for $thunk symbols in this test since it doesn't really
yield any additional information; however ideally we would implement
per-thread local temp arena that can be freed.
2024-03-13 08:25:38 +01:00
Jakub Konka
faa4bdb017 elf+aarch64: fix off-by-one in converging on groups interleaved with thunks 2024-03-12 13:16:11 +01:00
Jakub Konka
b1eba5a996 elf+aarch64: actually write out thunks, and add a proper link test 2024-03-12 13:16:11 +01:00
Tristan Ross
c260b4c753
std.builtin: make global linkage fields lowercase 2024-03-11 07:09:10 -07:00
Jakub Konka
1a6b2e84ac test/link/elf: remove pie hack due to QEMU bug that is now fixed 2024-03-10 10:39:31 +01:00
Jakub Konka
b7b63855d0 test/link/elf: enable tests for aarch64 cpu arch 2024-03-09 19:26:26 +01:00
Jakub Konka
ddb33baa11 test/link/elf: test static linking C riscv64-musl 2024-02-21 23:08:29 +01:00
Jakub Konka
55dadc3d85 test/link/elf: test static linking C aarch64-musl 2024-02-21 22:40:03 +01:00
Jakub Konka
d93a0763d4 test/link/link: pass build options to elf and macho tests 2024-01-24 12:34:39 +01:00
Jakub Konka
aa50bca151 test/link/elf: make invalid input file test less janky 2024-01-24 12:34:39 +01:00
Jakub Konka
b1ffc2b8b3 test/link/elf: patch up relocatable test 2024-01-15 00:18:50 +01:00
Jakub Konka
d7c2324cdb test/link/elf: trigger build system bug testing relocatable mode 2024-01-14 20:51:03 +01:00
Carl Åstholm
3cd646869b Add tests for --undefined-version 2024-01-09 17:26:10 +01:00
Andrew Kelley
b92e30ff0b std.Build.ResolvedTarget: rename target field to result
This change is seemingly insignificant but I actually agonized over this
for three days. Some other things I considered:

* (status quo in master branch) make Compile step creation functions
  accept a Target.Query and delete the ResolvedTarget struct.
  - downside: redundantly resolve target queries many times
* same as before but additionally add a hash map to cache target query
  resolutions.
  - downside: now there is a hash map that doesn't actually need to
    exist, just to make the API more ergonomic.
* add is_native_os and is_native_abi fields to std.Target and use it
  directly as the result of resolving a target query.
  - downside: they really don't belong there. They would be available
    as comptime booleans via `@import("builtin")` but they should not
    be exposed that way.

With this change the downsides are:
* the option name of addExecutable and friends is `target` instead of
  `resolved_target` matching the type name.
  - upside: this does not break compatibility with existing build
    scripts
* you likely end up seeing `target.result.cpu.arch` rather than
  `target.cpu.arch`.
  - upside: this is an improvement over `target.target.cpu.arch` which
    it was before this commit.
  - downside: `b.host.target` is now `b.host.result`.
2024-01-01 17:51:18 -07:00
Andrew Kelley
3179f58c41 rename std.zig.CrossTarget to std.Target.Query 2024-01-01 17:51:18 -07:00
Andrew Kelley
04480f72d8 fix linker test regressions
Caused by problems with transitive dependencies
2024-01-01 17:51:18 -07:00
Andrew Kelley
142471fcc4 zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.

The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.

* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
  std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
  std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
  `std.Build.Module.addCMacro` is provided.
  - remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
  - use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
  - use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
  Along with other fields, those unspecified options will be inherited
  from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
  to get the host target.
2024-01-01 17:51:18 -07:00
Jakub Konka
f26459e594 lib/std/Build/CheckObject: update all tests to new API 2023-12-13 12:06:25 +01:00
Jakub Konka
d05db52616 elf: copy out committed ZigObject to a buffer when creating static lib 2023-12-05 17:29:26 +01:00
Jakub Konka
ee1630beea elf: exit early with an error when parsing or init failed 2023-12-05 16:31:47 +01:00
Jakub Konka
297c39ff56 test/link/elf: adjust tests for new errors 2023-12-05 14:40:13 +01:00
Jakub Konka
85c0485fd9 elf: test -r mode does not create unneeded .eh_frame section 2023-11-16 10:54:39 +01:00
Jakub Konka
f6bf3353b1 elf: test -r mode with archive on the linker line 2023-11-16 10:51:21 +01:00
Jakub Konka
17177727c0 test/link: refactor common bits between ELF and MachO tests 2023-11-10 13:50:33 +01:00
Jakub Konka
7566a8fbd8 test/link: spawn ELF and MachO tests from the same root test/link/link.zig 2023-11-10 13:44:43 +01:00
Jakub Konka
73fd4ed54b test/link/elf: make .eh_frame relocatable test also verify COMDATs we emit 2023-11-09 23:22:47 +01:00
Jakub Konka
50f48022f0 test/link/elf: fix .eh_frame test 2023-11-09 14:51:00 +01:00
Jakub Konka
f607126614 test/link/elf: verify we can output a valid relocatable with .eh_frame section 2023-11-09 11:49:04 +01:00
Jakub Konka
9bcb432a0e elf: test emitting relocatable 2023-11-08 18:41:09 +01:00
Jakub Konka
bf0387b6bb
Merge pull request #17873 from ziglang/elf-archive
elf: implement archiving input object files
2023-11-07 03:22:14 +01:00
Jakub Konka
261db02018 CheckObject: support parsing and dumping archive symtab for ELF 2023-11-06 21:18:26 +01:00
Jakub Konka
6490e2ed82 test/link/elf: improve test linking with static lib 2023-11-06 14:47:01 +01:00
Andrew Kelley
702b809ea3
Merge pull request #17815 from Luukdegram/wasm-no-entry
wasm-linker: implement `-fno-entry` and correctly pass `--shared` and `--pie` when given
2023-11-05 18:44:12 -05:00
Jakub Konka
205f8214d8 test/link/elf: enable our ELF archiver 2023-11-05 13:42:26 +01:00
Jakub Konka
ee66137269 elf: add link smoke tests covering emitting obj and static lib 2023-11-04 09:13:34 +01:00
Jakub Konka
b8c8565e93 elf: implement --gc-sections for non-LLVM Zig source 2023-11-04 09:08:27 +01:00
Luuk de Gram
c893f83715
cli: consolidate entry point flags 2023-11-03 12:48:53 +01:00
Jakub Konka
bc081901dc Step.Compile: differentiate between fuzzy and exact matches for compile errors 2023-10-25 11:40:16 +02:00
Jakub Konka
55c7a6d99d elf: test unknown file type error 2023-10-24 23:11:50 +02:00
Jakub Konka
bc9ab3a613 elf: test mismatched cpu architecture error 2023-10-24 22:48:55 +02:00
Jakub Konka
c9c210a4e7 elf: test path errors in ld script parsing 2023-10-24 22:31:25 +02:00
Jakub Konka
403e539669 elf: test unresolved symbol reference error 2023-10-24 22:08:36 +02:00
Jakub Konka
8087ec8e8c elf: improve parsing of ld scripts and actually test linking against them 2023-10-24 19:03:00 +02:00
Jakub Konka
b8ff989fa0 elf: force pie in tests affected by QEMU bug 2023-10-19 19:46:23 +02:00
Jakub Konka
1bbe521074 elf: fix flaky link tests 2023-10-19 03:34:47 +02:00
Andrew Kelley
aeadcb3918 disable flaky linker test
tracked by #17576
2023-10-17 21:46:13 -07:00