Commit Graph

60 Commits

Author SHA1 Message Date
Jakub Konka
9d4a4e9ed1 link-tests: update uuid test with new uuid given dyld ops changes 2023-01-19 00:05:54 +01:00
Luuk de Gram
b9224c172f
wasm-linker: Fix & mangle symbol name of imports
When outputting the names section, we should output the actual symbol
name rather than the import name. This makes sure that symbols with
an explicit name set have the correct name but retain the import name
too.

We also now correctly mangle the name of an extern function with an
explicit library name. This ensures that functions that have a
different library name, but the same import/function name, can be
resolved correctly with other modules and don't resolve to the
same symbol.
2023-01-03 10:02:54 +01:00
Luuk de Gram
f9b3e8c762
test/link: add test case for exporting data syms 2023-01-02 18:36:18 +01:00
Luuk de Gram
3e32a18956
test/link: add test case for function table
Adds 3 linker tests to verify the indirect function table
functionality for importing, exporting and its regular definitions.
2023-01-02 18:36:18 +01:00
Luuk de Gram
e4869eeac1
test/link: linker tests for all export cases
Adds a linker test case for each possible export case. This means
one where no exports are done (i.e. no flags set), when the -dynamic
flag is set, and finally when --export=<value> flag(s) are set.
2023-01-02 18:36:17 +01:00
Andrew Kelley
40ba4d4a89
Merge pull request #14102 from Luukdegram/wasm-undefined-symbols
WebAssembly: remove unconditional --allow-undefined flag
2022-12-29 17:59:44 -05:00
Luuk de Gram
8403612adc
test/link: update linker tests
Force importing symbols to show the correct functions are being
imported from the host environment.
2022-12-28 16:49:36 +01:00
Jakub Konka
8d29c84d00 link-tests: test uuid on x86_64-macos too 2022-12-27 16:43:35 +01:00
Jakub Konka
6925ef0f1a zld: exclude strtab padding from uuid calculation 2022-12-27 16:43:35 +01:00
Jakub Konka
8adcc2258f link-tests: redo macho strict validation test to match libstuff 2022-12-27 16:43:35 +01:00
Jakub Konka
2cb6db2219 link-tests: add macho strict validation test
Support more operators when running simple arithmetic tests, and
allow for int literals in the program spec.
2022-12-23 14:02:52 +01:00
Jakub Konka
b20a610f03 link-tests: force cross-comp to exclude host differences 2022-12-17 00:53:47 +01:00
Jakub Konka
9ad24a4aee macho: add uuid link test 2022-12-16 18:31:48 +01:00
Andrew Kelley
28514476ef remove -fstage1 option
After this commit, the self-hosted compiler does not offer the option to
use stage1 as a backend anymore.
2022-12-06 12:15:04 -07:00
Jakub Konka
72769f6cec link-tests: add test case for parsing weak imports 2022-11-06 15:21:28 +01:00
Jakub Konka
5ef33e7c7e
Merge pull request #13459 from ziglang/issue-13457
macho: do not zero-out file if there are no nonzerofill sects
2022-11-06 08:39:13 +01:00
Jakub Konka
aaaa7df152 macho: add linker test case for issue 13457 2022-11-06 00:10:12 +01:00
Luuk de Gram
ef0df24626
test/link: add linker test to verify mangling
This adds a simple linker test to ensure the built library contains
an import entry for each extern function call that was mangled.
2022-11-01 15:43:34 +01:00
Luuk de Gram
2f41109cc4
test/link: add Wasm linker tests for features
Adds a test for inferring features based on a different object file.
Also provides a test case where cpu features are explicitly set on
a library where the end result will output said target features.
2022-10-25 20:48:08 +02:00
Luuk de Gram
c0fe135ff3
test/link: remove redundant dependOn statements
`runAndCompare` will already depend on the `CheckObject` step itself
so it's not needed to also have the test step depend on the
check object step.
2022-10-18 17:20:08 +02:00
jacobly0
bd0dd225e8
Sema: implement linksection on functions
* Sema: implement linksection on functions

 * Implement function linksection in Sema.
 * Don't clobber function linksection/align/addrspace in Sema.
 * Fix copy-paste typo in tests.
 * Add a bunch of missing test_step.dependOn.
 * Fix checkInSymtab match.

Closes #12546
2022-10-18 14:02:10 +03:00
Luuk de Gram
74108bb9c0 test/link: fix Wasm archive test
As memcpy is now part of compiler-rt, we no longer expect
any imports in the binary.
2022-10-15 07:02:38 -07:00
Luuk de Gram
8635c18e40
test/link: don't strip producers section for wasm
When testing the Wasm linker for the producers section
we do not ever want to strip the binary as this will remove
the producers section in release-small.

This fixes the CI errors by d086b371f0
2022-10-11 21:27:09 +02:00
Ali Chraghi
d086b371f0 Compilation: strip debug info from ReleaseSmall by default 2022-10-11 17:51:25 +02:00
Luuk de Gram
fda75f53fa
test/link: Add linker test for producers section
This also turns off non-debug modes for the bss linker tests for
Wasm. This is done as it's not required to guarantee to zero out
the bss section for non-debug modes.
2022-10-08 09:43:40 +02:00
Jakub Konka
54854e2ab8 add removed expected stdout comparison in link test 2022-09-18 09:28:46 +02:00
Jakub Konka
0030e72d53 use EmulatableRunStep for newly added macho link test
Reverts 75e9a8c7fa
2022-09-18 09:22:49 +02:00
Andrew Kelley
75e9a8c7fa skip macho link test execution on non-macOS
2c3d87b168 introduced a new test that
passes on macOS but fails on other operating systems. This commit makes
it only run on macOS.
2022-09-17 21:33:19 -07:00
Jakub Konka
2c3d87b168 macho: test empty translation units 2022-09-17 18:43:24 +02:00
Luuk de Gram
8627858bbc
test/link: add test for extern resolution
Adds a linker tests to verify extern/undefined symbols
representing non-functions are being resolved correctly.
2022-08-30 18:32:08 +02:00
Luuk de Gram
7fe2a3d104
test/link: add wasm linker-test for archives
Adds a test case that will pull-in compiler-rt symbols,
and therefore link with the compiler-rt archive file.
2022-08-20 15:46:39 +02:00
Jakub Konka
9b595dd55f link-test: refactor and reorg
Move common tests by target file format (Wasm, MachO) into helper
functions in `link.zig`, and sort alphabetically within for easier
tracking versus file organization on disk.
2022-08-17 23:13:49 +02:00
Jakub Konka
d84282174c link-test: move tls test to macho/tls
This test was always really testing correct behavior of our in-house
MachO linker to begin with.
2022-08-17 09:00:26 +02:00
Luuk de Gram
72c0cebe5c
test/link/macho: use EmulationStep for dead_strip 2022-07-23 17:27:47 +02:00
Luuk de Gram
4776065036
Use EmulatableRunStep for MachO linker tests 2022-07-23 10:03:51 +02:00
Jakub Konka
2c184f9a5f link-tests: add checkNotPresent and add -dead_strip smoke test
`checkNotPresent` is the inverse of `checkNext` - if the phrase is
found in the output, then it fails the test.
2022-07-22 16:58:21 +02:00
Jakub Konka
d80fcc8a0b macho: rework symbol handling for incremental stage2 builds 2022-07-22 16:58:20 +02:00
Jakub Konka
03feea0fb2 macho: split section into subsections if requested and/or possible 2022-07-22 16:58:20 +02:00
Luuk de Gram
8033767082
wasm-linker: Implement linker tests (#12006)
* test/link: initial wasm support

This adds basic parsing and dumping of wasm section so they
can be tested using the new linker-test infrastructure.

* test/link: all wasm sections parsing and dumping

We now parse and dump all sections for the wasm binary format.
Currently, this only dumps the name of a custom section.
Later this should also dump symbol table, name, linking metadata and relocations.
All of those live within the custom sections.

* Add wasm linker test

This also fixes a parser mistake in reading the flags.

* test/link: implement linker tests wasm & fixes

Adds several test cases to test the wasm self-hosted linker.
This also introduces fixes that were caught during the implementation
of those tests.

* test-runner: obey omit_stage2 for standalone

When a standalone test requires stage2, but stage2 is omit
from the compiler, such test case will not be included as part
of the test suite that is being ran. This is to support CI's
where we omit stage2 to lower the memory usage.
2022-07-12 14:36:33 +02:00
Jakub Konka
5834a608fc link-tests: do not save global extracted var unless a match
Improve testing MachO binaries by verbose printing of the symtab
which includes segment,section names for defined symbols, and
import (dylib) name for imports.
2022-06-28 10:23:25 +02:00
Jakub Konka
075f5bc5ff link-tests: test -weak-lx and -weak_framework x 2022-06-28 09:22:04 +02:00
Jakub Konka
0dd28920da macho: implement and handle -needed-* and -needed_* family of flags
MachO linker now handles `-needed-l<name>`, `-needed_library=<name>`
and `-needed_framework=<name>`. While on macOS `-l` is equivalent
to `-needed-l`, and `-framework` to `-needed_framework`, it can be
used to the same effect as on Linux if combined with `-dead_strip_dylibs`.

This commit also adds handling for `-needed_library` which is macOS
specific flag only (in addition to `-needed-l`).

Finally, in order to leverage new linker testing harness, this commit
added ability to specify lowering to those flags via `build.zig`:
`linkSystemLibraryNeeded` (and related), and `linkFrameworkNeeded`.
2022-06-27 19:53:38 +02:00
Jakub Konka
efc5c97bff macho: implement -dead_strip_dylibs linker flag 2022-06-27 19:53:38 +02:00
Jakub Konka
589bf67635 macho: implement -headerpad_max_install_names 2022-06-25 18:04:40 +02:00
Jakub Konka
a6fbdfabb9 link-tests: add -headerpad_size test scenario 2022-06-25 17:59:09 +02:00
Jakub Konka
f91503e577 link-tests: defer parsing of the RPN program until running the action 2022-06-25 17:56:03 +02:00
Jakub Konka
8f00bc9d23 link-tests: put macho search strategy tests into one test case 2022-06-25 10:57:56 +02:00
Jakub Konka
24821dd17f link-tests: test -search_paths_first and -search_dylibs_first macho flags 2022-06-24 22:07:51 +02:00
Jakub Konka
03ddb42b8b link-tests: rename check() to checkStart()
Do not hardcode the symtab label; instead allow each parser to define
its own.

Check for missing extractor value in the matcher when matching `{}`.
2022-06-23 13:16:03 +02:00
Jakub Konka
ba768614ac link-tests: frameworks example can test for libobjc autolink in safety modes 2022-06-22 18:51:35 +02:00