Commit Graph

6150 Commits

Author SHA1 Message Date
Andrew Kelley
187a6d198f
Merge branch 'nrdmn-uefi'
closes #2944
2019-09-13 14:11:00 -04:00
LemonBoy
eb7d36ae0d Make single-element enum default to u0
* Allow comptime_int as explicit enum tag type

Closes #2997
2019-09-13 15:13:10 -04:00
stratact
742abc71c7 Add missing C dl_iterate_phdr function for FreeBSD 2019-09-13 15:10:35 -04:00
Andrew Kelley
c15e464320
Merge branch 'uefi' of https://github.com/nrdmn/zig into nrdmn-uefi 2019-09-13 14:10:42 -04:00
LemonBoy
774f770056 Correct AT_FDCWD definition 2019-09-12 13:15:50 -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
68b49f74c4
consolidate std.debug.parseDie and std.debug.parseDie1 2019-09-12 01:40:55 -04:00
LemonBoy
f36b8fd7b2 Recognize & skip the UTF-8 BOM 2019-09-11 15:20:18 -04:00
Andrew Kelley
0eddee449d
add behavior test for @enumToInt(enum(u1){x}.x)
closes #2737
2019-09-11 15:05:00 -04:00
Andrew Kelley
67491a4222
disable runtime safety in std.io.InStream
Let's not be writing 0xaa in safe modes for upwards of 4 MiB for every
stream read. This is equivalent to the fact that we don't memset the
entire call stack to 0xaa for every function call.
2019-09-11 15:01:54 -04:00
Andrew Kelley
c9b2210fcf
async function calls re-use frame buffers
See #3069
2019-09-10 22:59:00 -04:00
Andrew Kelley
92a427437c
Merge remote-tracking branch 'origin/master' into llvm9 2019-09-10 16:53:11 -04:00
Andrew Kelley
7101e583d6
update glibc src files to 2.30 2019-09-10 16:40:54 -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
Michael Dusan
68d159ea9d fix build on macOS + xcode + clang 2019-09-10 14:38:39 -04:00
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
LemonBoy
8b5cb8df99 Don't forget to resolve the pointee type
Fixes #3128
2019-09-10 19:07:04 +02: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