Commit Graph

6020 Commits

Author SHA1 Message Date
Andrew Kelley
3cd035ba3b
update C header files to clang 9.0.0rc4 2019-09-10 13:30:43 -04:00
Andrew Kelley
e92d74958c
lld: apply patch: [mach-o] Extend LC_DATA_IN_CODE support to x86_64
This applies 91864f82c7d7bd1a151fdfd076a3a67a2893b868 from LLVM trunk to
the embedded LLD.

Once Zig upgrades to LLD 10, there will be no difference between Zig's
fork and upstream, and Zig's fork can be dropped.
2019-09-10 13:25:20 -04:00
Andrew Kelley
016a59e3a1
update embedded LLD to 9.0.0rc4 2019-09-10 13:10:12 -04:00
Andrew Kelley
185cb13278
Merge remote-tracking branch 'origin/master' into llvm9 2019-09-10 13:00:35 -04:00
LemonBoy
ba4d83af3e Resolve lazy arguments passed to @compileLog
Closes #3193
2019-09-10 11:22:40 -04:00
LemonBoy
e2c68fce89 Accept void argument for @cDefine value
Closes #2612
2019-09-10 11:16:50 -04:00
Andrew Kelley
e657b73f30
Merge branch 'async-std-lib'
This introduces the concept of "IO mode" which is configurable by the
root source file (e.g. next to `pub fn main`). Applications can put this
in their root source file:

```
pub const io_mode = .evented;
```

This will populate `std.io.mode` to be `std.io.Mode.evented`. When I/O
mode is evented, `std.os.read` handles EAGAIN by suspending until the
file descriptor becomes available for reading. Although the std lib
event loop supports epoll, kqueue, and Windows I/O Completion Ports,
this integration with `std.os.read` currently only works on Linux.

This integration is currently only hooked up to `std.os.read`, and not,
for example, `std.os.write`, child processes, and timers. The fact that
we can do this and still have a working master branch is thanks to Zig's
lazy analysis, comptime, and inferred async. We can continue to make
incremental progress on async std lib features, enabling more and more
test cases and coverage.

In addition to `std.io.mode` there is `std.io.is_async` which is equal
to `std.io.mode == .evented`. In case I/O mode is async, `std.io.InStream`
notices this and the read function pointer becomes an async function
pointer rather than a blocking function pointer. Even in this case,
`std.io.InStream` can *still be used as a blocking input stream*.
Users of the API control whether it is blocking or async at runtime by whether
or not the read function suspends. In case of file descriptors, for
example, this might correspond to whether it was opened with `O_NONBLOCK`.
The `noasync` keyword makes a function call or `await` assert that no
suspension happens. This assertion has runtime safety enabled.

`std.io.InStream`, in the case of async I/O, uses by default a 4 MiB
frame size for calling the read function. If this is too large or too
small, the application can globally increase the frame size used by
declaring `pub const stack_size_std_io_InStream = 1234;` in their root
source file. This way, `std.io.InStream` will only be generated once,
avoiding bloat, and as long as this number is configured to be high
enough, everything works fine. Zig has runtime safety to detect when
`@asyncCall` is given too small of a buffer for the frame size.

This merge introduces -fstack-report which can help identify large async
function frame sizes and explain what is making them so big. Until #3069 is
solved, it's recommended to stick with blocking IO mode.

-fstack-report outputs JSON format, which can then be viewed in a GUI
that represents the tree structure. As an example, Firefox does a decent
job of this.

One feature that is currently missing is detecting that the call stack
upper bound is greater than the default for a given target, and passing
this upper bound to the linker. As an example, if Zig detects that 20
MiB stack upper bound is needed - which would be quite reasonable -
currently on Linux the application would only be given the default of 16
MiB.

Unrelated miscellaneous change: added std.c.readv
2019-09-10 10:39:27 -04:00
Andrew Kelley
ff051f8f5d
-fstack-report outputs JSON
See #3069
2019-09-10 10:26:54 -04:00
Andrew Kelley
0489d06c24
make the std lib support event-based I/O
also add -fstack-report
2019-09-10 10:26:52 -04:00
daurnimator
a29ce78651 std: add BloomFilter data structure 2019-09-10 10:20:30 -04:00
LemonBoy
8fbae77770
Force LLVM to generate byte-aligned packed unions
Sometimes the frontend and LLVM would disagree on the ABI alignment of a
packed union. Solve the problem by telling LLVM we're gonna manage the
struct layout by ourselves.

Closes #3184
2019-09-10 10:07:32 -04:00
Sahnvour
a06f84fcc6 forbid opaque types in function return types 2019-09-10 10:11:49 -04:00
Michael Dusan
8bd5681651 fix tests.addPkgTests to always run native target
- include native-target when native-target ∉ cross_targets

old behavior:

- do nothing when `-Dskip-non-native`
- never execute pkg tests for non-members of cross_targets
2019-09-10 10:10:14 -04:00
Andrew Kelley
852679c369
fix a var decl in scope preventing for loop spills 2019-09-09 16:44:23 -04:00
Andrew Kelley
a3993465fe
Merge pull request #3200 from LemonBoy/eq-tagged-union
Allow comparison between union tag and enum literal
2019-09-09 16:17:45 -04:00
LemonBoy
fec795cd29 Adjust the stdlib to be 32bit compatible 2019-09-09 16:16:13 -04:00
Andrew Kelley
f50bfb94b5
fix bad LLVM IR when for target expr needs to be spilled
Also reduce the size of ZigVar in memory by making the name
a `const char *` rather than a `Buf`.
2019-09-09 15:59:16 -04:00
LemonBoy
e4c3067617 Fix typo in TLS initialization code 2019-09-09 13:54:31 -04:00
LemonBoy
4b1cd45472 Comptime folding of enum/union comparisons 2019-09-09 19:09:56 +02:00
LemonBoy
cc63760587 Allow comparison between union tag and enum literal
Closes #2810
2019-09-09 18:51:13 +02:00
Andrew Kelley
f7721ac37c
implement spilling when returning error union async function call
closes #3190
2019-09-09 12:15:39 -04:00
Andrew Kelley
2482bdf22b
release builds of stage1 have llvm ir verification
the stage2 zig code however gets compiled in release mode,
and stripped.
2019-09-09 09:33:33 -04:00
Sahnvour
19cf9bd062 use /debug:fastlink when building with msvc and debug info 2019-09-09 00:26:39 -04:00
Michael Dusan
0d9a78a852 test-stack-traces: add FreeBSD 2019-09-09 00:25:21 -04:00
Andrew Kelley
071ca00574
Merge branch 'gustavolsson-clang-frameworks-dir' 2019-09-08 15:09:51 -04:00
Andrew Kelley
5dde3cd3bd
move logic for propagating framework dirs to zig cc 2019-09-08 15:09:05 -04:00
Gustav Olsson
ec13fa3f4a forward framework dirs to embedded clang in addition to linker on osx 2019-09-08 14:46:25 +02:00
Andrew Kelley
229323e13a
fix suspensions inside for loops generating invalid LLVM IR
closes #3076
2019-09-07 17:37:17 -04:00
Andrew Kelley
d3cf040c90
Merge branch 'glibc-2.30'
closes #3098
2019-09-07 15:08:47 -04:00
Andrew Kelley
b21ad07767
update glibc ABI lists to 2.30 2019-09-07 15:04:09 -04:00
Andrew Kelley
45ab9d5fd6
update glibc headers to 2.30 2019-09-07 14:59:38 -04:00
Andrew Kelley
99fd42404a
update process_headers tool for glibc 2.30 2019-09-07 14:46:59 -04:00
Andrew Kelley
9a18db8a80
properly spill expressions with async function calls 2019-09-07 00:27:45 -04:00
Andrew Kelley
d1a98ccff4
implement spills when expressions used across suspend points
closes #3077
2019-09-07 00:13:12 -04:00
Andrew Kelley
9ca8d9e21a
fix await used in an expression generating bad LLVM 2019-09-07 00:13:12 -04:00
emekoi
9423d382fb fixed compiler error for gcc 9.2.0 2019-09-06 19:20:25 -04:00
Andrew Kelley
7d303ae861
runtime safety for noasync function calls
See #3157
2019-09-06 13:08:44 -04:00
Andrew Kelley
0a3c6dbda9
implement noasync function calls
See #3157
2019-09-05 21:55:32 -04:00
Timon Kruiper
ca70ca7e26 Add compiler error when negating invalid type 2019-09-05 15:27:50 -04:00
Andrew Kelley
4a5bc89862
add -l as an alias for --library 2019-09-05 15:17:23 -04:00
Andrew Kelley
b564e7ca59
os: raise maximum file descriptor limit
Do a binary search for the maximum RLIMIT_NOFILE.

Patch lifted from node.js commit
6820054d2d42ff9274ea0755bea59cfc4f26f353
2019-09-05 15:09:13 -04:00
Andrew Kelley
2045b4d932
prefer result type casting to peer type resolution
See #2749
2019-09-05 14:56:52 -04:00
Andrew Kelley
8f0df86937
I'm pretty sure sp is the stack pointer on all ARM 2019-09-05 14:15:39 -04:00
Timon Kruiper
866c253e0e
Add compile error when shifting amount is not an int type 2019-09-05 13:10:39 -04:00
LemonBoy
8e3c56b912
Always resolve the struct field types
Packed structs used to skip the zero-sized types and trip some
assertions that expected the type reference not to be null.

Fixes #3143
2019-09-05 13:07:04 -04:00
LemonBoy
0107b19124 Resolve lazy values when checking for definedness
Fixes #3154
2019-09-05 13:09:43 -04:00
Jonathan Marler
9a358d2d33 Add Array support to @Type 2019-09-05 13:08:45 -04:00
Vesa Kaihlavirta
847a262efd Shorten @field documentation and add an example 2019-09-05 13:07:04 -04:00
Michael Dusan
fe153ad2a4 stage1 enhance IR print
- print fn name in pass1
- replace scalar with enum IrPass for clarity
2019-09-05 13:06:10 -04:00
LemonBoy
fabf45f5fc Add the noinline keyword for function declarations 2019-09-05 13:04:58 -04:00