aboutsummaryrefslogtreecommitdiff
path: root/src/link.cpp
AgeCommit message (Collapse)Author
2019-09-26Export _start as __start for MIPS targetsLemonBoy
2019-09-26Initial support for mipsel architecture¬LemonBoy
2019-09-25fix building musl on eabihf abis, incorrect include dirsAndrew Kelley
See #3286. The issue is not fully solved however because this has uncovered another issue.
2019-09-22silence nonportable include path warnings when building glibc on windowsAndrew Kelley
2019-09-15Merge remote-tracking branch 'origin/master' into llvm9Andrew Kelley
2019-09-12improvements targeted at improving async functionsAndrew Kelley
* Reuse bytes of async function frames when non-async functions make `noasync` calls. This prevents explosive stack growth. * Zig now passes a stack size argument to the linker when linking ELF binaries. Linux ignores this value, but it is available as a program header called GNU_STACK. I prototyped some code that memory maps extra space to the stack using this program header, but there was still a problem when accessing stack memory very far down. Stack probing is needed or not working or something. I also prototyped using `@newStackCall` to call main and that does work around the issue but it also brings its own issues. That code is commented out for now in std/special/start.zig. I'm on a plane with no Internet, but I plan to consult with the musl community for advice when I get a chance. * Added `noasync` to a bunch of function calls in std.debug. It's very messy but it's a workaround that makes stack traces functional with evented I/O enabled. Eventually these will be cleaned up as the root bugs are found and fixed. Programs built in blocking mode are unaffected. * Lowered the default stack size of std.io.InStream (for the async version) to 1 MiB instead of 4. Until we figure out how to get choosing a stack size working (see 2nd bullet point above), 4 MiB tends to cause segfaults due to stack size running out, or usage of stack memory too far apart, or something like that. * Default thread stack size is bumped from 8 MiB to 16 to match the size we give for the main thread. It's planned to eventually remove this hard coded value and have Zig able to determine this value during semantic analysis, with call graph analysis and function pointer annotations and extern function annotations.
2019-09-10Merge remote-tracking branch 'origin/master' into llvm9Andrew Kelley
2019-09-10Get more of the tests passing for FreeBSD (#3197)stratact
* Add missing <stdint.h> include for uint8_t type declaration * Add needed FreeBSD check to link to libpthread * Apply patch to enable more tests in the FreeBSD CI
2019-09-02Merge remote-tracking branch 'origin/master' into llvm9Andrew Kelley
2019-09-02add ability to specify darwin framework search dirsAndrew Kelley
2019-08-20Merge branch 'master' into llvm9Andrew Kelley
2019-08-19don't put libc on the elf linker line for objectsAndrew Kelley
closes #3093
2019-07-18improvements to riscv supportAndrew Kelley
2019-07-17update zig codebase to llvm 9Andrew Kelley
2019-07-16libc headers before C language headers, and disable libunwind on arm32Andrew Kelley
2019-07-16update bundled musl source to 1.1.23Andrew Kelley
2019-07-16Merge branch 'msvc-libc-2064' of https://github.com/dimenus/zig into ↵Andrew Kelley
dimenus-msvc-libc-2064
2019-07-15mingw libc can link against ntdllAndrew Kelley
2019-07-12mingw libc: delete dead linker code regarding using system libcAndrew Kelley
2019-07-12handle mingw libc defs betterAndrew Kelley
also zig build handles --verbose and linkSystemLibrary better
2019-07-12mingw libc: solve the segfault having to do with destructorsAndrew Kelley
* fixed --verbose-cc printing an extra "zig" before the rest of the command line * windows-gnu targets use libfoo.a, foo.o extensions to match mingw conventions.
2019-07-10fix windows not able to build mingwAndrew Kelley
2019-07-10add some more windows defsAndrew Kelley
2019-07-10mingw: build and link mingwex.libAndrew Kelley
zig can now cross compile hello.c targeting windows
2019-07-10fixing non system library linkingdimenus
2019-07-10mingw: building and linking msvcrt-os.libAndrew Kelley
2019-07-10mingw: building and linking mingw32.libAndrew Kelley
2019-07-10resolved #2064 & fixed hello_world libc builddimenus
2019-07-09ship with mingw-w64 v6.0.0Andrew Kelley
See #514
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