aboutsummaryrefslogtreecommitdiff
path: root/src/link.cpp
AgeCommit message (Collapse)Author
2019-07-07ability to target any glibc versionAndrew Kelley
2019-07-01Added function-section functionalityTimon Kruiper
2019-06-17Remove duplicate exe name with zig runJonathan Marler
2019-06-07update the default macos version min to 10.14Andrew Kelley
2019-06-04Stop the musl builder from skipping necessary filesLemonBoy
The code assumed that the architecture-specific bits, found in the arch/ subfolder, were only overrides for the generic .c files. Changed the logic to always include the whole architecture-specific implementations and discard the generic ones, this way we won't exclude files with no .c counterpart.
2019-05-29cleanups for windows subsystem in builtin.zigAndrew Kelley
2019-05-27improve the stack check CLI optionsAndrew Kelley
See #2526
2019-05-20Remove macos-specific linking hacksLemonBoy
2019-05-16improvements to build-lib use case of WebAssemblyAndrew Kelley
* build-exe does include the startup code that supplies _start for the wasm32-freestanding target. Previously this did not occur because of logic excluding "freestanding". * build-lib for wasm32-freestanding target gets linked by LLD. To avoid infinite recursion, compiler_rt and zig libc are built as objects rather than libraries. - no "lib" prefix and ".wasm" extension instead of ".a". Rather than build-lib foo.zig producing "libfoo.a", now it produces "foo.wasm". * go back to using `.o` extension for webassembly objects * zig libc only provides _start symbol for wasm when linking libc.
2019-05-15fix static builds of zig from requiring c compilerAndrew Kelley
to be installed when linking libc. When zig links against libc, it requires a dynamic linker path. Usually this can be determined based on the architecture and operating system components of the target. However on some systems this is not correct; because of this zig checks its own dynamic linker. When zig is statically linked, this information is not available, and so it resorts to using cc -print-filename=foo to find the dynamic linker path. Before this commit, Zig incorrectly exited with an error if there was no c compiler installed. Now, Zig falls back to the dynamic linker determined based on the arch and os when no C compiler can be found.
2019-05-15improvements to zig's implementation of libc and WebAssemblyAndrew Kelley
* rename std/special/builtin.zig to std/special/c.zig not to be confused with @import("builtin") which is entirely different, this is zig's multi-target libc implementation. * WebAssembly: build-exe is for executables which have a main(). build-lib is for building libraries of functions to use from, for example, a web browser environment. - for now pass --export-all for libraries when there are any C objects because we have no way to detect the list of exports when compiling C code. - stop passing --no-entry for executables. if you want --no-entry then use build-lib. * make the "musl" ABI the default ABI for wasm32-freestanding. * zig provides libc for wasm32-freestanding-musl.
2019-05-13Assemble asm files using CCLemonBoy
Stuffing all the files together and compiling the resulting blob with the main program is a terrible idea. Some files, namely the .S ones, must be run trough the C preprocessor before assembling them (#2437). Beside that the aggregate may be mis-compiled due to the presence of some flags that affect the following code. For example let's consider two files, a.s and b.s a.s ``` fn1: ret .data data1: .word 0 ``` b.s ``` fn2: ret ``` Now, fn1 and fn2 will be both placed in the .text section as intended if the two files are compiled separately. But if we merge them the `.data` flag ends up placing fn2 in the wrong section! This fixes a nasty crash where musl's memset ended up in the non-executable data segment, leading to too many hours of head-scratching.
2019-05-08fix build on macOSAndrew Kelley
Sadly due to a workaround for LLD linker limitations on macOS we cannot put libuserland into an .a file; instead we have to use object files. Again due to linker limitations, bundling compiler_rt.o into another relocatable object also doesn't work. So we're left with disabling stack probing on macOS for the stage1 self-hosted code. These workarounds could all be removed if the macos support in the LLD linker improved, or if Zig project had its own linker that did not have these issues.
2019-05-08add --bundle-compiler-rt function to link optionsAndrew Kelley
and use it when building libuserland.a The self-hosted part of stage1 relies on zig's compiler-rt, and so we include it in libuserland.a. This should potentially be the default, but for now it's behind a linker option. self-hosted translate-c: small progress on translating functions.
2019-05-03Switch wasm export-all to only values marked exportsBenjamin Feng
2019-04-29Merge pull request #2139 from emekoi/lib-on-mingwAndrew Kelley
implement linking to libc on mingw
2019-04-27added static_crt_dir to libc fileemekoi
2019-04-20renamed add_gnu_link_argsemekoi
2019-04-16remove workaround for LLD bugAndrew Kelley
Zig's embedded LLD now has a patch to resolve the deadlock race condition, and the patch is getting upstreamed too, so this closes #2283.
2019-04-15disable threads when linking WebAssembly to work around an LLD bugAndrew Kelley
See #2283
2019-04-14wasi: don't pass --no-entry to linkerShritesh Bhattarai
2019-04-11delete unused functionAndrew Kelley
missed by 27cd830ec8ca1dd
2019-04-11Add initial support for iOS targets (#2237)Matthew Iannucci
* Add iOS C int sizes... try to hack in iOS DebugInfo * Get rid of ios link check for now * Remove macos linkversion check
2019-04-10Build compiler_rt for WASM exeShritesh Bhattarai
2019-04-05wasm: Pass --allow-undefined and --export-all to the linkerShritesh Bhattarai
2019-04-04fixed linking of system libraries on mingwemekoi
2019-04-04added code for linking libc on mingwemekoi
2019-04-04made lld flags on windows consistentemekoi
2019-03-20Merge remote-tracking branch 'origin/llvm8'Andrew Kelley
2019-03-19disable all C warnings when building muslAndrew Kelley
2019-03-18Merge remote-tracking branch 'origin/master' into llvm8Andrew Kelley
2019-03-18libc: separate linux headers from musl/glibcAndrew Kelley
2019-03-17when linking msvcrt, also link ntdll.libAndrew Kelley
See #2073
2019-03-14macho linking: always -dynamic for non-static-libsAndrew Kelley
2019-03-13ignore -lm on darwin because it's handled by libSystemAndrew Kelley
2019-03-13force windows to link against dynamic msvcrtAndrew Kelley
See #2064
2019-03-13breaking: remove --static; add -dynamicAndrew Kelley
`--static` is no longer an option. Instead, Zig makes things as static as possible by default. `-dynamic` can be used to choose a dynamic library rather than a static one. `--enable-pic` is a new option. Usually it will be enabled automatically, but in the case of build-exe with no dynamic libraries on Linux or freestanding, Zig chooses off by default. closes #1703 closes #1828
2019-03-13Merge remote-tracking branch 'origin/master' into llvm8Andrew Kelley
2019-03-12avoid a string that is too long for msvcAndrew Kelley
2019-03-12ability to build musl from sourceAndrew Kelley
bundles musl 1.1.21 See #514
2019-03-12building musl start files from sourceAndrew Kelley
2019-03-10Add elf riscv32 and elf riscv64 as options in getLDMOption during ↵Matt Whiteside
construction of link job.
2019-03-10Merge remote-tracking branch 'origin/master' into llvm8Andrew Kelley
2019-03-09Merge pull request #2038 from ziglang/cachingAndrew Kelley
breaking changes to zig build API and improved caching
2019-03-08breaking changes to zig build API and improved cachingAndrew Kelley
* in Zig build scripts, getOutputPath() is no longer a valid function to call, unless setOutputDir() was used, or within a custom make() function. Instead there is more convenient API to use which takes advantage of the caching system. Search this commit diff for `exe.run()` for an example. * Zig build by default enables caching. All build artifacts will go into zig-cache. If you want to access build artifacts in a convenient location, it is recommended to add an `install` step. Otherwise you can use the `run()` API mentioned above to execute programs directly from their location in the cache. Closes #330. `addSystemCommand` is available for programs not built with Zig build. * Please note that Zig does no cache evicting yet. You may have to manually delete zig-cache directories periodically to keep disk usage down. It's planned for this to be a simple Least Recently Used eviction system eventually. * `--output`, `--output-lib`, and `--output-h` are removed. Instead, use `--output-dir` which defaults to the current working directory. Or take advantage of `--cache on`, which will print the main output path to stdout, and the other artifacts will be in the same directory with predictable file names. `--disable-gen-h` is available when one wants to prevent .h file generation. * `@cImport` is always independently cached now. Closes #2015. It always writes the generated Zig code to disk which makes debug info and compile errors better. No more "TODO: remember C source location to display here" * Fix .d file parsing. (Fixes the MacOS CI failure) * Zig no longer creates "temporary files" other than inside a zig-cache directory. This breaks the CLI API that Godbolt uses. The suggested new invocation can be found in this commit diff, in the changes to `test/cli.zig`.
2019-03-08Remove glibc compat shim with restrictive licenseJay Weisskopf
Unlike the other glibc source code checked into the repo, `csu/init.c` did not have a license clause that allowed linking without restrictions. `_IO_stdin_used` is the only symbol in the file and appears to be a 20 year old compatibility shim for the glibc 2.0 ABI. Obsolete in 2.1.
2019-03-07fix passing invalid argument -NDEBUGAndrew Kelley
2019-03-07fix linking glibc: caching static libs andAndrew Kelley
handle linking pthread, rt, dl, m better
2019-03-07fix regressions on macosAndrew Kelley
2019-03-07multi-arch glibc headersAndrew Kelley