Commit Graph

7191 Commits

Author SHA1 Message Date
Jacob Young
c894ac09a3 dwarf: fix stepping through an inline loop containing one statement
Previously, stepping from the single statement within the loop would
always exit the loop because all of the code unrolled from the loop is
associated with the same line and treated by the debugger as one line.
2024-11-24 17:28:12 -05:00
Jacob Young
70ad7dcd48 lldb: implement tuple types
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
2024-11-23 23:51:35 -05:00
Alex Rønne Petersen
aef5c75602 compiler: Disallow align(0) everywhere in the language.
Thus leaving the design space for this alignment value open, e.g. for packing.
2024-11-23 18:44:07 -05:00
xdBronch
5f3a70ed5f Fix peer type resolution with allowzero pointers
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
2024-11-20 02:09:50 +02:00
Jacob Young
a8ec306b49 Sema: fix peer resolution alignment between slice and empty struct
An empty struct that coerces to an empty array should not force
`align(1)` on the resulting slice type.
2024-11-16 21:22:57 -05:00
Jacob Young
11e54a3559 link: fix failing incremental test cases 2024-11-16 14:03:31 -05:00
mlugg
bbbc95afd0 AstGen: add missing rvalue call to labeledBlockExpr
...and fix a minor x86_64 backend bug exposed by this fix.

Resolves: #21974
2024-11-12 14:51:10 +00:00
mlugg
6e56bc1096
test: add new incremental case
This is similar to the old `llvm/shift_right_plus_left` case, which was
disabled by 1b1c78c. The case is not enabled on the LLVM backend, since
incremental compilation support for this backend is a work in progress
and is tracked by #21165. It passes on the x86_64-linux target with the
self-hosted backend.

Resolves: #12288
2024-11-11 12:22:55 +00:00
mlugg
ca12e4f33e
test: remove old-style incremental cases, add a few new incremental cases
These cases have been disabled for a while, and we have transitioned to
using a compact file format for incremental test cases.

I was originally planning to port all of these cases, but the vast
majority aren't testing anything interesting, so it wasn't worth the
effort. I did look through each one; anything interesting being tested
has been extracted into a new case in `test/incremental/`.

Two of the new tests are currently failing with the self-hosted ELF
linker, and thus are currently only enabled with the C backend.

Resolves: #12844
2024-11-11 12:22:48 +00:00
Wooster
35201e9d93 Sema: fix wording in error message
It's an FQN, not an actual file name.
2024-11-09 20:21:32 +00:00
Alex Rønne Petersen
f25ea264b7 Revert "test: Add aarch64_be-linux-(none,gnu,musl) to module tests."
This reverts commit 4049be90de.

See: https://github.com/ziglang/zig/issues/21911
2024-11-05 07:15:53 +01:00
Alex Rønne Petersen
4049be90de
test: Add aarch64_be-linux-(none,gnu,musl) to module tests. 2024-11-04 08:29:42 +01:00
Alex Rønne Petersen
9d0bb7ada8
test: Disable 128-bit atomics behavior tests on aarch64_be.
See: https://github.com/ziglang/zig/issues/21892
2024-11-04 08:29:42 +01:00
Alex Rønne Petersen
2958a90515
test: Disable some vector behavior tests on aarch64_be.
See: https://github.com/ziglang/zig/issues/21893
2024-11-04 08:29:42 +01:00
Alex Rønne Petersen
b72b81292f
test: Remove some unsupported ohos triples from llvm_targets. 2024-11-04 08:29:42 +01:00
Alex Rønne Petersen
96ea7d3e1c
test: Disable reinterpret packed union on all big endian targets.
See: https://github.com/ziglang/zig/issues/21050
2024-11-04 08:29:42 +01:00
Alex Rønne Petersen
3054486d1d
Merge pull request #21843 from alexrp/callconv-followup
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
Some follow-up work for #21697
2024-11-03 14:27:09 +01:00
Alex Rønne Petersen
2f003f39b2
Merge pull request #21599 from alexrp/thumb-porting 2024-11-03 14:25:30 +01:00
Alex Rønne Petersen
621487d5ab
test: Add thumb-linux-(musl)eabi(hf) target triples for module tests. 2024-11-03 09:29:33 +01:00
Alex Rønne Petersen
d89cf3e7d8
test: Add the ability to skip specific modules for a target. 2024-11-03 09:29:33 +01:00
Alex Rønne Petersen
c9e67e71c1
std.Target: Replace isARM() with isArmOrThumb() and rename it to isArm().
The old isARM() function was a portability trap. With the name it had, it seemed
like the obviously correct function to use, but it didn't include Thumb. In the
vast majority of cases where someone wants to ask "is the target Arm?", Thumb
*should* be included.

There are exactly 3 cases in the codebase where we do actually need to exclude
Thumb, although one of those is in Aro and mirrors a check in Clang that is
itself likely a bug. These rare cases can just add an extra isThumb() check.
2024-11-03 09:29:30 +01:00
Alex Rønne Petersen
e4e3d7ab41
Sema: Disallow calling functions with certain special calling conventions. 2024-11-02 10:44:18 +01:00
Alex Rønne Petersen
11915ae48e
std.zig.target: Change mips64(el)-linux-musl triples to -muslabi64.
With this, MIPS triples for musl are in line with glibc triples.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
270fbbcd86
std.Target: Add muslabin32 and muslabi64 tags to Abi.
Once we upgrade to LLVM 20, these should be lowered verbatim rather than to
simply musl. Similarly, the special case in llvmMachineAbi() should go away.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
e27b4647d8
Merge pull request #21617 from alexrp/target-dyld-stuff
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
Improve the `DynamicLinker` API and fix `detectAbiAndDynamicLinker()` for non-Linux/Hurd ELF hosts
2024-11-02 10:29:41 +01:00
mlugg
d11bbde5f9
compiler: remove anonymous struct types, unify all tuples
This commit reworks how anonymous struct literals and tuples work.

Previously, an untyped anonymous struct literal
(e.g. `const x = .{ .a = 123 }`) was given an "anonymous struct type",
which is a special kind of struct which coerces using structural
equivalence. This mechanism was a holdover from before we used
RLS / result types as the primary mechanism of type inference. This
commit changes the language so that the type assigned here is a "normal"
struct type. It uses a form of equivalence based on the AST node and the
type's structure, much like a reified (`@Type`) type.

Additionally, tuples have been simplified. The distinction between
"simple" and "complex" tuple types is eliminated. All tuples, even those
explicitly declared using `struct { ... }` syntax, use structural
equivalence, and do not undergo staged type resolution. Tuples are very
restricted: they cannot have non-`auto` layouts, cannot have aligned
fields, and cannot have default values with the exception of `comptime`
fields. Tuples currently do not have optimized layout, but this can be
changed in the future.

This change simplifies the language, and fixes some problematic
coercions through pointers which led to unintuitive behavior.

Resolves: #16865
2024-10-31 20:42:53 +00:00
Jakub Konka
6ff267dc26 link/Elf: ensure we always sort all relocations by r_offset in -r mode
According to a comment in mold, this is the expected (and desired)
condition by the linkers, except for some architectures (RISCV and
Loongarch) where this condition does not have to upheld.

If you follow the changes in this patch and in particular doc comments
I have linked the comment/code in mold that explains and implements
this.

I have also modified `testEhFrameRelocatable` test to now test both
cases such that `zig ld -r a.o b.o -o c.o` and `zig ld -r b.o a.o -o
d.o`. In both cases, `c.o` and `d.o` should produce valid object
files which was not the case before this patch.
2024-10-29 17:27:42 -07:00
Robin Voetter
3450809e3d
Merge pull request #21826 from Snektron/spirv-vulkan
spirv: vulkan setup
2024-10-29 19:58:51 +01:00
mlugg
05b445a276 Sema: add missing coercion to bool for condbr_inline
Also, start using labeled switch statements when dispatching
maybe-runtime instructions like condbr to comptime-only variants like
condbr_inline.

This can't be merged until we get a zig1.wasm update due to #21385.

Resolves: #21405
2024-10-28 02:24:59 +00:00
Robin Voetter
6d8ee89721
fix compile error tests with unstable error sets
The print order of error sets depends on the order that the compiler
adds names to its internal state. These names can be anything, and
do not necessarily need to be from the same error set or be errors
at all. When the last remaining reference to builtin.cpu.arch was
removed in start.zig in 9b42bc1ce5, this order changed. Likely there
is something that has the name 'C' that is referenced somewhere
recursively from builtin.cpu.arch.

This all causes these few tests to fail, and hence the expected
order is simply updated now. Perhaps there is a better way to
add this.
2024-10-27 18:02:12 +01:00
Robin Voetter
49a067ccfe
spirv: forbid merging logical pointers
Under some architecture/operating system combinations it is forbidden
to return a pointer from a merge, as these pointers must point to a
location at compile time. This adds a check for those cases when
returning a pointer from a block merge.
2024-10-27 16:31:45 +01:00
Alex Rønne Petersen
bf31c9505c
test: Add some missing android, haiku, illumos, solaris triples to llvm_targets. 2024-10-26 22:00:49 +02:00
Alex Rønne Petersen
03d0e296cb
Merge pull request #21710 from alexrp/function-alignment
Some improvements to the compiler's handling of function alignment
2024-10-25 11:10:28 +02:00
Veikka Tuominen
9ffee5abed
Sema: fix check for whether current AnalUnit is a test function
Closes #21159
2024-10-24 13:34:07 +03:00
Andrew Kelley
2530d638d6 more helpful message when testTlsOffsetAlignment fails 2024-10-23 16:27:39 -07:00
Andrew Kelley
f2efe05155 use deterministic order in relocatable-eh-frame tests
This test does not pass in master branch either if you flip the object
order around.
2024-10-23 16:27:39 -07:00
Andrew Kelley
22948616ff split a fat test case 2024-10-23 16:27:39 -07:00
Andrew Kelley
3cc19cd865 better error messages 2024-10-23 16:27:38 -07:00
Andrew Kelley
4706ec81d4 introduce a CLI flag to enable .so scripts; default off
The compiler defaults this value to off so that users whose system
shared libraries are all ELF files don't have to pay the cost of
checking every file to find out if it is a text file instead.

When a GNU ld script is encountered, the error message instructs users
about the CLI flag that will immediately solve their problem.
2024-10-23 16:27:38 -07:00
Andrew Kelley
5b016e290a move ld script processing to the frontend
along with the relevant logic, making the libraries within subject to
the same search criteria as all the other libraries.

this unfortunately means doing file system access on all .so files when
targeting ELF to determine if they are linker scripts, however, I have a
plan to address this.
2024-10-23 16:27:38 -07:00
Andrew Kelley
78f643c46d
Merge pull request #21758 from kcbanner/dll_storage_class
Add `is_dll_import` to @extern, to support `__declspec(dllimport)` with the MSVC ABI
2024-10-23 15:35:54 -07:00
Matthew Lugg
6bf52b0505
Merge pull request #21697 from mlugg/callconv
Replace `std.builtin.CallingConvention` with a tagged union, eliminating `@setAlignStack`
2024-10-23 16:48:33 +01:00
kcbanner
7edd69d8aa tests: add tests for is_dll_import externs
- tests/standalone/extern wasn't running its test step
- add compile error tests for thread local / dll import @extern in a comptime scope
2024-10-22 18:46:14 -04:00
kcbanner
2d888a8e63 tests: re-enable tests that now pass on aarch64-windows 2024-10-22 11:39:29 +02:00
kcbanner
85d87c9ca1 coff: fix incorrect default image_base values and re-enable shared library tests on Windows
This was the cause of aarch64-windows shared libraries causing  "bad image" errors
during load-time linking. I also re-enabled the tests that were surfacing this bug.
2024-10-21 22:54:52 -07:00
Alex Rønne Petersen
40104f2145
compiler: Disallow function alignment for nvptx and spirv. 2024-10-20 09:21:14 +02:00
mlugg
f7d679ceae
riscv: disable failing test
Looks like the self-hosted riscv64 backend can't handle `std.meta.eql`
involving the new `CallingConvention` right now.
2024-10-19 20:06:04 +01:00
mlugg
8d5ac6bdea
Sema: add and improve some callconv compile errors 2024-10-19 19:46:07 +01:00
mlugg
4be0cf30fc
test: update for CallingConvention changes
This also includes some compiler and std changes to correct error
messages which weren't properly updated before.
2024-10-19 19:15:23 +01:00
mlugg
8573836892
incremental: disable flaky test 2024-10-18 09:46:03 +01:00