18921 Commits

Author SHA1 Message Date
Jakub Konka
a6fbdfabb9 link-tests: add -headerpad_size test scenario 2022-06-25 17:59:09 +02:00
Jakub Konka
8c1feef4cd macho: implement -headerpad_size option
Includes both traditiona and incremental codepaths with one caveat that
in incremental case, the requested size cannot be smaller than the
default padding size due to prealloc required due to incremental nature
of linking.

Also parse `-headerpad_max_install_names`, however, not actionable just yet -
missing implementation.
2022-06-25 17:59:08 +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
0078d36ff3
Merge pull request #11917 from motiejus/wl-search-paths
macho: implement `-search_paths_first` and `-search_dylibs_first`
2022-06-25 17:55:26 +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
dfdb807543 cache setting macho search strategy flags 2022-06-25 10:50:00 +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
eadac47631 cli: let the linker resolve libs into dynamic and static
Unlike targeting ELF-based OSes such as Linux, resolving system libs
on Darwin should follow one of two strategies: `-search_paths_first`
or `-search_dylibs_first` and hence we defer always forcing linking
a static library to the linker.
2022-06-24 22:02:19 +02:00
Jakub Konka
b60938eefd macho: verbose print all input linker args verbatim 2022-06-24 22:01:29 +02:00
Jakub Konka
905a18849f
Merge pull request #11923 from koachan/sparc64-codegen
stage2: sparc64: Another batch of new Air lowerings, improvements, and fixes
2022-06-24 20:29:21 +02:00
Jakub Konka
0df7ed79d3 macho: implement -search_dylibs_first linker option 2022-06-24 20:25:16 +02:00
Motiejus Jakštys
d589047e80 zld: ignore -search_paths_first
Ignore MachO-specific flag -search_paths_first, since it is the default
in zld and ld64.

Also see Jakub's comment[1]:

    Changing topic slightly, @motiejus dunno if you noticed, with this
    change building arm64 Zig binary fails on macos - it complains about
    unknown -search_paths_first flag. This one is an easy fix: we should
    ignore it since this is the default behaviour in both ld64 and zld.

[1]: https://github.com/ziglang/zig/pull/11906#issuecomment-1163545849
2022-06-24 19:03:15 +02:00
Koakuma
672d6df429 stage2: sparc64: Skip Sema-failing tests for now 2022-06-24 21:19:33 +07:00
Koakuma
ad176b319d stage2: sparc64: Implement SPARCv9 movr 2022-06-24 21:19:33 +07:00
Koakuma
65c5ef52e9 stage2: sparc64: Implement airRem, airMod, and SPARCv9 s/udivx 2022-06-24 21:19:33 +07:00
Koakuma
27adee3f12 stage2: sparc64: Implement airErrUnionPayloadPtrSet 2022-06-24 21:19:33 +07:00
Koakuma
84a57987c7 stage2: sparc64: Implement airAggregateInit 2022-06-24 21:19:33 +07:00
Koakuma
dd57729299 stage2: sparc64: Update BigTomb implementation to use Liveness
Change BigTomb implementation to call to Liveness' implementation
rather than implementing feed() in itself.
This is modelled after the AArch64 backend.
2022-06-24 21:19:33 +07:00
Koakuma
e2cb25358e stage2: sparc64: Implement airCall with BigTomb use for return 2022-06-24 21:19:33 +07:00
Koakuma
26b63b022f stage2: sparc64: Add airMemset placeholder 2022-06-24 21:19:33 +07:00
Koakuma
4fd0500bb5 stage2: sparc64: Implement airBoolToInt 2022-06-24 21:19:33 +07:00
Koakuma
837cd0d8af stage2: sparc64: Fix airNot comments/error messages 2022-06-24 21:19:33 +07:00
Koakuma
be6718b796 stage2: sparc64: Implement airIsNull/airIsNonNull 2022-06-24 21:19:33 +07:00
Koakuma
4d15284c3c stage2: sparc64: Implement SPARCv9 shifts 2022-06-24 21:19:33 +07:00
Koakuma
513ab4eb56 stage2: sparc64: Implement airIntCast basics 2022-06-24 21:19:33 +07:00
Koakuma
36bfe4b7ef stage2: sparc64: Implement airFence + SPARCv9 membar 2022-06-24 21:19:33 +07:00
Koakuma
18d61d691c stage2: sparc64: Implement airArrayElemVal 2022-06-24 21:19:33 +07:00
Koakuma
672cd2f02f stage2: sparc64: Implement SPARCv9 and 2022-06-24 21:19:33 +07:00
Koakuma
6218d70d09 stage2: sparc64: Implement airBinOp for and, or, and xor 2022-06-24 21:19:33 +07:00
Koakuma
921f776224 stage2: sparc64: Implement airTry 2022-06-24 21:19:27 +07:00
Koakuma
40590c8bf9 stage2: sparc64: Save registers before calling another function 2022-06-24 21:08:41 +07:00
Koakuma
5c8612642b stage2: sparc64: Use official encoding for not rs2, rs1 2022-06-24 21:08:41 +07:00
Koakuma
e7fde5f64e stage2: sparc64: Introduce condition_register MCValue type
Introduce condition_register MCValue type for future uses with BPr/MOVr
(mostly when needing to compare a signed value with zero)
2022-06-24 21:08:41 +07:00
Koakuma
accc3bad63 stage2: sparc64: Move conditional branch emission out of airCondBr 2022-06-24 21:08:41 +07:00
Koakuma
8b3f7d2ad8 stage2: sparc64: Merge the compare_flag structs into condition_flags
This follows the design in the aarch64 backend (commit
61844b6bd405b4cca3ab673284609aa6a651d506).
2022-06-24 21:08:40 +07:00
Luuk de Gram
7c87f9c828 link:clarification & enable MachO getGlobalSymbol
This adds clarification to the getGlobalSymbol doc comments,
as well as renames the `addExternFn` function for MachO to `getGlobalSymbol`.
This function will now be called from 'src/link.zig' as well.

Finally, this also enables compiling zig's libc using LLVM even though
the `fno-LLVM` flag is given.
2022-06-24 08:12:17 +02:00
Luuk de Gram
3868864695 Revert "wasm: Enable f16 behavior tests"
This reverts commit 3c34c9f13c67ff1716a9531e87d23a6dad12b45e.
2022-06-24 08:12:17 +02:00
Luuk de Gram
6ae898b244 wasm: more f16 support and cleanup of intrinsics
`genFunctype` now accepts calling convention, param types, and return type
as part of its function signature rather than `fnData`. This means
we no longer have to create a dummy for our intrinsic call abstraction.
This also adds support for f16 division and builtins such as `@ceil` & more.
2022-06-24 08:12:17 +02:00
Luuk de Gram
ba37bc81e9 wasm: Enable f16 behavior tests 2022-06-24 08:12:17 +02:00
Luuk de Gram
a6747d328c stage2: Enable compiler-rt when LLVM is existant
Rather than checking if the user wants to use LLVM for the current compilation,
check for the existance of LLVM as part of the compiler. This is temporarily,
until other backends gain the ability to compiler LLVM themselves.
This means that when a user passed `-fno-LLVM` we will use the native
backend for the user's code, but use LLVM for compiler-rt.

This also fixes emitting names for symbols in the Wasm linker,
by deduplicating symbol names when multiple symbols point the same object.
2022-06-24 08:12:17 +02:00
Luuk de Gram
9015efe405 wasm: Implement @mulAdd for f16
Implements `@mulAdd` for floats with bitsize 16, where it generates
a call into compiler-rt's `fmaf` function. Note that arguments
for fmaf are different in order than `@mulAdd`.
2022-06-24 08:12:17 +02:00
Luuk de Gram
5ebaf49ebb wasm: Implement basic f16 support
This implements binary operations and comparisons
for floats with bitsize 16. It does this by calling into
compiler-rt to first extend the float to 32 bits, perform the operation,
and then finally truncate back to 16 bits. When loading and storing the f16,
we do this as an unsigned 16bit integer.
2022-06-24 08:12:17 +02:00
Luuk de Gram
241180216f wasm-linker: Parse object file from the archive
Rather than finding the original object file, we seekTo to the
object file's position within the archive file, and from there open
a new file handle. This file handle is passed to the `Object` parser
which will create the object.
2022-06-24 08:12:17 +02:00
Luuk de Gram
c9f929a18b fix memory leaks 2022-06-24 08:12:17 +02:00
Luuk de Gram
16daf3f3bc wasm-link: Discard old symbols correctly
When a new symbol is resolved to an existing symbol where
it doesn't overwrite the existing symbol, we now add this symbol
to the discarded list. This is required so when any relocation points
to the symbol, we can retrieve the correct symbol it's resolved by instead.
2022-06-24 08:12:17 +02:00
Luuk de Gram
1a3f58f5e5 wasm-linker: Correctly resolve function type
When performing relocations for a type index,
we first check if the target symbol is undefined. In which case,
we will obtain the type from the `import` rather than look into the
`functions` table.
2022-06-24 08:12:17 +02:00
Luuk de Gram
cb28fc2e63 wasm-linker: Resolve symbols from archives
Lazily load object files by default, and only load the object file
when an unresolved symbol has been found within an archive.
2022-06-24 08:12:17 +02:00
Luuk de Gram
0606fbbc4b wasm-linker: Implement Archive parsing
This implements a very basic archive file parser that validates
the magic bytes, and then parses the symbol table and stores
the symbol and their position.
2022-06-24 08:12:17 +02:00
Luuk de Gram
4d3715d89f wasm-linker: de-duplicate functions+atom sorting
Multiple symbols can point to the same function, this means that when we loop over
the symbol list, we must deduplicate those functions being added twice.
Additionaly, we must also ensure that when we append a new type and set the type
index on a function, we must not do this again for the same function.

This commit also implements sorting of code atoms to ensure their order matches
the order of the function section to ensure the function signature matches
that of the function body.
2022-06-24 08:12:17 +02:00
Luuk de Gram
8d03e4fc6b link: Implement API to get global symbol index 2022-06-24 08:12:17 +02:00