aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
AgeCommit message (Collapse)Author
2023-03-18link: use std.os.ptrace wrapper on linuxJakub Konka
2023-03-16link: move macOS kernel inode cache invalidation to MachO linkerJakub Konka
2023-03-15stage2: avoid linux-only APIs on other operating systemsAndrew Kelley
2023-03-15link: only write manifest if we have the exclusive lockAndrew Kelley
Fixes assertion tripping when racing multiple processes that will create the same static archive.
2023-03-15link: PTRACE_ATTACH/PTRACE_DETACHAndrew Kelley
2023-03-15stage2: hot code swapping PoCAndrew Kelley
* CLI supports --listen to accept commands on a socket * make it able to produce an updated executable while it is running
2023-03-06std.os: Allow write functions to return INVAL errorsjim price
In Linux when interacting with the virtual file system when writing in invalid value to a file the OS will return errno 22 (INVAL). Instead of triggering an unreachable, this change now returns a newly introduced error.InvalidArgument.
2023-03-05std.os: Add DeviceBusy as a possible write errorjim price
In Linux when writing to various files in the virtual file system, for example /sys/fs/cgroup, if you write an invalid value to a file you'll get errno 16. This change allows for these specific cases to be caught instead of being lumped together in UnexpectedError.
2023-02-16[elf linker] add --sort-sectionMotiejus Jakštys
Tested by: created a "hello world" C file and compiled with: zig cc -v main.c -Wl,--sort-section=name -o main ... and verified the `--sort-section=name` is passed to ld.lld. Refs https://github.com/zigchroot/zig-chroot/issues/1
2023-02-13move the cache system from compiler to std libAndrew Kelley
2023-02-01link: remove union types which are now internal to backendsJakub Konka
2023-02-01link: make Wasm atoms fully owned by the linkerLuuk de Gram
2023-02-01link: make SpirV atoms fully owned by the linkerJakub Konka
2023-02-01link: decouple DI atoms from linker atoms, and manage them in Dwarf linkerJakub Konka
2023-02-01link: make Plan9 atoms fully owned by the linkerJakub Konka
2023-01-31link: make Coff atoms fully owned by the linkerJakub Konka
2023-01-31link: make Elf atoms fully owned by the linkerJakub Konka
2023-01-31link: make MachO atoms fully owned by the linkerJakub Konka
2023-01-27self-hosted: remove allocateDeclIndexes from the public link.File APIJakub Konka
2023-01-27wasm: migrate to new non-allocateDeclIndexes APILuuk de Gram
2023-01-26coff: migrate to new non-allocateDeclIndexes APIJakub Konka
2023-01-26elf: migrate to new non-allocateDeclIndexes APIJakub Konka
2023-01-26macho: completely remove allocateDeclIndexes in favor of linker trackingJakub Konka
2023-01-23std.os.windows: add possible error NETNAME_DELETED of ReadFileJan Philipp Hafer
Closes #13631
2023-01-20zld: parse, synthesise and emit unwind recordsJakub Konka
2023-01-12wasm-linker: implement __wasm_call_ctors symbolLuuk de Gram
This implements the `__wasm_call_ctors` symbol. This symbol is automatically referenced by libc to initialize its constructors. We first retrieve all constructors from each object file, and then create a function body that calls each constructor based on its priority. Constructors are not allowed to have any parameters, but are allowed to have a return type. When a return type does exist, we simply drop its value from the stack after calling the constructor to ensure we pass the stack validator.
2023-01-05ELF linker: support common-page-size and max-page-size lld optsFrank Denis
These linker flags are required to build static ELF binaries that can run under the Blink emulator: https://github.com/jart/blink/issues/14
2023-01-04windows: fixes to support using zig cc/c++ with CMake on Windowskcbanner
Using zig cc with CMake on Windows was failing during compiler detection. -nostdinc was causing the crt not to be linked, and Coff/lld.zig assumed that wWinMainCRTStartup would be present in this case. -nostdlib did not prevent the default behaviour of linking libc++ when zig c++ was used. This caused libc++ to be built when CMake ran ABI detection using zig c++, which fails as libcxxabi cannot compile under MSVC. - Change the behaviour of COFF -nostdinc to set /entry to the function that the default CRT method for the specified subsystem would have called. - Fix -ENTRY being passed twice if it was specified explicitly and -nostdlib was present. - Add support for /pdb, /version, /implib, and /subsystem as linker args (passed by CMake) - Remove -Ddisable-zstd, no longer needed - Add -Ddisable-libcpp for use when bootstrapping on msvc
2023-01-04fixup formattingkcbanner
2023-01-04windows: supporting changes for boostrapping via msvckcbanner
- add support for passing through .def files to the linker, required for building libLTO.dll in LLVM - fixup libcpp linking conditionals - add option to skip linking zstd for use in bootstrapping (when building against an LLVM with LLVM_ENABLE_ZSTD=OFF)
2023-01-03add -fopt-bisect-limitGuillaume Wenzek
2022-12-29Merge pull request #14102 from Luukdegram/wasm-undefined-symbolsAndrew Kelley
WebAssembly: remove unconditional --allow-undefined flag
2022-12-28link: fix memory leaksJacob Young
* Fix linker memory leaks found while running `zig build test-cases`. * Add missing target to test manifest.
2022-12-25WebAssembly: do not link with --allow-undefined unconditionallyFrank Denis
In #1622, when targeting WebAsembly, the --allow-undefined flag became unconditionally added to the linker. This is not always desirable. First, this is error prone. Code with references to unkown symbols will link just fine, but then fail at run-time. This behavior is inconsistent with all other targets. For freestanding wasm applications, and applications that only use WASI, undefined references are better reported at compile-time. This behavior is also inconsistent with clang itself. Autoconf and cmake scripts checking for function presence think that all tested functions exist, but then resulting application cannot run. For example, this is one of the reasons compilation of Ruby 3.2.0 to WASI fails with zig cc, while it works out of the box with clang. But all applications checking for symbol existence before compilation are affected. This reverts the behavior to the one Zig had before #1622, and introduces an `import_symbols` flag to ignore undefined symbols, assuming that the webassembly runtime will define them.
2022-12-09Revert "coff: specify default base path for relative source paths in pdb"Jakub Konka
2022-12-06remove `-fstage1` optionAndrew Kelley
After this commit, the self-hosted compiler does not offer the option to use stage1 as a backend anymore.
2022-11-10win: combine PDB fixes into one changesetJakub Konka
2022-11-05std.os: take advantage of the freebsd's copy_file_rangeAli Chraghi
2022-10-29Merge pull request #13082 from g-w1/unnamed-decls-and-relocs-p9Andrew Kelley
Plan9: Fix The Backend
2022-10-25use fixed-size arrays for feature listsLuuk de Gram
Considering all possible features are known by the linker during compile-time, we can create arrays on the stack instead of dynamically allocating hash maps. We use a simple bitset to determine whether a feature is enabled or not, and from which object file it originates. This allows us to make feature validation slightly faster and use less runtime memory. In the future this could be enhanced further by having a single array instead with a more sophisticated bitset.
2022-10-24link: add an explicit error set for flush() and flushModule()Andrew Kelley
This makes it easier to understand how control flow should happen in various cases; already just by doing this it is revealed that UndefinedSymbol and UndefinedSymbolReference should be merged, and that MissingMainEntrypoint should be removed in favor of the ErrorFlags mechanism thath we already have for missing the main entrypoint. The main motivation for this change, however, is preventing a compile error when there is conditional compilation inside linker implementations, causing the flush() error set to depend on compilation options. With this change, the error set is fixed, and, notably, the `-Donly-c` flag no longer has compilation errors due to this error set.
2022-10-24additional fixes for Plan9Jacob G-W
with this, the tests should pass
2022-10-23build: add `-Donly-c` optionAndrew Kelley
This option can be used to produce a C backend build of the self-hosted compiler, which only has the C backend enabled. Once the C backend is capable of self-hosting, this will be a way for us to replace our stage1 codebase with a C backend build of self-hosted, which we can then use for bootstrapping. See #5246 for more details. Using this option right now results in a crash because the C backend is not yet passing all the behavior tests.
2022-10-18stage2: better handling of CacheMode.whole on WindowsAndrew Kelley
Windows gives AccessDenied if you delete a directory which contains open file handles. This could be triggered when using CacheMode.whole when cross compiling macho test binaries.
2022-10-05fix(text): hyphenate "comptime" adjectivesr00ster91
2022-09-09Merge remote-tracking branch 'origin/master' into llvm15Andrew Kelley
2022-09-09Merge pull request #12772 from ziglang/coff-basic-importsJakub Konka
coff: implement enough of the incremental linker to pass behavior and incremental tests on Windows
2022-09-08[ld] add --print-* for diagnosticsMotiejus Jakštys
This adds the following for passthrough to lld: - `--print-gc-sections` - `--print-icf-sections` - `--print-map` I am not adding these to the cache manifest, since it does not change the produced artifacts. Tested with an example from #11398: it successfully prints the resulting map and the GC'd sections.
2022-09-07coff: re-enable default entrypoint for WindowsJakub Konka
2022-08-30Merge remote-tracking branch 'origin/master' into llvm15Andrew Kelley