14496 Commits

Author SHA1 Message Date
Andrew Kelley
acf2e8fe64 fix start code for WebAssembly 2021-06-30 18:39:04 -07:00
Takeshi Yoneda
d606811f55 Fix test cases for stage2.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-30 20:35:17 -04:00
Takeshi Yoneda
bc7761d8e0
Add support for WASI reactor in pure Zig-exe. (#9178)
* Add command line help for "-mexec-model"
* Define WasmExecModel enum in std.builtin.
* Drop the support for the old crt1.o in favor of crt1-command.o

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-30 20:02:48 -04:00
Jakub Konka
a95ba0d10d
Merge pull request #9254 from moosichu/feature/macos-link-universal-static-libs
Add fat/universal archive support to zig ld
2021-06-30 10:22:49 +02:00
Nameless
908b431abe std/os/uefi: fix packed struct bitfields 2021-06-30 09:28:08 +03:00
Sreehari Sreedev
b8329351b1 boot_services: allow custom MemoryTypes 2021-06-30 09:26:09 +03:00
Jakub Konka
81bf05bf6c
Merge pull request #9266 from ziglang/zld-dylibs
zig ld can create dylibs now; remove system linker hack and any mention of ld64.lld from the codebase
2021-06-30 00:03:55 +02:00
Jakub Konka
0e15205521 Remove mention of lldMachO from the project
including:
* finding lldMachO in CMake config
* punting `ld64.lld` to LLD linker
* providing bindings to LLD linker
2021-06-29 23:38:19 +02:00
Andrew Kelley
37fbf5b0d3
Merge pull request #9258 from ziglang/shared-cache-locking
Shared Cache Locking
2021-06-29 17:29:59 -04:00
Andrew Kelley
e32530b6a3 std.fs.File: update doc comments regarding locking
Update to accomodate the differences in Windows, which is now advisory
file locking, and include details about which operating systems have
atomic locking flags.
2021-06-29 14:25:04 -07:00
Andrew Kelley
06129d7e3d std: implement a cross platform file locking abstraction
This modifies the lock semantics from using AccessMode to using
NtLockFile/NtUnlockFile.

This is a breaking change.
2021-06-29 14:25:04 -07:00
Andrew Kelley
488f68069b implement std.fs.File.setLock for Windows 2021-06-29 14:25:04 -07:00
Andrew Kelley
3d7ae63c6f stage2: remove c_object_cache_digest_set
This logic was a workaround to prevent cache deadlocks which happened
from always using exclusive file locks. Now that the Cache system
supports sharing cached artifacts, this workaround is no longer needed.

Closes #7596
2021-06-29 14:25:04 -07:00
Andrew Kelley
4e61af404e stage2: Cache system handles shared objects
Fixes #9139
Fixes #9187
2021-06-29 14:25:04 -07:00
Andrew Kelley
6ba6b98b72 std add fs.File.setLock
Windows implementation is still missing.
2021-06-29 14:25:04 -07:00
Tom Maenan Read Cutting
186577225f Add fat/universal archive support to zig ld
This is an extension of adding fat dylib support to zig ld, pulling out
the functionality needed to support fat headers & offsets and applying
it to zig archives.

Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
2021-06-29 18:42:57 +01:00
Jakub Konka
8211cef77c zld: we can now create basic dylibs targeting macOS! 2021-06-29 17:46:23 +02:00
Jakub Konka
069fcf1c95 zld: put all global symbols in the export trie
* sort the symbols by name to optimise the export trie first
* insert only symbols with global linkage (private exts or weak should
  not make the cut)
2021-06-29 11:21:44 +02:00
Jakub Konka
75a13a456b zld: remove system linker hack and lld hooks 2021-06-29 07:59:46 +02:00
Jakub Konka
2c385e58f9
Merge pull request #9242 from ziglang/zld-link-system-libsystem-when-native
zld: link against system libSystem when available
2021-06-28 21:06:12 +02:00
Jakub Konka
9b5a463111 zld: if libSystem.dylib found, then need to link libc.dylib too 2021-06-28 17:42:59 +02:00
Jakub Konka
eca12b74b8 zld: recurse dylibs reexports when defined and desired 2021-06-28 15:14:50 +02:00
Jakub Konka
5aff1d5d6f zld: frameworks do not need dylib ext on older macs 2021-06-28 12:17:26 +02:00
Andrew Kelley
6d47b4f39e Revert "Include package root dir in stage2 error messages"
This reverts commit 15a030ef3d2d68992835568f2fb9d5deab18f39f.

ast-check started crashing after this commit. Needs more QA before
merging.
2021-06-27 17:30:29 -07:00
J.C. Moyer
15a030ef3d Include package root dir in stage2 error messages 2021-06-27 14:53:46 +03:00
Isaac Freund
f398ac3ee4 std/fmt: add fmtDurationSigned
When working with durations it often makes sense to use signed integers
and allow negative durations, and there is currently no nice way to
format these in std.fmt. This patch adds a simple wrapper for the
existing fmtDurtion to fit this need.
2021-06-27 12:54:31 +03:00
g-w1
ef56e42a2a
stage2: fix unreachable in union(enum) with anytype payload 2021-06-27 12:26:29 +03:00
Evan Haas
3be682bac9
translate-c: Add documentation for zig translate-c 2021-06-27 12:25:32 +03:00
Jakub Konka
b94787afd7 zld: link against system libSystem.tbd
when native OS _and_ `libSystem.tbd` can be found. Otherwise,
fallback to linking against Zig-provided `lib/libc/darwin/libSystem.B.tbd`.
2021-06-26 10:11:39 +02:00
Emil Lerch
2ac769eab9 allow json scientific notation to coerce to integers as long as they actually resolve to int type 2021-06-26 10:10:36 +03:00
Robin Voetter
dacc5e624e Export isValidId, remove pub on unexported functions 2021-06-26 09:59:40 +03:00
Andrew Kelley
1534cd2f88
Merge pull request #9148 from marler8997/windowsChildOutput
finish ChildProcess collectOutputWindows
2021-06-25 21:42:18 -04:00
Jakub Konka
7a85dc6935
Merge pull request #9202 from ifreund/sysroot
stage2: add --sysroot link option
2021-06-25 22:37:46 +02:00
Andrew Kelley
73f77f3080 AstGen: fix O(N^2) perf for many decls with same parent
AstGen was calling findLineColumn() for every sibling Decl, using the
parent Decl as the starting point for the search for newlines. This
resulted in poor performance for large numbers of Decls with the same
parent.

The solution is simple: since AstGen progresses monotonically through
the AST, keep a single cursor into the source file, and whenever
line/column information is needed, advance the cursor. This guarantees
O(N) on the number of bytes in the file.

Perf:
As an example I ran ast-check on zigwin32/win32/everything.zig
(a 17 MiB file) in master branch, and after this commit.
With master branch, I killed the process after 17 seconds out of
boredom. With this commit, it completed in 300 milliseconds.

Closes #9234
2021-06-25 12:58:21 -07:00
Jakub Konka
49b3986417 zld: fix section mapping for Go specific sections
which include:
* `__TEXT,__rodata` => `__DATA_CONST,__const`
* `__TEXT,__typelink` => `__DATA_CONST,__const`
* `__TEXT,__itablink` => `__DATA_CONST,__const`
* `__TEXT,__gosymtab` => `__DATA_CONST,__const`
* `__TEXT,__gopclntab` => `__DATA_CONST,__const`

Also, we treat section as containing machine code and mapping
it to `__TEXT,__text` if it is `S_REGULAR` and contains either
`S_ATTR_PURE_INSTRUCTIONS` or `S_ATTR_SOME_INSTRUCTIONS` or both.
2021-06-25 20:32:58 +02:00
Isaac Freund
f9171bf542
std/build: add --sysroot general option 2021-06-25 19:13:43 +02:00
Isaac Freund
260c5aed86
stage2: add --sysroot link option
This feature is necessary for cross-compiling code that dynamically
links system libraries, at least with the current feature set of lld.
2021-06-25 19:13:43 +02:00
xackus
411f9c60b1 mark tsan as linguist-vendored 2021-06-25 12:46:23 +03:00
Tom Maenan Read Cutting
177b1b6bf9 Add fat/universal dylib support to zig ld
With this change zig ld can link with dynamic libraries
contained within a fat/universal file that had multiple
seperate binaries embedded within it for multi-arch
support (in macOS).

Whilst zig can still only create single-architecture
executables - the ability to link with fat libraries is
useful for cases where they are the easiest (or only)
option to link against.
2021-06-25 08:38:47 +02:00
Jacob G-W
2d2a6ed1a4 stage2: implement @setRuntimeSafety 2021-06-25 08:57:03 +03:00
Jacob G-W
4adcd560ce langref: make @setRuntimeSafety more correct 2021-06-25 08:57:03 +03:00
Jakub Konka
350ead9cb2
Merge pull request #9229 from ziglang/zld-objc-frameworks
zig ld: link Obj-C, link frameworks, improve linker's implementation
2021-06-25 07:51:21 +02:00
Jakub Konka
ddd2cd7330 zld: fix Dylib.Id parsing logic for string values 2021-06-24 23:34:31 +02:00
Jakub Konka
264f5f4544 Apply AST fixes 2021-06-24 23:08:24 +02:00
Jakub Konka
8fc5b5a087 zld: put DICE and CodeSig load commands last
after `LC_LOAD_DYLIB` commands to match ld64 and make the binaries
compatible with Apple tools.
2021-06-24 22:40:19 +02:00
Jakub Konka
ad0be78577 zld: parse dylib's id from tbd 2021-06-24 22:19:44 +02:00
Jakub Konka
5e0e7b2cb4 zld: exclude libs part of the umbrella
when parsing the umbrella lib
2021-06-24 20:27:23 +02:00
Jakub Konka
8669e3d46b zld: when parsing dylibs, allow multiple return values 2021-06-24 18:57:21 +02:00
Jakub Konka
5ac5cd9de7 zld: naively parse all dylib deps in stubs 2021-06-24 18:57:11 +02:00
Jakub Konka
3cb6b6bd90 zld: merge Stub with Dylib struct
After giving it more thought, it doesn't make sense to separate
the two structurally. Instead, there should be two constructors
for a Dylib struct: one from binary file, and the other from a stub
file. This cleans up a lot of code and opens the way for recursive
parsing of re-exports from a dylib which are a hard requirement for
native feel when linking frameworks.
2021-06-24 18:57:04 +02:00