Commit Graph

20237 Commits

Author SHA1 Message Date
Martin Wickham
5523e2061b Move std.testing.zig_exe_path into build options 2022-09-14 14:42:58 -07:00
Andrew Kelley
61aaef0b07 std: re-enable test case for fixed bug
The miscompilation in question has been fixed upstream in LLVM 14.

closes #9879
2022-09-13 18:36:39 -07:00
Andrew Kelley
68f2d6cb24 std: remove workaround for fixed bug
The miscompilation in question has been fixed upstream in LLVM 13.

closes #8117
2022-09-13 18:20:18 -07:00
Andrew Kelley
0a89624d59 stage2: support being built in ReleaseSafe mode 2022-09-13 18:08:59 -07:00
Veikka Tuominen
349d78a443 validate number literals in AstGen 2022-09-13 20:26:04 -04:00
Andrew Kelley
716d9237cb Merge remote-tracking branch 'origin/llvm15'
Upgrade to LLVM 15
2022-09-13 15:39:19 -07:00
Andrew Kelley
fda6d44778 zig cc: do not enable the cache for link operations
This commit makes `zig cc` match the equivalent behavior of
`zig build-exe` with regards to caching. That is - it will cache
individual .c to .o compilations (with the usual exceptions), but will
always repeat the linking process so that incremental linking has a
chance to happen.

Perhaps a future enhancement will provide a way to get the old behavior,
but I suspect this new behavior will be preferred by everyone, because
it is closer to what C compilers do. Note that the old behavior can be
obtained by switching to `zig build-exe` instead of `zig cc` and using
the `--enable-cache` parameter.

Closes #12317
2022-09-13 14:10:13 -07:00
Andrew Kelley
0a4cfb81bc Merge remote-tracking branch 'origin/master' into llvm15 2022-09-13 13:50:25 -07:00
Andrew Kelley
f9859c102d fix libc++ exceptions for musl targets
This reverts commit d31be31267.

The problem was happening due to an LLVM bug exposed by having LTO
enabled for libunwind. The simple workaround is to disable LTO for
libunwind. It can be re-enabled in the future when the upstream bug
is fixed.

See #12828
2022-09-13 11:38:14 -07:00
Andrew Kelley
c25ce5bba0
Merge pull request #12820 from ziglang/pointless-discard-error
introduce compile error for pointless discards
2022-09-13 13:01:42 -04:00
Andrew Kelley
b2e94de358 add compile error test for pointless discards 2022-09-13 10:01:17 -07:00
Luuk de Gram
be94487029
Merge pull request #12823 from Luukdegram/wasm-linker
wasm-linker: misc improvements & cleanups
2022-09-13 17:42:51 +02:00
Andrew Kelley
cdb40936bd properly annotate nullability of ZigLLVMCreateDebugForwardDeclType
This bug manifested as a segfault in stage1 when calling this function.
The C++ code looks like this:

```c++
entry->llvm_di_type = ZigLLVMCreateDebugForwardDeclType(g->dbuilder,
    ZigLLVMTag_DW_structure_type(), full_name,
    import ? ZigLLVMFileToScope(import->data.structure.root_struct->di_file) : nullptr,
    import ? import->data.structure.root_struct->di_file : nullptr,
    line);
```

There is actually no problem here - what happened is that because
cross-language LTO was enabled between zig and c++ code, and because
Zig annotated the file parameter (3rd line) as being non-null, the C++
code assumed that parameter could not be null, and eagerly dereferenced
`import->...`, causing a segfault, since it was null.

I verified that this commit fixed the problem and I also verified this
hypothesis by disabling LTO and noticing that it indeed avoided the
problem.
2022-09-13 03:09:29 -07:00
Andrew Kelley
ebd082d3f6 remove pointless discards in test cases 2022-09-13 02:04:20 -07:00
Andrew Kelley
bec70a1a39 stage2: remove pointless discards from source code
Good riddance!
2022-09-13 02:04:20 -07:00
Andrew Kelley
f8a9bc57ce translate-c: lower discards differently
This makes translate-c lower discards as `_ = @TypeOf(foo);` to avoid
tripping the "pointless discard" error.

Ideally, translate-c would avoid emitting pointless discards, in which
case this commit can be reverted, however, that is a separate
enhancement.
2022-09-13 02:04:20 -07:00
Andrew Kelley
d31be31267 disable failing c++ test
See tracking issue #12828
2022-09-12 23:16:57 -07:00
Andrew Kelley
87819dba27 libunwind: compile with -std=c11
I noticed that the upstream cmake script does this now.
2022-09-12 23:16:38 -07:00
Andrew Kelley
7a941391d8 universal-libc: fix strncmp tests
The specification for this function is that it returns a positive value,
zero, or negative value, not that it returns the difference between
ascii values.
2022-09-12 22:32:15 -07:00
Andrew Kelley
78729c4939 update CI tarballs with libcxx fix
The main reason to update the CI tarballs is
f79824f946 which fixes an issue that
caused the CI to fail on all targets.
2022-09-12 21:25:49 -07:00
Andrew Kelley
2434cb6f06 cmake: add -Dversion-string flag to zig build command 2022-09-12 20:13:00 -07:00
Andrew Kelley
188902a710 Sema: introduce Type.ptrAlignmentAdvanced
I'm not sure why the other commits in this branch caused this fix to be
necessary. Also, there seems to be more fixes necessary before tests
will pass.
2022-09-12 18:13:24 -07:00
Andrew Kelley
f16855b9d7 remove pointless discards 2022-09-12 18:13:24 -07:00
Andrew Kelley
011663eea5 Merge remote-tracking branch 'origin/master' into llvm15 2022-09-12 16:11:18 -07:00
Andrew Kelley
01e89fec71 disable LLVM 15 regressed behavior test: "vector @splat"
See #12827
2022-09-12 16:02:31 -07:00
Andrew Kelley
f79824f946 libcxx: define _LIBCPP_ABI_VERSION and _LIBCPP_ABI_NAMESPACE
The changes from https://reviews.llvm.org/D119173 mean that __config no
longer defaults the libc++ ABI to 1, relying on external configuration.
This means Zig must provide the external configuration.

This fixes static libraries built with zig with -lc++ to have the
standard __1 namespace prefix, which had previously regressed in the
llvm15 branch.
2022-09-12 15:56:31 -07:00
Andrew Kelley
6e3bbba951 update CI tarballs for LLVM 15 2022-09-12 13:03:10 -07:00
Luuk de Gram
3edf8c7a6c
wasm-linker: reset file pointer for incremental
On each invocation of `flush()` the file pointer is moved.
This means that rather than overwriting the binary file,
we're appending to the file. With this commit, we're resetting
said pointer to '0' and overwrite the existing binary in incremental
mode.
2022-09-12 21:35:28 +02:00
Luuk de Gram
61f317e386
wasm-linker: rename self to descriptive name 2022-09-12 21:19:16 +02:00
Luuk de Gram
6dbf5f1d86
wasm-linker: write to file at once
Rather than writing to the file using a writer, we now first write to
an arraylist and store the binary in memory. Once the full binary
data was written, we write all data to disk at once. This reduces
the amount of syscalls tremendously, increasing the performance of
the linker in exchange for increased memory usage during flush.
2022-09-12 21:19:16 +02:00
Luuk de Gram
a01b1448e2
wasm-linker: write magic bytes only on success
By writing them at the very end, we can easily detect
where the writing of the binary went wrong as tools will
indicate the missing of the magic bytes.
2022-09-12 21:19:13 +02:00
Veikka Tuominen
e323cf1264 stage2: change how defers are stored in Zir
Storing defers this way has the benefits that the defer doesn't get
analyzed multiple times in AstGen, it takes up less space, and it
makes Sema aware of defers allowing for 'unreachable else prong'
error on error sets in generic code.

The disadvantage is that it is a bit more complex and errdefers with
payloads now emit a placeholder instruction (but those are rare).

Sema.zig before:
  Total ZIR bytes:    3.7794370651245117MiB
  Instructions:       238996 (2.051319122314453MiB)
  String Table Bytes: 89.2802734375KiB
  Extra Data Items:   430144 (1.640869140625MiB)
Sema.zig after:
  Total ZIR bytes:    3.3344192504882812MiB
  Instructions:       211829 (1.8181428909301758MiB)
  String Table Bytes: 89.2802734375KiB
  Extra Data Items:   374611 (1.4290275573730469MiB)
2022-09-12 01:52:44 -04:00
Andrew Kelley
ab3ac291ac Merge remote-tracking branch 'origin/master' into llvm15 2022-09-11 20:26:53 -07:00
Shane Kennedy
c97d64b677 chore: Remove unused constants 2022-09-11 23:18:43 -04:00
Andrew Kelley
349df40d14
Merge pull request #12814 from ziglang/native-libc-integration
stage2: no condition on system libs to link native libc
2022-09-11 23:12:50 -04:00
Andrew Kelley
65bea514ae Compilation: handle system C compiler not found
When linking libc and compiling natively, Zig tries to integrate with
the system C compiler. However, this caused Zig to fail when no system C
compiler is installed, despite the fact that Zig is perfectly capable of
compiling & linking libc without one.

This commit makes Zig fall back to using its own ability to provide libc
in the case that no C compiler is installed. For glibc, it means
sometimes getting the warning "zig cannot build new glibc version abc,
providing instead xyz".

Ideally, Zig would do some more validation about the system libraries
being linked against, and report an error in case it could not provide
the exact correct libc version of the system libraries (or that the
system libraries themselves conflict with each other), however, I think
it is fair to call that a separate enhancement.
2022-09-11 16:37:03 -07:00
Loris Cro
60678f5baf autodoc: fix regression in frontend rendering of values 2022-09-11 23:45:18 +02:00
Andrew Kelley
aec0e595f2 stage2: no condition on system libs to link native libc
Before, Zig tried to use its own libc files (e.g. glibc) when there were
no system libs being linked. This prevented building against native
glibc on systems that have newer glibc than the ones Zig provides.

Closes #12797
2022-09-11 13:39:58 -07:00
Loris Cro
2a96f80d03 autodoc: reduce json payload size
this commit removes whitespace and changes Decl, AstNode and Type to be
json arrays instead of json objects. This change reduces json payload
size for the stdlib from 25mb to < 10mb.
2022-09-11 21:35:01 +02:00
Loris Cro
81939a4939 autodoc: remove unnecessary string copy 2022-09-10 17:31:42 +02:00
Jakub Konka
4fd4c733d4 x86_64: pass more behavior tests 2022-09-10 09:23:26 +02:00
Jakub Konka
5778077f9f
Merge pull request #12799 from joachimschmidt557/stage2-arm
stage2 ARM: introduce allocRegs mechanism and other improvements
2022-09-10 09:13:08 +02:00
Jakub Konka
69da56b36c
Merge pull request #12802 from ziglang/macho-refactor
Self-hosted backends and linkers refactor: x86_64 + aarch64 + macho + coff
2022-09-10 09:07:07 +02:00
Jakub Konka
a1b8545265 coff: remove unused function 2022-09-10 00:59:46 +02:00
Jakub Konka
0824808444 macho: refactor direct use of locals container in favour of helpers 2022-09-10 00:58:16 +02:00
Jakub Konka
485d8819b3 aarch64: update codegen to using a global index rather than local index 2022-09-10 00:57:54 +02:00
Jacob Young
5b9c5191ab type: print comptime on fn type params
This avoids the following confusing error message:

    error: expected type 'fn(i32, i32) void', found 'fn(i32, i32) void'
2022-09-10 01:55:52 +03:00
Evan Haas
8e631ee3e7 translate-c: Escape non-ASCII characters that appear in macros
Macro definitions are simply a slice of bytes, which may not be
UTF-8 encoded. If they are not UTF-8 encoded, escape non-printable
and non-ASCII characters as `\xNN`.

Fixes #12784
2022-09-10 01:50:17 +03:00
Jakub Konka
fc5a6e0e32 x86_64: combine got_load, direct_load and imports_load into linker_load MCV 2022-09-10 00:18:39 +02:00
Jakub Konka
d8f2103545 macho+coff: return index into global table from getGlobalSymbol 2022-09-09 23:30:31 +02:00