Commit Graph

223 Commits

Author SHA1 Message Date
LemonBoy 2b624fea84 Add dlltool functionality
Don't need no patched lld --kill-at behaviour now.
2019-10-12 10:56:16 +02:00
LemonBoy 8aa20227ed Fix cross-compilation to i386-windows-msvc
Use Mingw's .def files to build a .lib when possible and show an error
otherwise.
2019-10-11 15:52:55 -04:00
LemonBoy 86e5bbffd7 Patch lld to have a more sensible kill-at implementation
Lift some code from llvm-dlltool, the lld code is meant to follow what
gnu ld does but that's not much useful for our purposes.

Also use the `--kill-at` option when generating the .lib files out of
mingw's .def files: this way our building process closely matches the
one use by the upstream and now finally generates files that allow both
C code and Zig code to link.
2019-10-10 09:38:57 +02:00
LemonBoy b96fa89462 Compile the architecture-specific mingw sources 2019-10-09 22:44:36 +02:00
Andrew Kelley 543e729398 Merge pull request #3331 from meme/android-ndk
Support Android NDK
2019-09-28 13:30:19 -04:00
meme 030abfa0d2 minor tweaks 2019-09-28 13:21:29 -04:00
meme 0c556095f4 do not link against gcc runtime on Android target 2019-09-28 12:48:13 -04:00
Andrew Kelley ce0e794092 fix glibc builds on aarch64-linux-gnu
There was a missing include path in the compilation line, leading to
incorrect fstat ABI.

closes #3291
2019-09-27 18:19:21 -04:00
meme 308e7d5314 fix building static Android executables 2019-09-27 17:33:07 -04:00
meme f7bf61a983 support Android NDK and bionic 2019-09-27 16:51:42 -04:00
LemonBoy c8e4108c5b Export _start as __start for MIPS targets 2019-09-26 17:13:57 +02:00
LemonBoy 4ebcf64864 Initial support for mipsel architecture¬ 2019-09-26 09:31:55 +02:00
Andrew Kelley c9690916e5 fix building musl on eabihf abis, incorrect include dirs
See #3286. The issue is not fully solved however because this has
uncovered another issue.
2019-09-25 14:03:26 -04:00
Andrew Kelley d6f7b573aa silence nonportable include path warnings when building glibc on windows 2019-09-22 18:15:30 -04:00
Andrew Kelley c4416b224d Merge remote-tracking branch 'origin/master' into llvm9 2019-09-15 20:59:53 -04:00
Andrew Kelley cf4bccf765 improvements targeted at improving async functions
* 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-12 01:40:58 -04:00
Andrew Kelley 92a427437c Merge remote-tracking branch 'origin/master' into llvm9 2019-09-10 16:53:11 -04:00
stratact a165cc0535 Get more of the tests passing for FreeBSD (#3197)
* 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-10 14:50:54 -04:00
Andrew Kelley 058050f22c Merge remote-tracking branch 'origin/master' into llvm9 2019-09-02 20:56:31 -04:00
Andrew Kelley 0fe28855c5 add ability to specify darwin framework search dirs 2019-09-02 11:48:06 -04:00
Andrew Kelley 5f3d59f0ac Merge branch 'master' into llvm9 2019-08-20 19:09:52 -04:00
Andrew Kelley 3f7f520036 don't put libc on the elf linker line for objects
closes #3093
2019-08-19 12:33:36 -04:00
Andrew Kelley d4ca337e6b improvements to riscv support 2019-07-18 12:21:57 -04:00
Andrew Kelley e816d592e8 update zig codebase to llvm 9 2019-07-17 17:47:39 -04:00
Andrew Kelley c0b4121ff2 libc headers before C language headers, and disable libunwind on arm32 2019-07-16 21:38:18 -04:00
Andrew Kelley d994379173 update bundled musl source to 1.1.23 2019-07-16 19:54:14 -04:00
Andrew Kelley 15ed47921f Merge branch 'msvc-libc-2064' of https://github.com/dimenus/zig into dimenus-msvc-libc-2064 2019-07-16 12:51:02 -04:00
Andrew Kelley 851a7288a9 mingw libc can link against ntdll 2019-07-15 18:25:13 -04:00
Andrew Kelley 39b850c6cf mingw libc: delete dead linker code regarding using system libc 2019-07-12 18:10:53 -04:00
Andrew Kelley 3621d54e57 handle mingw libc defs better
also zig build handles --verbose and linkSystemLibrary better
2019-07-12 17:25:25 -04:00
Andrew Kelley 7b8ba871a9 mingw libc: solve the segfault having to do with destructors
* 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-12 14:44:34 -04:00
Andrew Kelley e0670557b4 fix windows not able to build mingw 2019-07-10 20:20:53 -04:00
Andrew Kelley 3714d524c3 add some more windows defs 2019-07-10 19:40:46 -04:00
Andrew Kelley 2bb93784c6 mingw: build and link mingwex.lib
zig can now cross compile hello.c targeting windows
2019-07-10 17:41:34 -04:00
dimenus 540a40e2d9 fixing non system library linking 2019-07-10 15:37:25 -05:00
Andrew Kelley 67f3bc9101 mingw: building and linking msvcrt-os.lib 2019-07-10 16:19:51 -04:00
Andrew Kelley ea90a3a9a1 mingw: building and linking mingw32.lib 2019-07-10 14:13:00 -04:00
dimenus e9331dc5cf resolved #2064 & fixed hello_world libc build 2019-07-10 11:40:20 -05:00
Andrew Kelley 1c7f21852f ship with mingw-w64 v6.0.0
See #514
2019-07-09 23:34:16 -04:00
Andrew Kelley 7ccf7807b3 ability to target any glibc version 2019-07-07 17:56:08 -04:00
Timon Kruiper 7586f613d5 Added function-section functionality 2019-07-01 17:49:08 +02:00
Jonathan Marler 21dff1c4e2 Remove duplicate exe name with zig run 2019-06-17 14:10:10 -04:00
Andrew Kelley 5784631fab update the default macos version min to 10.14 2019-06-07 12:20:02 -04:00
LemonBoy 291aaee977 Stop the musl builder from skipping necessary files
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-06-04 12:45:02 -04:00
Andrew Kelley 1ab0ac3ea2 cleanups for windows subsystem in builtin.zig 2019-05-29 16:55:02 -04:00
Andrew Kelley 2c0280ba08 improve the stack check CLI options
See #2526
2019-05-27 20:59:19 -04:00
LemonBoy 266b2de150 Remove macos-specific linking hacks 2019-05-20 23:09:25 +02:00
Andrew Kelley 81e960eb74 improvements to build-lib use case of WebAssembly
* 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-16 13:56:56 -04:00
Andrew Kelley 6b36b756eb fix static builds of zig from requiring c compiler
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-15 21:50:56 -04:00
Andrew Kelley 14cdb01f35 improvements to zig's implementation of libc and WebAssembly
* 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-15 20:14:58 -04:00