aboutsummaryrefslogtreecommitdiff
path: root/src/link.cpp
AgeCommit message (Collapse)Author
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
2019-03-06cross compile glibc startup filesAndrew Kelley
2019-03-06support other architectures for glibc startup filesAndrew Kelley
2019-03-05build libunwind.a from source and link itAndrew Kelley
2019-03-05support glibc dl, m, pthread, rtAndrew Kelley
2019-03-05dynamic linker path is independent from libc installationAndrew Kelley
2019-03-05stop linking against gcc filesAndrew Kelley
2019-03-05support crtbegin.o and crtend.o when using explicit libcAndrew Kelley
2019-03-05building glibc from sourceAndrew Kelley
2019-03-04initial glibc supportAndrew Kelley
2019-03-02rename std lib files to new conventionAndrew Kelley
2019-03-02compile error for import outside package pathAndrew Kelley
closes #2024 there's a new cli option `--main-pkg-path` which you can use to choose a different root package directory besides the one inferred from the root source file and a corresponding build.zig API: foo.setMainPkgPath(path)