Commit Graph

15981 Commits

Author SHA1 Message Date
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
Jacob G-W
bd19f5e611 initial implementation of print_mir 2021-11-27 10:56:04 -05:00
Luuk de Gram
6e88df44a2
wasm-linker: Link into binary during flush
This contains a few additions:
- Proper stack pointer calculation keeping alignment in mind.
- Setting up memory layout (including user flags).
- Export or import memory
- Handle 'easy' linker tasks during incremental compilation, while offloading
heavy-tracking/computation tasks to `flush()`
- This architecture allows us to easily integrate with the rest of 'zwld' to
implement linking stage2 code with external object files.
2021-11-27 15:11:03 +01:00
Luuk de Gram
a54ac08885
wasm-linker: Resolve relocations
We now resolve relocations for globals, memory addresses and function indexes.
Besides above, we now also emit imported functions correctly and create a
corresponding undefined symbol for it, where as we create a defined symbol
for all other cases.

TODO: Make incrememental compilation work again with new linker infrastructure
2021-11-27 15:02:05 +01:00
Luuk de Gram
f56ae69edd
wasm-linker: Upstream zwld into stage2
- Converts previous `DeclBlock` into `Atom`'s to also make them compatible when
the rest of zlwd gets upstreamed and we can link with other object files.
- Resolves function signatures and removes any duplicates, saving us a lot of
potential bytes for larger projects.
- We now create symbols for each decl of the respective type
- We can now (but not implemented yet) perform proper relocations.
- Having symbols and segment_info allows us to create an object file
for wasm.
2021-11-27 15:02:01 +01:00
Andrew Kelley
17f057c556 stage2: implement @typeName
* stage1: change the `@typeName` of `@TypeOf(undefined)`,
   `@TypeOf(null)`, and `@TypeOf(.foo)` to match stage2.
 * move passing behavior tests to the passing-for-stage2 section.
2021-11-27 00:27:52 -07:00
Andrew Kelley
f0deef1d79 Sema: fix analyzeBlockBody logic
Previously, when a coercion needed to be inserted into a break
instruction, the `br` AIR instruction would be rewritten so that the
block operand was a sub-block that did the coercion. The problem is that
the sub-block itself was never added to the parent block, resulting in
the `br` instruction operand being a bad reference.

Now, the `br` AIR instruction that needs to have coercion instructions
added is replaced with the sub-block itself with type `noreturn`, and
then the sub-block has the coercion instructions and a new `br`
instruction that breaks from the original block.

LLVM backend needed to be fixed to lower `noreturn` blocks without
emitting an unused LLVM basic block.
2021-11-26 23:17:01 -07:00
Andrew Kelley
d43ebf562d zig build: add each_lib_rpath property
Maps to `-feach-lib-rpath` and `-fno-each-lib-rpath`.

Closes #8800
2021-11-26 21:22:33 -07:00
chwayne
755eeb7be0
zig fmt: Fix performance issue with nested arrays (#10224)
* Remove double recursive call in renderArrayInit
* Preserve an empty line before a comment line

Fixes #10194
2021-11-26 23:02:09 -05:00
Andrew Kelley
fdc04101f3 mingw-w64: add wsock32 def files
closes #7877
2021-11-26 20:57:30 -07:00
Andrew Kelley
4cdf5b6662 mingw-w64: patch to silence implicit-function-declaration warnings
Closes #7356

I did this as a patch to the source rather than passing flags so that
it would intentionally be reverted when we update to the next release of
mingw-w64. At this time if any warnings are still emitted we should find
out why and make sure upstream is aware of the problem.
2021-11-26 20:34:01 -07:00
Andrew Kelley
b097545a5f zig cc: honor all -m and -mno- CPU feature flags
closes #9196
2021-11-26 19:59:33 -07:00
Andrew Kelley
eec825cea2 zig cc: support -Bdynamic and -Bstatic parameters
Related: #10050
2021-11-26 16:26:19 -07:00
Isaac Freund
b196dd1d79 std.system: fix slice bounds in preadMin()
If a partial read occurs past the halfway point, buf.len - i will be
less than i, which is illegal. The end bound is also entirely unecessary
in this case, so just remove it.
2021-11-26 14:35:46 -08:00