18107 Commits

Author SHA1 Message Date
Andrew Kelley
ab658e32bd Sema: fix export with Internal linkage
The Export tables should only be populated with non-internal exports.
2022-04-24 20:24:37 -07:00
jagt
76311aebff std: fix crypto and hash benchmark 2022-04-24 23:01:06 -04:00
protty
963ac60918
std.Thread: Mutex and Condition improvements (#11497)
* Thread: minor cleanups

* Thread: rewrite Mutex

* Thread: introduce Futex.Deadline

* Thread: Condition rewrite + cleanup

* Mutex: optimize lock fast path

* Condition: more docs

* Thread: more mutex + condition docs

* Thread: remove broken Condition test

* Thread: zig fmt

* address review comments + fix Thread.DummyMutex in GPA

* Atomic: disable bitRmw x86 inline asm for stage2

* GPA: typo mutex_init

* Thread: remove noalias on stuff

* Thread: comment typos + clarifications
2022-04-23 19:35:56 -05:00
Morritz
daef82d06f
add GetProcessTimes binding to the kernel32.zig (#11488) 2022-04-23 16:58:27 -05:00
Andrew Kelley
cf20b97b71
Merge pull request #11279 from igor84/s1_packed_struct
stage1: Fix packed structs (#2627, #10104)
2022-04-22 11:39:12 -04:00
Andrew Kelley
06310e3d4e Revert "Fix C include files not being in whole cache (#11365)"
This reverts commit a430630002bf02162ccbf8d3eb10fd73e490cefd.

Wait a minute, I'm sorry, I need to revert this. The whole premise
of this change is broken because the point of the hash is that it tells
whether the same compilation has been done before. This requires items
to be added to the hash in the same sequence every time. This means that
introducing a lock is fundamentally broken because the order needs to be
the same in future runs of the compiler, and not decided by threads
racing against each other.

The proper solution to this is to, in whole cache mode, append the hash
inputs to some data structure, and then after the compilation is
complete, do some kind of sorting on the hash inputs so that they will
be the same order every time, then apply them in sequence. No lock on
the Cache object is needed for this scheme.
2022-04-22 08:19:51 -07:00
Tom Read Cutting
a430630002
Fix C include files not being in whole cache (#11365) 2022-04-22 11:12:51 -04:00
Andrew Kelley
42e81cd81b
Merge pull request #11377 from AnnikaCodes/11368
C backend: Fix array declarations
2022-04-22 10:55:41 -04:00
Andrew Kelley
0e830b1630 clean up behavior tests
Split big test into the two separate things it is testing.
Add missing checks to the test which revealed the test is not actually
passing yet for the C backend.
2022-04-22 07:52:21 -07:00
Annika L
c992b25908 C backend: Fix array declarations 2022-04-22 07:42:47 -07:00
Jakub Konka
5da0e03553
Merge pull request #11480 from rabingaire/fix-child-process-hang-on-macos
Fix child process spawn on macos hangs with stdin, stdout behavior set to pipe
2022-04-22 07:26:51 +02:00
Jakub Konka
5c501e8dad
Merge pull request #11485 from ziglang/fix-4353 2022-04-22 06:34:06 +02:00
Andrew Kelley
9c5fe5b5a4 LLVM: C calling convention lowering fixes
For parameters and return types of functions with the C calling
convention, the LLVM backend now has a special lowering for the function
type that makes the function adhere to the C ABI. The AIR instruction
lowerings for call, ret, and ret_load are adjusted to bitcast the real
type to the ABI type if necessary.

More work on this will need to be done, however, this improvement is
enough that stage3 now passes all the same behavior tests that stage2
passes - notably, translate-c no longer has a segfault due to C ABI
issues with Zig's Clang C API wrapper.
2022-04-21 20:27:06 -07:00
Andrew Kelley
804d0661f5
Merge pull request #11448 from ziglang/ci-stage3
CI: additionally test building stage3
2022-04-21 18:57:59 -04:00
Andrew Kelley
ffaa045429 stage2: add zig_backend to the cache hash
This makes stage2 and stage3 have different cache namespaces, so that
building something with stage3 does not try to reuse the same cached
artifacts as were produced by stage2. This makes sense since the code
of stage3 is produced by the self-hosted compiler, whereas the code of
stage2 is produced by the bootstrap compiler. Note also that stage4 and
stage3 will share the same zig_backend, end hence cache namespace.
Ideally stage4 and stage3 are identical binaries, so this checks out.
2022-04-21 13:29:46 -07:00
Jakub Konka
74bfb8ba07 pdb: fix resource mgmt 2022-04-21 21:53:29 +02:00
Yusuf Bham
41654a318d std.mem: add concatWithSentinel 2022-04-21 14:39:41 -04:00
Motiejus Jakštys
6d0283e6bc
[doc update] add size_t (#11482)
For those souls looking for a zig `size_t` equivalent, and not
lucky/educated enough (that was me yesterday) to know it's the same as
`uintptr_t`.

From a recent discussion on IRC.
2022-04-21 14:33:42 -04:00
Andrew Kelley
ebfddbaf00 CI: additionally test building stage3 2022-04-21 11:20:26 -07:00
Jakub Konka
42ed34d1f6 macho: create LlvmObject in createEmpty only
Prior to this change we would also create it in `openPath`, but as
`openPath` internally calls `createEmpty` we would end up with a
memory leak.
2022-04-21 10:08:37 -04:00
Andrew Kelley
bd5831ce0e
Merge pull request #11467 from ziglang/segmented-list-decls
stage2: use indexes for Decl objects
2022-04-21 09:49:20 -04:00
Jakub Konka
bedd7efa2b debug: add smoke test 2022-04-21 11:51:38 +02:00
Jakub Konka
28ca203b71 debug: fix resource (de)allocation for Elf and Coff targets
With this change, it is now possible to safely call
`var di = std.debug.openSelfDebugInfo(gpa)`. Calling then
`di.deinit()` on the object will correctly free all allocated
resources.

Ensure we store the result of `mmap` with correct alignment.
2022-04-21 11:48:15 +02:00
Rabin Gaire
50ec55faaf ran zig fmt on changes 2022-04-21 14:12:08 +05:45
Rabin Gaire
4ece507b5a update test message and using unreachable keyword for unintended test code path 2022-04-21 13:28:41 +05:45
Andrew Kelley
31758f79db link: Wasm: don't assume we have a zig module 2022-04-20 18:14:38 -07:00
Andrew Kelley
f7596ae942 stage2: use indexes for Decl objects
Rather than allocating Decl objects with an Allocator, we instead allocate
them with a SegmentedList. This provides four advantages:
 * Stable memory so that one thread can access a Decl object while another
   thread allocates additional Decl objects from this list.
 * It allows us to use u32 indexes to reference Decl objects rather than
   pointers, saving memory in Type, Value, and dependency sets.
 * Using integers to reference Decl objects rather than pointers makes
   serialization trivial.
 * It provides a unique integer to be used for anonymous symbol names,
   avoiding multi-threaded contention on an atomic counter.
2022-04-20 17:37:35 -07:00
Andrew Kelley
4f527e5d36 std: fix missing hash map safety
There was a missing compile error for calling ensureUnusedCapacity
without a Context in the case that the Context is non-void.
2022-04-20 17:18:06 -07:00
Jakub Konka
96c1314443 debug: fix resource (de)allocation for MachO targets
With this change, it is now possible to safely call
`var di = std.debug.openSelfDebugInfo(gpa)`. Calling then
`di.deinit()` on the object will correctly free all allocated
resources.
2022-04-21 00:45:01 +02:00
Jakub Konka
26153ce73a dwarf: clean up allocations in std.dwarf module
While this code probably could do with some love and a redesign,
this commit fixes the allocations by making sure we explicitly
pass an allocator where required, and we use arenas for temporary
or narrowly-scoped objects such as a `Die` (for `Die` in particular,
not every `FormValue` will be allocated - we could duplicate, or
we can use an arena which is the proposal of this commit).
2022-04-21 00:06:52 +02:00
Rabin Gaire
d976456ef6 add test case for child_process spawn logic
tests creating a child process with stdin/stdout behavior set to
StdIo.Pipe.
2022-04-20 18:37:10 +05:45
Andrew Kelley
99112b63bd std.SegmentedList: breaking API changes
* Remove the Allocator field; instead it must be passed in as a
   parameter to any function that needs it.
 * Rename `push` to `append` and `pushMany` to `appendSlice` to match
   the conventions set by ArrayList.
2022-04-20 05:31:24 -07:00
Andrew Kelley
711bf55eaa std: bring back SegmentedList
I want to use it for the self-hosted compiler.
2022-04-20 05:31:24 -07:00
Rabin Gaire
9e4cd1f4e6 fix child process spawn on macos hangs issue
When a child process with stdin, stdout behavior set to pipe is
ran on macos it used to hang which has been fixed. Issue existed because
we forgot to call `posix_spawn_file_actions_addclose` syscall on user
exposed file descriptor which resulted on file descriptor not closing
properly.
2022-04-20 18:02:41 +05:45
Joachim Schmidt
1a1b5ee264
Merge pull request #11462 from joachimschmidt557/stage2-aarch64
stage2 AArch64: truncation support
2022-04-20 09:44:43 +02:00
protty
e3cbea934e
std.Thread.Futex improvements (#11464)
* atomic: cache_line

* Thread: Futex rewrite + more native platform support

* Futex: tests compile

* Futex: compiles and runs test

* Futex: broadcast test

* Futex: fix PosixImpl for tests

* Futex: fix compile errors for bsd platforms

* Futex: review changes + fix timeout=0 + more comments
2022-04-19 19:42:15 -05:00
Yusuf Bham
2fa7f6e502 std.os.uefi: Add BlockIoProtocol 2022-04-19 19:51:19 -04:00
Robin Voetter
859ae152bc array hash map: fix getOrPutAdapted on Managed array hash map 2022-04-19 19:41:12 -04:00
Andrew Kelley
0c5ad335d2 build system: add -fstage1/-fno-stage1 to zig build
So that people can start experimenting with compiling their projects
with the self-hosted compiler.

I expect this commit to be reverted after #89 is closed.
2022-04-19 14:40:27 -07:00
joachimschmidt557
fa85a739d9
stage2 AArch64: fix shl, shr, shl_exact, shr_exact
Introduces the necessary truncation after shift
2022-04-19 22:40:51 +02:00
joachimschmidt557
cbb13c023e
stage2 AArch64: change binOp lowering mechanism to use Mir tags
Mirrors e2e69803dc16efe11a6d42c6c49853e16a41fd0c for AArch64
2022-04-19 22:40:50 +02:00
joachimschmidt557
0a909a6712
stage2 AArch64: implement addwrap, subwrap, mulwrap 2022-04-19 22:40:50 +02:00
joachimschmidt557
d9d9fea6ae
stage2 AArch64: Add ldrsb, ldrsh instructions 2022-04-19 22:40:48 +02:00
joachimschmidt557
f95a8ddafa
stage2 AArch64: Implement basic truncate functionality 2022-04-19 22:39:14 +02:00
joachimschmidt557
c78daeb642
stage2 AArch64: add basic assertions to bits.zig for correct codegen
Includes many fixes of errors discovered by adding these assertions
2022-04-19 22:37:56 +02:00
Andrew Kelley
9c2cbe39c2
Merge pull request #11461 from Luukdegram/wasm-debug-info
Wasm: add support for debug information
2022-04-19 14:12:13 -04:00
Luuk de Gram
be08d2bdbd
wasm: Fix unreachable paths
When the last instruction is a debug instruction, the type of it is void.
Similarly for 'noreturn' emit an 'unreachable' instruction to tell the wasm-validator
the path cannot be reached.

Also respect the '--strip' flag in the self-hosted wasm linker and not emit a 'name' section
when the flag is set to `true`.
2022-04-19 19:58:49 +02:00
Andrew Kelley
78f26b970e
Merge pull request #11469 from topolarity/wasm-fixup
stage2: Move `selfExePathWasi` to `introspect.zig`
2022-04-19 13:30:15 -04:00
Andrew Kelley
535d5624e4 wasm: fix lowerDeclRefValue using wrong Decl 2022-04-19 13:04:59 -04:00
Andrew Kelley
f3b3d7f20a
Merge pull request #11468 from topolarity/f80-mul
compiler_rt: Implement softfloat multiply for `f80`
2022-04-19 13:04:31 -04:00