19592 Commits

Author SHA1 Message Date
Andrew Kelley
a3045b8abb LLVM backends: more LLVM 15 fixes
uwtable now needs a "sync" or "async" parameter.

more opaque pointer fixes
2022-08-03 16:42:27 -07:00
Andrew Kelley
7e43904508 stage1: more LLVM15 opaque pointers fixes 2022-08-03 14:48:08 -07:00
Andrew Kelley
900f969cb3 link: LLD 15 requires two dashes on --error-limit 2022-08-03 14:19:35 -07:00
Andrew Kelley
d631bfe060 update clang CLI options to LLVM 15 2022-08-02 19:43:38 -07:00
Andrew Kelley
c75226d033 update target CPU features for LLVM 15 2022-08-02 19:22:09 -07:00
Andrew Kelley
5043369e14 stage1: fix a few more LLVM 15 opaque pointer bugs 2022-08-02 18:06:21 -07:00
Andrew Kelley
c8e20758f6 add missing declaration to zig_clang.h 2022-08-02 17:22:23 -07:00
Andrew Kelley
affe52b590 compiler_rt: use standard f16 function names on x86
LLVM 15 started generating calls to the standard name now.
2022-08-02 17:22:23 -07:00
Andrew Kelley
dfecd819ce build: add new clang libraries for LLVM 15 upgrade 2022-08-02 17:22:16 -07:00
Andrew Kelley
129bd4e9c3 update LLVM library list to LLVM 15 2022-08-02 16:57:32 -07:00
Andrew Kelley
30b98d3973 more LLVM backend fixes
more carnage from opaque pointers API
2022-08-02 16:48:58 -07:00
Andrew Kelley
99318e7a95 LLVM backend fixes
Fixing assertions hit after upgrading to opaque pointers API.
2022-08-02 00:04:38 -07:00
Andrew Kelley
44f833129c LLVM backends: work around poorly designed C API
As part of the Opaque Pointers upgrade documentation, LLVM says that the
function LLVMGetGEPSourceElementType() can be used to obtain element
type information in lieu of LLVMGetElementType(), however, this function
actually returns the struct type, not the field type. The GEP
instruction does store the information we need, however, this is not
exposed in the C API. It seems like they accidentally exposed the wrong
field, because one would never need the struct type since one must
already pass it directly to the GEP instruction, so one will always have
it handy, whereas one will usually not have the field type handy.
2022-08-01 23:26:36 -07:00
Andrew Kelley
9e4091200e stage1: avoid using LLVMGetElementType 2022-08-01 23:00:57 -07:00
Andrew Kelley
aa79cc10aa fix bugs from previous two commits 2022-08-01 22:41:45 -07:00
Andrew Kelley
bc2aaf18c8 stage2: LLVM lowering to opaque pointers API 2022-08-01 20:55:17 -07:00
Andrew Kelley
0f793840ae stage1: LLVM lowering to opaque pointers API 2022-08-01 18:16:52 -07:00
Andrew Kelley
70d3912390 update Target, CPU, OS, ABI, etc. to LLVM 15 2022-07-31 18:10:28 -07:00
Andrew Kelley
d46446e4df Merge remote-tracking branch 'origin/master' into llvm15 2022-07-31 15:55:44 -07:00
Ikko Ashimine
ff125db53d wasm: fix typo in CodeGen.zig
occured -> occurred
2022-07-31 13:00:37 -07:00
Ryan Liptak
1a1b7a3afd Linux: Add IN_MASK_CREATE and corresponding error handling in inotify_add_watch
From https://man7.org/linux/man-pages/man7/inotify.7.html

> **IN_MASK_CREATE** (since Linux 4.18)
>
> Watch pathname only if it does not already have a watch associated with it; the error EEXIST results if pathname is already being watched.
2022-07-31 13:00:16 -07:00
Cody Tapscott
075f93fa10 stage2 LLVM: Pass inline assembly outputs directly when not targeting memory
This change provides a basic implementation of #2349 for stage2. There's
still quite a lot of work before this logic is as complete as what's in
Clang (b364535304/clang/lib/CodeGen/CGStmt.cpp (L2304-L2795)),
particularly considering the diversity of constraints across targets.

It's probably not worth doing the complete work until there's a clearer
picture for constraints in Zig's future dedicated ASM syntax, but at
least this gives us a small improvement for now.

As a bonus, this also fixes a bug with how we were handling `_`
identifiers.
2022-07-31 12:59:19 -07:00
Andrew Kelley
1ab15b6c9c
Merge pull request #12289 from Vexu/stage2
Stage2: reify functions + fixes
2022-07-31 12:57:53 -07:00
sin-ack
b35490c217 cmake: Print all LLVM config errors instead of just the last one
If you have multiple llvm-config executables in your path, and all of
them cause failures, then only the last failure will be printed. This
can cause confusion when the multiple llvm-config executables are from
different major LLVM versions, i.e. LLVM 13 and 14, which might mask an
error that happened on the LLVM 14 llvm-config with an unrelated error.

This commit makes it so that all errors are collected into a list and
printed all at once; this way, you can see how each llvm-config
executable failed to configure properly. Note that the failures still
won't be printed if a successful configuration is found.
2022-07-31 12:56:00 -07:00
Cody Tapscott
c0a1b4fa46 stage2: Fix AIR printing
Packed structs never have comptime fields, and a slice might actually be
backed by a variable, which we need to catch before iterating its
elements.
2022-07-30 12:36:11 -07:00
Evan Haas
8632e4fc7b translate-c: use correct number of initializers for vectors
Fixes #12264
2022-07-30 13:24:03 +03:00
Veikka Tuominen
02dc073260 Sema: check comptime slice sentinel 2022-07-30 11:07:37 +03:00
Andrew Kelley
3cf8f283d3
Merge pull request #12085 from topolarity/dyn-link-libcpp
Dynamically link `libc++` if integrating with system LLVM
2022-07-29 14:18:32 -07:00
Veikka Tuominen
d26d696ee0 parser: require expression after colon in slice expr 2022-07-30 00:18:08 +03:00
Veikka Tuominen
4758752e5d Sema: implement coercion from tuples to tuples
Closes #12242
2022-07-30 00:18:08 +03:00
Veikka Tuominen
17622b9db1 Sema: implement @Type for functions
Closes #12280
2022-07-30 00:18:08 +03:00
Veikka Tuominen
f43ea43ac9 stage2: fix hashing of struct values
Closes #12279
2022-07-30 00:17:49 +03:00
Cody Tapscott
4fc2acdaa4 build.zig: Emit warning if "config.h" cannot be found
We now warn the user if config.h could not be located.

This also updates the search to stop early upon encountering a
`.git` directory, so that we avoid recursing outside of the zig
source if possible.
2022-07-29 11:38:58 -07:00
Wei Fu
b3d0694fc5 stage1: remove deadcode ast_print
Fixes: 2a990d696 ("stage1: rework tokenizer to match stage2")
Fixes: b6354ddd5 ("move AST rendering code to separate file")

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-29 11:28:39 -07:00
Andrew Kelley
64dc1b05d6
Merge pull request #12286 from ziglang/division-safety
Division safety improvements
2022-07-29 11:03:27 -07:00
Andrew Kelley
932d1f785e CI: -Denable-llvm for test-cases
This requires using -Dstatic-llvm and setting the search prefix and the
target, just like it is required for building stage2 and stage3. This
prevents Zig from trying to integrate with the system, which would
trigger an error due to the `cc` command not being installed.

closes #12144
2022-07-29 11:03:12 -07:00
Andrew Kelley
a7a6f38eeb Sema: fix runtime safety for integer overflow with vectors 2022-07-29 11:03:12 -07:00
Cody Tapscott
58540f968a ELF: Scan for dylibs-as-objects when adding rpaths
Shared libraries can be provided on the command line as if they were
objects, as a path to the ".so" file. The "each-lib-rpath" functionality
was ignoring these shared libraries accidentally, causing missing rpaths
in the output executable.
2022-07-29 09:44:45 -07:00
Andrew Kelley
1b1c70ce38 disable failing incremental compilation test case
see #12288

now `zig build test-cases -Denable-llvm` passes locally for me.
2022-07-29 02:35:06 -07:00
Andrew Kelley
daac39364a fix compile error test case note column number 2022-07-29 02:35:06 -07:00
Andrew Kelley
40f8f0134f Sema: enhance div_trunc, div_exact, div_floor
* No longer emit div_exact AIR instruction that can produce a
   remainder, invoking undefined behavior.
 * div_trunc, div_exact, div_floor are extracted from analyzeArithmetic
   and directly handled similarly to div_trunc, integrating them with
   integer overflow safety checking.
 * Also they no longer emit divide-by-zero safety checking when RHS
   is comptime known to be non-zero.
2022-07-29 02:35:06 -07:00
Andrew Kelley
1fc24e8d80 Sema: enhance div instruction analysis
Concrete improvements:
 * Added safety for integer overflow (-MAX_INT/-1)
 * Omit division by zero safety check when RHS is comptime known to
   be non-zero.
 * Avoid emitting `_optimized` variants of AIR instructions for integers
   (this suffix is intended to be used for floats only).

Subjective changes: I extracted the div logic out from analyzeArithmetic
in order to reduce the amount of branches - not for performance reasons
but for code clarity. It is more lines of code however, and some logic
is duplicated.
2022-07-29 02:35:06 -07:00
Andrew Kelley
a482517357 std.debug: default signal handler also handles SIGFPE 2022-07-29 02:35:06 -07:00
Veikka Tuominen
fdaf9c40d6 stage2: handle tuple init edge cases 2022-07-29 10:12:36 +03:00
Veikka Tuominen
9e0a930ce3 stage2: add error for comptime control flow in runtime block 2022-07-29 10:08:35 +03:00
Meghan Denny
b5861193e0 std: rename std.Target.systemz to .s390x 2022-07-28 23:22:44 -07:00
Cody Tapscott
f1feb1369b Dynamically link libc++, if integrating with system LLVM
This ensures that the zigcpp clang driver and LLVM are using the
same copy of libc++. See prior commit for more details.
2022-07-28 22:21:24 -07:00
Cody Tapscott
b0525344a2 Add check to verify libc++ is shared by LLVM/Clang
This check is needed because if static/dynamic linking is mixed incorrectly,
it's possible for Clang and LLVM to end up with duplicate "copies" of libc++.

This is not benign: Static variables are not shared, so equality comparisons
that depend on pointers to static variables will fail. One such failure is
std::generic_category(), which causes POSIX error codes to compare as unequal
when passed between LLVM and Clang.

I believe this is the cause of https://github.com/ziglang/zig/issues/11168

In order to avoid affecting build times when Zig is repeatedly invoked,
we only enable this check for "zig env" and "zig version"
2022-07-28 22:21:24 -07:00
Andrew Kelley
e6b3eae490
Merge pull request #11867 from nektro/patch-2
stage2: ensure builtin packages are always available
2022-07-28 15:20:49 -07:00
Veikka Tuominen
ece1d1daf4 CLI: add error for duplicate package 2022-07-28 15:20:01 -07:00