Commit Graph

28561 Commits

Author SHA1 Message Date
Jakub Konka
b343103567 elf+aarch64: handle gottp and .tls_common 2024-03-08 22:46:18 +01:00
Jakub Konka
7258d143e3 elf+aarch64: fix incorrectly emitted TLSDESC relocs 2024-03-08 22:46:17 +01:00
Jakub Konka
b5642b4f85 elf+aarch64: set _GLOBAL_OFFSET_TABLE_ to .got section 2024-03-08 22:46:17 +01:00
Jakub Konka
d9069cbe2c elf+aarch64: relax TLSDESC for executables 2024-03-08 22:46:17 +01:00
Jakub Konka
310cef0972 elf+aarch64: handle TLSDESC non-relaxed 2024-03-08 22:46:17 +01:00
Jakub Konka
109d2321b0 link: refactor common aarch64 helpers 2024-03-08 22:46:17 +01:00
Jakub Konka
c1dbf01aa3 elf+aarch64: resolve TLS LE model 2024-03-08 22:46:17 +01:00
Jakub Konka
69f9f359dd elf+aarch64: use correctly offset tp address 2024-03-08 22:46:17 +01:00
Jakub Konka
0af5d2e9b6 elf+aarch64: implement .plt.got 2024-03-08 22:46:17 +01:00
Jakub Konka
1cf45fb209 elf+aarch64: implement enough to link dynamically with gcc as the driver 2024-03-08 22:46:17 +01:00
mlugg
f3227598eb Sema: reset block error return trace index between cases
Resolves: #19210
2024-03-08 07:30:32 -08:00
february cozzocrea
b2427ea7d8 test manifest key checking and other fixes
This commit adds several fixes and improvements for the Zig compiler
test harness.

1. -Dskip-translate-c option added for skipping the translate-c tests.
2. translate-c/run-translated-c tests in test/cases/* have been added to
   the steps test-translate-c and test-run-translated-c. Closes #18224.
3. Custom name added to the CheckFile step for the translate-c step to
   better communicate which test failed.
4. Test manifest key validation added to return an error if a manifest
   contains an invalid key.
2024-03-08 02:59:45 -08:00
Andrew Kelley
83e578a181
Merge pull request #19163 from ianic/zlib_no_lookahead
compress.zlib: don't overshoot underlying reader
2024-03-07 18:46:47 -08:00
Andrew Kelley
97aa5f7b8a
Merge pull request #19190 from mlugg/struct-equivalence
compiler: namespace type equivalence based on AST node + captures
2024-03-07 18:41:45 -08:00
mlugg
38331b1cab
Package.Module: actually set File.path_digest for builtin modules 2024-03-07 06:26:25 +00:00
Dillen Meijboom
377ecc6afb feat: add support for --enable-new-dtags and --disable-new-dtags 2024-03-06 17:52:05 -08:00
Jacob Young
aa7d16aba1 grammar: remove gratuitous ambiguity
Previously, the following matched both ContainerField alternatives:
 * [IDENTIFIER]
 * [IDENTIFIER][COLON][TypeExpr]
2024-03-06 13:59:46 -08:00
mlugg
b41a0b4768
Package.Module: deduplicate identical builtin modules
Previously, when multiple modules had builtin modules with identical
sources, two distinct `Module`s and `File`s were created pointing at the
same file path. This led to a bug later in the frontend. These modules
are now deduplicated with a simple hashmap on the builtin source.
2024-03-06 21:26:39 +00:00
mlugg
4c05a9a892
Sema: do not destroy enum type if field analysis fails 2024-03-06 21:26:38 +00:00
mlugg
e1d8187028
cases: correct after #18816
I changed an error messages and fixed a minor bug while implementing
this proposal, which led to a few compile error cases failing.
2024-03-06 21:26:38 +00:00
mlugg
e043fe474f
Fix incorrectly resolved merge conflicts
To be honest, I can't be bothered to figure out which commits these
changes should be in.
2024-03-06 21:26:38 +00:00
mlugg
20403ee41d
behavior: add tests for #18816 2024-03-06 21:26:38 +00:00
mlugg
a7cac5fc8e
behavior: correct tests after #18816 2024-03-06 21:26:38 +00:00
mlugg
2c4ac44f25
compiler: treat decl_val/decl_ref of potentially generic decls as captures
This fixes an issue with the implementation of #18816. Consider the
following code:

```zig
pub fn Wrap(comptime T: type) type {
    return struct {
        pub const T1 = T;
        inner: struct { x: T1 },
    };
}
```

Previously, the type of `inner` was not considered to be "capturing" any
value, as `T1` is a decl. However, since it is declared within a generic
function, this decl reference depends on the context, and thus should be
treated as a capture.

AstGen has been augmented to tunnel references to decls through closure
when the decl was declared in a potentially-generic context (i.e. within
a function).
2024-03-06 21:26:38 +00:00
mlugg
d0c022f734
compiler: namespace type equivalence based on AST node + captures
This implements the accepted proposal #18816. Namespace-owning types
(struct, enum, union, opaque) are no longer unique whenever analysed;
instead, their identity is determined based on their AST node and the
set of values they capture.

Reified types (`@Type`) are deduplicated based on the structure of the
type created. For instance, if two structs are created by the same
reification with identical fields, layout, etc, they will be the same
type.

This commit does not produce a working compiler; the next commit, adding
captures for decl references, is necessary. It felt appropriate to split
this up.

Resolves: #18816
2024-03-06 21:26:37 +00:00
mlugg
8ec6f730ef
compiler: represent captures directly in InternPool
These were previously associated with the type's namespace, but we need
to store them directly in the InternPool for #18816.
2024-03-06 21:26:37 +00:00
mlugg
975b859377
InternPool: create specialized functions for loading namespace types
Namespace types (`struct`, `enum`, `union`, `opaque`) do not use
structural equality - equivalence is based on their Decl index (and soon
will change to AST node + captures). However, we previously stored all
other information in the corresponding `InternPool.Key` anyway. For
logical consistency, it makes sense to have the key only be the true key
(that is, the Decl index) and to load all other data through another
function. This introduces those functions, by the name of
`loadStructType` etc. It's a big diff, but most of it is no-brainer
changes.

In future, it might be nice to eliminate a bunch of the loaded state in
favour of accessor functions on the `LoadedXyzType` types (like how we
have `LoadedUnionType.size()`), but that can be explored at a later
date.
2024-03-06 21:26:37 +00:00
mlugg
a6ca20b9a1
compiler: change representation of closures
This changes the representation of closures in Zir and Sema. Rather than
a pair of instructions `closure_capture` and `closure_get`, the system
now works as follows:

* Each ZIR type declaration (`struct_decl` etc) contains a list of
  captures in the form of ZIR indices (or, for efficiency, direct
  references to parent captures). This is an ordered list; indexes into
  it are used to refer to captured values.
* The `extended(closure_get)` ZIR instruction refers to a value in this
  list via a 16-bit index (limiting this index to 16 bits allows us to
  store this in `extended`).
* `Module.Namespace` has a new field `captures` which contains the list
  of values captured in a given namespace. This is initialized based on
  the ZIR capture list whenever a type declaration is analyzed.

This change eliminates `CaptureScope` from semantic analysis, which is a
nice simplification; but the main motivation here is that this change is
a prerequisite for #18816.
2024-03-06 21:26:37 +00:00
Veikka Tuominen
90ab8ea9e6
Sync Aro sources (#19199)
ref: 02353ad9f17f659e173f68975a442fcec3dd2c94
2024-03-06 14:17:41 -05:00
garrison hinson-hasty
1e67f50211
Sema: fix compiler crash @ptrCasting optional slice 2024-03-05 18:55:21 +00:00
Meghan Denny
7d41a5cbcf cli: add --rpath and -R linker arg aliases 2024-03-05 10:39:55 -08:00
OK Ryoko
0b2e23b066 std.os.linux: enforce null-terminated path arguments 2024-03-05 20:11:49 +02:00
crayon
f5e2fa5c95 langref now sets color-scheme 2024-03-05 15:55:00 +02:00
Michael Ortmann
0b744da844 Fix doc - Language Reference - Table of Operators 2024-03-04 15:59:00 +00:00
Ryan Liptak
469643940c Use the global cache dir for the manifests of generated mingw .libs
Fixes a mismatch where the manifests would be written to the local cache dir, but the .def/.lib files themselves would be written to the global cache dir. This meant that if you cleared your global cache, your local cache would still think that the .lib files existed in the cache and it'd lead to 'No such file or directory' errors at linktime.

This mismatch was introduced in the stage1 -> stage2 transition of this code.
2024-03-04 05:36:01 -08:00
Igor Anić
a06a305f97 zlib: fix missing comptime attribute 2024-03-04 09:53:01 +01:00
Igor Anić
c680b5d138 compress.zlib: add overshoot test cast
Using example from [zigimg](https://github.com/zigimg/zigimg/pull/164) project.
2024-03-04 09:53:01 +01:00
Igor Anić
f2508abfa6 flate: use 4 bytes lookahead for zlib
That ensures no bytes are left in the BitReader buffer after we reach
end of the stream.
2024-03-04 09:53:01 +01:00
Igor Anić
711281602a flate: option to fill BitReader
fill(0) will fill all bytes in bit reader. If bit reader is aligned to
the byte, as it is at the end of the stream this ensures no overshoot
when reading footer. Footer is 4 bytes (zlib) or 8 bytes (gzip). For
zlib we will use 4 bytes BitReader and 8 for gzip. After align and fill
we will read those bytes and leave BitReader empty after that.
2024-03-04 09:53:01 +01:00
Igor Anić
8a963fd66e flate: 32 bit BitReader
Extend BitReader to accept size of internal buffer. It can be u64 (only
option until now) or u32.
2024-03-04 09:53:01 +01:00
Andrew Kelley
90c1a2c41a
Merge pull request #19152 from antlilja/llvm-broken-debug
LLVM: Fail to emit if LLVM encounters broken debug info
2024-03-02 21:43:39 -08:00
Andrew Kelley
33de937fd9 move zig objcopy command to be lazily built
part of #19063
2024-03-02 21:22:45 -08:00
Jacob Young
aa688567f5 Air: replace .dbg_inline_* with .dbg_inline_block
This prevents the possibility of not emitting a `.dbg_inline_end`
instruction and reduces the allocation requirements of the backends.

Closes #19093
2024-03-02 21:19:34 -08:00
antlilja
282b398f6d Add comment explaining LLVM bug and linking tracking issue 2024-03-03 02:28:24 +01:00
Andrew Kelley
671c2acf47
Merge pull request #19094 from truemedian/std-http-fields
std.http: fix http field parsing
2024-03-02 14:34:43 -08:00
antlilja
d345068ec2 LLVM: Fail to emit if LLVM encounters broken debug info 2024-03-02 20:53:06 +01:00
antlilja
e2345f006f LLVM: Add enableBrokenDebugInfoCheck and getBrokenDebugInfo
These functions allows the caller to find out wether the context
encounters broken debug info or not.
2024-03-02 20:53:06 +01:00
Matthew Lugg
9d500bda2d
Merge pull request #19117 from mlugg/dbg-var-blocks
Major ZIR size optimizations & small cleanups in Sema
2024-03-02 04:52:19 +00:00
Andrew Kelley
64f77f32df
Merge pull request #19136 from squeek502/windows-symlink-path-sep
Fix symLink's handling of `/` path separators on Windows
2024-03-01 17:45:33 -08:00
Jacob Young
b60fc16b4f compiler: audit debug mode checks
* Introduce `-Ddebug-extensions` for enabling compiler debug helpers
 * Replace safety mode checks with `std.debug.runtime_safety`
 * Replace debugger helper checks with `!builtin.strip_debug_info`

Sometimes, you just have to debug optimized compilers...
2024-03-01 17:42:54 -08:00