Commit Graph

16148 Commits

Author SHA1 Message Date
Lee Cannon
885c73f343
allocgate: actually free memory in gpa 2021-12-01 09:44:19 +00:00
Andrew Kelley
8f9d857932 Sema: fix error set merging creating references to invalid memory
Trying to use std.heap.page_allocator with stage2 now results in
(incorrect) compile errors rather than UAF.
2021-11-30 23:56:57 -07:00
Andrew Kelley
7355a20133
Merge pull request #10055 from leecannon/allocator_refactor
Allocgate
2021-11-30 18:48:31 -08:00
Andrew Kelley
dd62a6d2e8 AstGen: allow non-string-literal inline assembly for stage1
The end-game for inline assembly is that the syntax is more integrated
with zig, and it will not allow string concatenation for the assembler
code, for the same reasons that Zig does not have a preprocessor.

However, inline assembly in zig right now is lacking for a variety of
use cases (take a look at the open issues having to do with inline
assembly for example), and being able to use comptime expressions to
concatenate text is a workaround that real-world users are exploiting to
get by in the short term.

This commit keeps "assembly code must use string literal syntax" as a
compile error when using stage2, but allows it through when using
stage1.

I expect to revert this commit after making enough improvements to
inline assembly that our real world users' needs are satisfied.
2021-11-30 19:45:08 -07:00
Jan Philipp Hafer
f2608df0fb compiler_rt: add __ctzsi2, __ctzdi2 and __ctzti2
- structure derived from count0bits.zig
- test cases derived from clzsi2_test.zig and
  cross-checked via short helper program

See #1290
2021-11-30 18:31:16 -08:00
Andrew Kelley
40f5e5dfc6 CLI: introduce -fsingle-threaded/-fno-single-threaded
Previously there was only `--single-threaded`.

This flag now matches other boolean flags, instead of only being able to
opt in to single-threaded builds, you can now force multi-threaded
builds. Currently this only has the possibility to emit an error
message, but it is a better user experience to understand why one cannot
choose to enable threads in some cases.

This is breaking change to the CLI.

Related: #10143
2021-11-30 19:21:29 -07:00
Jeremy Fillingim
89afd4bd33 libstd: handle rmdirZ INVAL error (#10145)
The INVAL error was marked unreachable which prevents handling
of the error at a higher level.

It seems like it should map to BadPathError based on the man page for
rmdir (and an incomplete understanding of DeleteDirError), which says:

```
EINVAL pathname has .  as last component.
```
2021-11-30 17:38:21 -08:00
Lee Cannon
066eaa5e9c
allocgate: change resize to return optional instead of error 2021-11-30 23:45:01 +00:00
Lee Cannon
f68cda738a
allocgate: split free out from resize 2021-11-30 23:32:48 +00:00
Lee Cannon
23866b1f81
allocgate: update code to use new interface 2021-11-30 23:32:48 +00:00
Lee Cannon
02e5e0ba1f
allocgate: apply missed changes 2021-11-30 23:32:48 +00:00
Lee Cannon
9377f32c08
allocgate: utilize a *const vtable field 2021-11-30 23:32:48 +00:00
Lee Cannon
80bbf234e0
allocgate: fix failing tests 2021-11-30 23:32:48 +00:00
Lee Cannon
1093b09a98
allocgate: renamed getAllocator function to allocator 2021-11-30 23:32:47 +00:00
Lee Cannon
75548b50ff
allocgate: stage 1 and 2 building 2021-11-30 23:32:47 +00:00
Lee Cannon
47bc13bc59
allocgate: dont use a dummy temporary for stateless allocators 2021-11-30 23:32:47 +00:00
Lee Cannon
85de022c56
allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
Andrew Kelley
1e0addcf73 put the passing stage2 behavior tests back
This mostly reverts commit 692c254336.

The test "for loop over pointers to struct, getting field from struct
pointer" is still failing on the CI so that one is not moved over.
2021-11-30 16:15:42 -07:00
Andrew Kelley
04286e8c3b github issues: add a honeypot template for questions 2021-11-30 14:42:58 -07:00
Andrew Kelley
8635275202 remove linux header files that have case conflicts
similar commit from the past:
c73cd05468

This also modifies tools/update-linux-headers.zig to remove these same
files for next time to prevent a regression.

closes #10249
2021-11-30 14:29:11 -07:00
Andrew Kelley
51df63a44e
Merge pull request #10251 from ziglang/fix-10225
macos: fix stack traces for Zig linked with any linker including Apple's ld64
2021-11-30 12:52:00 -08:00
Jakub Konka
28623544ce macos: remove >= 0x10000000 assertion when printing stack traces
I don't think we can guarantee that especially for system dyld
dylibs which can be loaded at any address (perhaps even some
OS preferential low memory address).

Incidentally, this fixes stack trace tests on x86_64 macOS 12.
2021-11-30 16:48:49 +01:00
Jakub Konka
a56749b654 macos: rewrite logic for generating stack traces on macOS
In order to be linker-independent, when parsing debug info in each
linked OSO, we also create a quick lookup table for symbols defined
within the OSO. We then use this lookup to map symbol from the EXE
to its defined address within the original OSO which we can then
use to extract its associated DWARF info (if any).
2021-11-30 16:13:01 +01:00
Jakub Konka
86fe47235e macho: move nlist_64 type/flags helpers to std.macho 2021-11-30 13:59:33 +01:00
Jakub Konka
2873e19366 macho: ignore undefined symbols marked for discarding
If a symbol is undefined after we tried resolving it in static and
dynamic libraries, and it is annotated with N_DESC_DISCARDED flag,
we simply ignore it rather than flagging an undefined symbol error.
2021-11-30 10:22:26 +01:00
Andrew Kelley
692c254336 Revert "I found some more passing behavior tests"
This reverts commit 0a9b4d092f.

Hm, these are all passing for me locally. I'll have to do some
troubleshooting to figure out which one(s) are failing on the CI.
2021-11-30 00:19:37 -07:00
Andrew Kelley
902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07:00
Andrew Kelley
173d56213b improve behavior test coverage for overflow arithmetic 2021-11-29 23:21:07 -07:00
Andrew Kelley
0a9b4d092f I found some more passing behavior tests 2021-11-29 22:36:52 -07:00
Andrew Kelley
20e19e75fd add clang_argv to stage1 cache hash
closes #9304
2021-11-29 20:57:50 -07:00
Andrew Kelley
19eaf54bc9 update libc linux headers to v5.16-rc3
* Add missing Linux headers. Closes #9837
 * Update existing headers to latest Linux.
 * Consolidate headers that are the same for multiple Zig target CPU
   architectures. For example, Linux has only an x86 directory for both
   x86_64 and x86 CPU architectures. Now Zig only ships an x86 directory
   for Linux headers, and will emit the proper corresponding -isystem
   flags.
 * tools/update-linux-headers.zig is now available for upgrading to
   newer Linux headers, and the update process is now documented on the
   wiki.
2021-11-29 18:05:11 -07:00
Andrew Kelley
ec10e63f49 std: add workaround for failing io_uring test
See #10247
2021-11-29 18:04:28 -07:00
Jan Philipp Hafer
1ea650bb75 compiler_rt: add __popcountsi2, __popcountdi2 and __popcountti2
- apply simpler approach than LLVM for __popcountdi2
  taken from The Art of Computer Programming and generalized
- rename popcountdi2.zig to popcount.zig
- test cases derived from popcountdi2_test.zig
- tests: compare naive approach 10_000 times with
  random numbers created from naive seed 42

    See #1290
2021-11-29 12:50:25 -08:00
Andrew Kelley
d3426ce634 AstGen: require binary operations to have reachable operands 2021-11-29 13:21:36 -07:00
Stephen Gutekanst
b613210140
compiler_rt: implement __isPlatformVersionAtLeast (Objective-C @available expressions) for Darwin (#10232) 2021-11-29 14:54:23 -05:00
Jakub Konka
da0ea909bc macho: POINTER_TO_GOT signals a need for a GOT entry
It also signals the need for GOT indirection (unless it can
be optimised away via link-time constant optimisation).
2021-11-29 11:51:27 -08:00
Jakub Konka
7a7df392d1
Merge pull request #10240 from Luukdegram/stage2-wasm-behaviour
Stage2: wasm - Implement 'zig test'
2021-11-29 10:52:04 +01:00
Luuk de Gram
adf059f272
wasm: Update wasm stage2 test backend to use 'main' 2021-11-29 08:05:51 +01:00
Jakub Konka
2ca5a859e9 Force static libncurses in CMakeLists when static zig on macos
Add additional search paths pointing at homebrew prefixes as Apple
doesn't ship a static libncurses for linking - only a stub for dynamic
linking `libncurses.tbd`.
2021-11-28 21:10:33 -08:00
Andrew Kelley
a4aff36fb3
Merge pull request #10239 from ziglang/fix-10207
macho: fix regression in handling SIGNED_X relocs on x86_64
2021-11-28 20:47:58 -08:00
Jakub Konka
0f63f3eeb7
Merge pull request #10223 from g-w1/print-mir
stage2: initial implementation of print_mir
2021-11-28 21:43:54 +01:00
Jakub Konka
58a552aaf9 macho: save all undef symbols even if null 2021-11-28 20:48:54 +01:00
Jakub Konka
7e27ab0947 macho: fix parsing addend for non-extern SIGNED_X reloc
If `r_extern == 0` (the relocation is non-extern, meaning it targets
a specific memory offset within the object's section) and if the
relocation type signifies that the relocation requires correction
for RIP such as SIGNED_1, then we need to subtract the correction,
here 1 for SIGNED_1, from the calculated addend value as it's
implicitly included.
2021-11-28 20:35:00 +01:00
Luuk de Gram
dd49eca342
wasm: Implement 'zig test'
- This implements the required codegen for decl types such as pointers, arrays, structs and more.
- Wasm's start function can now use both a 'u8' and 'void' as return type. This will help us with writing tests
using the stage2 testing backend. (Until all tests of behavioural tests pass).
- Now correctly generates relocations for function pointers.
- Also implements unwrapping error union error, as well as return pointers.
2021-11-28 20:25:33 +01:00
Luuk de Gram
7226ad2670
wasm-link: Implement indirect function table
The function table contains all function pointers that are called
by using call_indirect. During codegen, we create a relocation
where the linker will resolve the correct index into the table and stores
this value within the data section at the location of the pointer.
2021-11-28 12:49:04 +01:00
Luuk de Gram
9b5d61430f
wasm: Implement slices 2021-11-27 21:34:51 +01:00
Luuk de Gram
90d8544d40
wasm: Add temporary stage2 entrypoint for wasm 2021-11-27 21:34:48 +01:00
Andrew Kelley
aa61e03f24
Merge pull request #10229 from Luukdegram/wasm-linker
stage2: Upstream zwld (partly) into wasm backend
2021-11-27 12:17:32 -08:00
Jakub Konka
c46a91da13 Add missing macOS libc headers
* mach/thread_state.h
* mach/vm_param.h
* objc/objc-runtime.h
2021-11-27 12:12:01 -08:00
Jacob G-W
dde5f15b49 interleave Air instructions and tags in printing Mir instructions 2021-11-27 10:56:29 -05:00