20767 Commits

Author SHA1 Message Date
Veikka Tuominen
3b60a6de2f Sema: fix using runtime instructions inside typeof in comptime only blocks
Closes #13210
Follow up to 3ccd4907fbcd04ecddffb618a4b14581fd080279
2022-10-20 20:11:12 +03:00
Veikka Tuominen
c95a34b68f stage2: improve source location of assignment 2022-10-20 20:11:00 +03:00
Veikka Tuominen
34e4b07d0c Sema: allow runtime only instructions to be emitted in outside functions
It is possible to get comptime-known values from runtime-known values
for example the length of array. Allowing runtime only instructions to
be emitted outside function bodies allows these operations to happen.
In places where comptime-known values are required we have other methods
to ensure that and they usually result in more specific compile errors too.

Closes #12240
2022-10-20 20:11:00 +03:00
Veikka Tuominen
13897be0ab Type: bitSizeOf non-packed structs should include padding
Closes #13214
2022-10-20 20:11:00 +03:00
Andrew Kelley
5b9c8d1d6f add m68k target CPU features 2022-10-20 09:21:06 -07:00
joachimschmidt557
67941926b2
stage2 AArch64: Remove remaining legacy binOp code 2022-10-20 16:14:52 +02:00
joachimschmidt557
dd62d5941e
stage2 AArch64: move remaining operations out of binOp 2022-10-20 16:14:52 +02:00
joachimschmidt557
3800bb538a
stage2 AArch64: mov mul,div,mod to new allocRegs mechanism 2022-10-20 16:14:52 +02:00
joachimschmidt557
ea7a60116d
stage2 AArch64: move add+sub to new allocRegs mechanism 2022-10-20 16:14:52 +02:00
joachimschmidt557
d8fddb535c
stage2 AArch64: move cmp to new allocRegs mechanism
Remove cmp from binOp in the process
2022-10-20 16:14:52 +02:00
joachimschmidt557
5838fe89c1
stage2 AArch64: introduce ldr_ptr_stack Mir instruction 2022-10-20 16:14:52 +02:00
joachimschmidt557
230bafa1ab
stage2 AArch64: simplify allocMem 2022-10-20 16:14:52 +02:00
joachimschmidt557
151e15e444
stage2 AArch64: merge floating-point registers into Register enum 2022-10-20 16:14:50 +02:00
Matheus C. França
b41b35f578
crypto/benchmark - replace testing allocator
Fix error: Cannot use testing allocator outside of test block
2022-10-20 14:04:59 +03:00
yujiri8
a99d465f62
Fix #12091: Error message with TERM=dumb is missing info 2022-10-20 13:57:57 +03:00
Andrew Kelley
a4eb221b9e link/MachO: avoid depending on host PATH_MAX
closes #13229

Restores ability to compile zig for WASI
2022-10-19 12:20:42 -07:00
LordMZTE
3f577f06a0 build: added unwind_tables to LibExeObjStep 2022-10-19 13:24:06 -04:00
Andrew Kelley
8a344fab39
Merge pull request #13036 from BratishkaErik/fix-installing 2022-10-19 09:34:35 -04:00
Luuk de Gram
7d6596e979
Merge pull request #13218 from Luukdegram/fix-emulatable-step
std: CheckObject - correctly depend on its own step when creating an EmulatableRunStep
2022-10-19 08:36:14 +02:00
Andrew Kelley
1952dd6437 Revert recent std.Progress implementation changes
I have noticed this causing my terminal to stop accepting input
sometimes. The previous implementation with all of its flaws was better
in the sense that it never caused this to happen.

This commit has multiple reverts in it:

Revert "Merge pull request #13148 from r00ster91/progressfollowup"

This reverts commit cb257d59f97ea5655bf453d8e7f07bbfb0a88e58, reversing
changes made to f5f28e0d2c49d5c62914edf0bff8f1941eef721f.

Revert "`std.Progress`: fix inaccurate line truncation and use optimal
max terminal width (#12079)"

This reverts commit cd3d8f3a4ee22a41098b1daf2a36d7fbb342d0fa.
2022-10-18 18:53:44 -07:00
Andrew Kelley
cb635e084b stage2: better handling of CacheMode.whole on Windows
Windows gives AccessDenied if you delete a directory which contains open
file handles. This could be triggered when using CacheMode.whole when
cross compiling macho test binaries.
2022-10-18 16:52:43 -07:00
Andrew Kelley
9ee4530b9b std.os.windows.OpenFile: handle INVALID_HANDLE ntstatus 2022-10-18 16:52:43 -07:00
Andrew Kelley
c7772dd694 std.zig.system.NativePaths: avoid calling std.os.getenv on Windows 2022-10-18 16:52:43 -07:00
Andrew Kelley
caddbbc315 build: avoid compiling self-hosted twice
build.zig: add a 'compile' step to compile the self-hosted compiler
without installing it.
Compilation: set cache mode to whole when using the LLVM backend and
--enable-cache is passed.

This makes `zig build` act the same as it does with stage1. Upside is
that a second invocation of `zig build` on an unmodified source tree
will avoid redoing the compilation again. Downside is that it will
proliferate more garbage in the project-local cache (same as stage1).

This can eventually be fixed when Zig's incremental compilation is more
robust; we can go back to having LLVM use CacheMode.incremental and rely
on it detecting no changes and avoiding doing the flush() step.
2022-10-18 16:52:43 -07:00
Eric Joldasov
1013212697 cmake: separate installing and building (again) 2022-10-18 16:52:43 -07:00
Veikka Tuominen
4aaff75c81 Sema: resolve tuple default values before hashing
Closes #12488
2022-10-19 01:38:19 +03:00
Veikka Tuominen
6582896ee0 Sema: remove unresolved inferred allocs
Closes #2557
2022-10-19 01:38:19 +03:00
Veikka Tuominen
4e134f6dcb Sema: respect inline call semantics
If an argument is comptime-known but shouldn't be create an alloc
to store it in to get a runtime-known value.
2022-10-19 01:38:18 +03:00
Andrew Kelley
14c173b200 ci: windows: update tarball
This has the `@max`/`@maximum`, `@min`/`@minimum` update.
2022-10-18 15:30:44 -07:00
Andrew Kelley
4f9345d20b Revert "adding static and dynamic ZigEquivalent
enums so that we can branch to set `link_mode` properly when we iterate
over the clang arguments. also replaced `dynamic` flag in
clang_options_data.zig with proper definition similarly to `static`."

This reverts commit 6af0eeb58d1d220d407ce4c463eaeb25b35f2761.

This change needs more careful consideration. It regressed
zig-bootstrap due to cmake passing `-static -lkernel32` and zig failing
with error.UnableToStaticLink.

See https://github.com/ziglang/zig-bootstrap/issues/134
2022-10-18 14:16:07 -07:00
Andrew Kelley
b120c819db
Merge pull request #13055 from alichraghi/m2m
all: rename `@maximum` to `@max` and `@minimum` to `@min`
2022-10-18 14:42:55 -04:00
Andrew Kelley
4962f36b0f synchronize target CPU features with LLVM 15.0.3 2022-10-18 10:18:09 -07:00
Andrew Kelley
7c7d9e13d7 Sema: fix runtime int to enum with one possible value 2022-10-18 10:18:09 -07:00
Andrew Kelley
d0a5ad0e4c update libcxx to LLVM 15.0.3 2022-10-18 10:18:09 -07:00
Motiejus Jakštys
fd10baf748 os.copy_file_range: save a syscall for most operations
Currenty copy_file_range always uses at least two syscalls:

1. As many as it needs to do the initial copy (always 1 during my
   testing)
2. The last one is always when offset is the size of the file.

The second syscall is used to detect the terminating condition. However,
because we do a stat for other reasons, we know the size of the file,
and we can skip the syscall.

Sparse files: since copy_file_range expands holes of sparse files, I
conclude that this layer was not intended to work with sparse files. In
other words, this commit does not make it worse for sparse file society.

Test program
------------

    const std = @import("std");

    pub fn main() !void {
        const arg1 = std.mem.span(std.os.argv[1]);
        const arg2 = std.mem.span(std.os.argv[2]);
        try std.fs.cwd().copyFile(arg1, std.fs.cwd(), arg2, .{});
    }

Test output (current master)
----------------------------

Observe two `copy_file_range` syscalls: one with 209 bytes, one with
zero:

    $ zig build-exe cp.zig
    $ strace ./cp ./cp.zig ./cp2.zig |& grep copy_file_range
    copy_file_range(3, [0], 5, [0], 4294967295, 0) = 209
    copy_file_range(3, [209], 5, [209], 4294967295, 0) = 0
    $

Test output (this diff)
-----------------------

Observe a single `copy_file_range` syscall with 209 bytes:

    $ /code/zig/build/zig build-exe cp.zig
    $ strace ./cp ./cp.zig ./cp2.zig |& grep copy_file_range
    copy_file_range(3, [0], 5, [0], 4294967295, 0) = 209
    $
2022-10-18 12:57:21 -04:00
Motiejus Jakštys
5ec76cf5c8 [elf] main.zig: add -z nocopyreloc
I did not fully wire it up in main.zig when I originally implemented
`-z nocopyreloc` in #11679 (440f5249f1a). Finish it.

If we strictly follow the rules, we should bump the cache has version,
since the field was technically added only now. But since nobody
complained thus far, I don't think many users care that much about it
and we can omit it.
2022-10-18 12:55:31 -04:00
Loris Cro
787788996f
Merge pull request #13120 from jcalabro/master
Add [src] links to function decls in autodocs
2022-10-18 17:51:40 +02:00
Luuk de Gram
c0fe135ff3
test/link: remove redundant dependOn statements
`runAndCompare` will already depend on the `CheckObject` step itself
so it's not needed to also have the test step depend on the
check object step.
2022-10-18 17:20:08 +02:00
Luuk de Gram
10b56b21d4
CheckObjectStep: correctly depend on its own step
When creating an `EmulatableRunStep`, it now correctly depends
on its own step rather than only the executable that was created.
This means we do not need to add extra `dependOn` statements on
both the emulatable step as well as the check object step.
2022-10-18 17:15:58 +02:00
Jacob Young
687a7d38a0 value: implement Value.eqlAdvanced on slices
* Support comparison between implicitly casted array pointer and slice.
 * Support comparison between slices with different value tags.

Closes #12700
2022-10-18 14:16:39 +02:00
Veikka Tuominen
71e0ab4ec7 zig fmt: rewrite @maximum and @minimum 2022-10-18 14:16:24 +03:00
Ali Chraghi
ca27055cda all: rename @maximum to @max and @minimum to @min 2022-10-18 14:15:16 +03:00
GethDW
edc842ff18
stage2: implement packedStuctToInt for more types 2022-10-18 14:05:48 +03:00
Meghan
759f72fcfe std.debug: define error set in DebugInfo.lookupModuleDl 2022-10-18 13:03:49 +02:00
Xavier Bouchoux
23e212a9d0 std: check for overflow in dumpStackTraceFromBase
same change as [68e26a2ceea85a1] "std: check for overflow in writeCurrentStackTrace"

On arm64 macOS, the address of the last frame is 0x0 rather than
a positive value like 0x1 on x86_64 macOS, therefore, we overflow
an integer trying to subtract 1 when printing the stack trace. This
patch fixes it by first checking for this condition before trying
to subtract 1.

Same behaviour on i386-windows-msvc.

Note that we do not need to signal the `SignalIterator` about this
as it will correctly detect this condition on the subsequent iteration
and return `null`, thus terminating the loop.
2022-10-18 13:03:22 +02:00
jacobly0
bd0dd225e8
Sema: implement linksection on functions
* Sema: implement linksection on functions

 * Implement function linksection in Sema.
 * Don't clobber function linksection/align/addrspace in Sema.
 * Fix copy-paste typo in tests.
 * Add a bunch of missing test_step.dependOn.
 * Fix checkInSymtab match.

Closes #12546
2022-10-18 14:02:10 +03:00
jumpnbrownweasel
71f8762959
Fix for #13163: DefaultRwLock accumulates write-waiters, eventually fails to write lock (#13180)
* Fix for: DefaultRwLock accumulates write-waiters, eventually fails to write lock #13163

* Comment out debug.print at the end of the last test.

* Code formatting

* - use equality test after lock/unlock rather than peeking into internals.
  however, this is still implementation specific and only done for
  DefaultRwLock.
- add num_reads maximum to ensure that reader threads stop if writer threads are
  starved
- use relaxed orderings for the read atomic counter
- don't check at the end for non-zero read ops, since the reader threads may
  only run once if they are starved

* More review changes
- Monotonic is sufficient for incrementing the reads counter
2022-10-17 18:15:15 -05:00
Andrew Kelley
ce3ffa5e1b
Merge pull request #11747 from Luukdegram/compiler-rt
compiler_rt: Move mem implementations from c.zig
2022-10-17 18:12:22 -04:00
Yujiri
8aa21ade8c add tcdrain on linux 2022-10-17 18:01:05 -04:00
Andrew Kelley
a1486e1e1e stage2: allow comptime expressions for inline asm
It is not yet determined whether the Zig language will land on
text-based string concatenation for inline assembly, as Zig 0.9.1
allows, and as this commit allows, or whether it will introduce a new
assembly syntax more integrated with the rest of the language. Until
this decision is made, this commit relaxes the restriction which was
preventing inline assembly expressions from using comptime expressions
for the assembly source code.
2022-10-17 16:31:23 -04:00