18336 Commits

Author SHA1 Message Date
Andrew Kelley
b33c8b0b06 Sema: comptime float negation supports negative zero
When handling the `negate` ZIR instruction, Zig now checks for a
comptime operand and handles it as a special case rather than lowering
it as `0 - x` so that the expression `-x` where `x` is a floating point
value known at compile-time, will get the negative zero bitwise
representation.
2022-05-10 21:50:55 -07:00
Andrew Kelley
f5edf78eea
Merge pull request #10143 from nuald/single-threaded-cpp1
Normalized C++ compilation options for single-threaded targets
2022-05-10 23:38:44 -04:00
Andrew Kelley
458943e324
Merge pull request #9831 from mathetake/llvmvisibility
Stage1: Add Visibility field to ExportOptions.
2022-05-10 22:04:30 -04:00
Andrew Kelley
ed63d6c7fd
Merge pull request #10428 from mrakh/rand_float_improvement
Improve stdlib's random float generation
2022-05-10 22:03:29 -04:00
Andrew Kelley
7bedeb9659 std.rand: move tests to a separate test file 2022-05-10 19:02:03 -07:00
Mahdi Rakhshandehroo
550888e2ac std: improve random float generation 2022-05-10 18:50:12 -07:00
Silver
e0a514df41 std: make IntegerBitSet and ArrayBitSet have defined memory layout
This is useful for wrapping C libraries and native interfaces that make use of bit sets
2022-05-10 21:30:58 -04:00
Andrew Kelley
45415093c6 reduce the scope of this branch
* back out the changes to RunStep
 * move the disabled test to the .cpp code and avoid a confusing
   name-collision with the _LIBCPP macro prefix
 * fix merge conflict with the edits to the same test that ensure global
   initializers are called.

Now this branch is only concerned with single-threaded targets and
passing the correct macro defines to libc++.
2022-05-10 17:31:54 -07:00
Andrew Kelley
1ff9a18cd3 stage1: back out the broken visibility changes
```
$ valgrind ./zig test ../test/behavior.zig -target powerpc-linux-musl -lc -I../test
==2828778== Invalid read of size 1
==2828778==    at 0x6EA0265: LLVMSetVisibility (in /home/andy/Downloads/zig/build/zig)
==2828778==    by 0x1BCE60B: do_code_gen(CodeGen*) (codegen.cpp:9031)
==2828778==    by 0x1BD51E2: codegen_build_object(CodeGen*) (codegen.cpp:10610)
==2828778==    by 0x1BA5C17: zig_stage1_build_object (stage1.cpp:132)
==2828778==    by 0xE61E24: Module.build_object (stage1.zig:149)
==2828778==    by 0xC3D4CE: Compilation.updateStage1Module (Compilation.zig:5025)
==2828778==    by 0xC3117E: Compilation.performAllTheWork (Compilation.zig:2691)
==2828778==    by 0xC2A3ED: Compilation.update (Compilation.zig:2098)
==2828778==    by 0xBB9D1F: main.updateModule (main.zig:3104)
==2828778==    by 0xB16B75: main.buildOutputType (main.zig:2793)
==2828778==    by 0xAD0526: main.mainArgs (main.zig:225)
==2828778==    by 0xACFCB9: main (stage1.zig:48)
```

Since the plan is to ship stage3 for Zig 0.10.0, the stage1
implementation of this hardly matters.
2022-05-10 16:43:51 -07:00
Alexander Slesarev
3997828a61 Added _LIBCPP_HAS_NO_THREADS for single_threaded binaries linked with libcxx.
Fixed single-threaded mode for Windows.
2022-05-10 16:40:48 -07:00
Andrew Kelley
c4c5020f02 fixups to the previous commit
* Rename std.builtin.GlobalVisibility to std.builtin.SymbolVisibility
 * Add missing compile error. From the LLVM language reference: "A
   symbol with internal or private linkage must have default
   visibility."
2022-05-10 15:44:40 -07:00
Takeshi Yoneda
9654a54d4a Add Visibility field to ExportOptions.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-05-10 15:21:48 -07:00
Kirk Scheibelhut
67c4b16d6e docs: T.bit_count -> @typeInfo(T).Int.bits
bit_count was removed in #6246
2022-05-10 17:28:44 -04:00
Frank Denis
aaf4011c2c Typo 2022-05-10 15:57:46 +02:00
Brian Gold
52651ae7a0 io_uring cancel test must tolerate CQ reordering
Fixes #11382. Tested on ArchLinux 5.17.5-arch1-1.
2022-05-10 11:49:41 +02:00
Luuk de Gram
62453496ba wasm: Write nops for padding debug info 2022-05-09 18:51:46 +02:00
Luuk de Gram
2ae2ac33d9 wasm: Emit debug sections
This commit adds the ability to emit the following debug sections:
.debug_info
.debug_abbrev
.debug_line
.debug_str

Line information and files are now being loaded correctly by browser debuggers.
2022-05-09 18:51:46 +02:00
Luuk de Gram
9b6b7034c2 wasm: Flush debug information + commit decl
This implements parts to commit a decl's debug information into
a linear memory buffer. The goal is to write this buffer at once
after we finished linking.
2022-05-09 18:51:46 +02:00
Luuk de Gram
f760272200 wasm: Debug info for lines + pro/epilogue
Maps lines and columns between wasm bytecode and Zig source code.
While this supports prologue and epilogue information, we need to add
support for performing relocations as the offsets are relative to the code section,
which means we must relocate it according to the atom offset's offset while keeping function count
in mind as well (due to leb128 encoding).
2022-05-09 18:51:46 +02:00
Luuk de Gram
d46cdb5396 wasm: Debug information for locals
Implements very basic debug information for locals.
For now it only implements debug info when the variable is stored within a
Wasm local. The goal is to support those that live in the data section (virtual stack).
2022-05-09 18:51:46 +02:00
Luuk de Gram
33b2f4f382 wasm: Implement debug info for parameters 2022-05-09 18:51:46 +02:00
Luuk de Gram
8e1c220be2 wasm: Add basic debug info references 2022-05-09 18:51:46 +02:00
Helio Machado
941b6830b1
std.crypto: generate AES constants at compile time (#11612)
* std/crypto: generate AES constants at compile time

* Apply suggestions from code review

Co-authored-by: Frank Denis <124872+jedisct1@users.noreply.github.com>

* Update lib/std/crypto/aes/soft.zig

* Separate encryption and decryption tables

* Run `zig fmt`

* Increase branch quota and remove redundant align

* Update lib/std/crypto/aes/soft.zig

Co-authored-by: Frank Denis <124872+jedisct1@users.noreply.github.com>

* Rename identifiers and simplify dataflow

* Increase branch quota (again) and fix comment

Co-authored-by: Frank Denis <124872+jedisct1@users.noreply.github.com>
2022-05-09 18:50:01 +02:00
Evan Haas
94b9bcd034 stdlib: escape backslashes and double quotes in Builder response file
Fixes #11595
2022-05-09 18:42:42 +03:00
Andrew Kelley
d7f8368da8
Merge pull request #11609 from ziglang/win-compiler-rt
compiler-rt: avoid symbol collisions with Windows libc
2022-05-08 19:29:21 -04:00
Hannes Bredberg
ea3f5905f0 Add Win64 calling convention
Closes ziglang/zig#11585
2022-05-08 16:28:10 -04:00
Andrew Kelley
cd019ee502 compiler_rt: avoid weak aliases on Windows
When exporting math functions for Windows, we provide weak exports of
'l' variants rather than weak aliases. We still use aliases on other
operating systems so that the 'l' variants have one less jump
instruction in this case.
2022-05-08 13:06:21 -07:00
Andrew Kelley
6fde2fcd51 allow in-memory coercion of differently-named floats with same bits
For example, this allows passing a `*c_longdouble` where a `*f80` is
expected, provided that `c_longdouble` maps to `f80` for this target.
2022-05-08 13:05:16 -07:00
Jakub Konka
9416b4d993
Merge pull request #11608 from ziglang/stage2-regalloc 2022-05-08 11:20:14 +02:00
Andrew Kelley
663b67783e compiler-rt: avoid symbol collisions with Windows libc
closes #11600
2022-05-07 17:44:49 -07:00
Andrew Kelley
aa05cd4809 CI: fix universal libc step name
This was a merge conflict that went undetected.
2022-05-07 17:44:37 -07:00
Jakub Konka
f161d3875a
Merge pull request #11605 from Luukdegram/wasm-mul-overflow
stage2: wasm - Improve `@mulWithOverflow` implementation
2022-05-07 23:30:08 +02:00
Jakub Konka
6bf67eada4 arm: lock dest register in shl_overflow so that we do not spill it
Nerf two tests - they will require further investigation, but arm
now passes all tests with the safety PR.
2022-05-07 22:53:17 +02:00
Jakub Konka
756ddf0925 arm: fix CF flags spilling and implement genSetStack for reg with overflow flags 2022-05-07 22:35:41 +02:00
Luuk de Gram
a110979582
stage2: Split @mulWithOverflow tests 2022-05-07 20:02:02 +02:00
Luuk de Gram
ad4f0dda8b
wasm: Fix @floatToInt and split overflow ops
As we now store negative signed integers as two's complement,
we must also ensure that when truncating a float, its value is wrapped
around the integer's size.

This also splits `@mulWithOverflow` into its own function to make
the code more maintainable and reduce branching.
2022-05-07 17:04:19 +02:00
Luuk de Gram
0c51e703f1
wasm: @addWithOverflow for bitsize 32 2022-05-07 14:24:18 +02:00
Jakub Konka
f57b059e58 regalloc: refactor locking multiple registers at once 2022-05-07 13:27:11 +02:00
Jakub Konka
bf11cdc9d8 x64: refactor code to avoid stage1 sema limitations 2022-05-07 13:19:53 +02:00
Jakub Konka
197c2a465f regalloc: rename freeze/unfreeze to lock/unlock registers 2022-05-07 10:46:05 +02:00
Andrew Kelley
e8c85450fe
Merge pull request #11592 from ziglang/stage3-macos-linker
Sema: solve a false positive "depends on itself"
2022-05-07 04:38:19 -04:00
Jakub Konka
43a627927f x64: fix misused register locks 2022-05-07 10:31:08 +02:00
Andrew Kelley
ec95e00e28 flatten lib/std/special and improve "pkg inside another" logic
stage2: change logic for detecting whether the main package is inside
the std package. Previously it relied on realpath() which is not portable.
This uses resolve() which is how imports already work.

 * stage2: fix cleanup bug when creating Module
 * flatten lib/std/special/* to lib/*
   - this was motivated by making main_pkg_is_inside_std false for
     compiler_rt & friends.
 * rename "mini libc" to "universal libc"
2022-05-06 22:41:00 -07:00
Andrew Kelley
3b60ab4872 stage2: fix std lib tests always filtering out all tests 2022-05-06 22:41:00 -07:00
Andrew Kelley
f034cef262 link/MachO: use const instead of var and limit scope of vars 2022-05-06 22:41:00 -07:00
Andrew Kelley
9afc4fe0e2 Sema: solve a false positive "depends on itself"
This improves the ABI alignment resolution code.

This commit fully enables the MachO linker code in stage3. Note,
however, that there are still miscompilations in stage3.
2022-05-06 22:40:57 -07:00
Andrew Kelley
0df28f9d45
Merge pull request #11492 from ziglang/ci-stage3-behavior
CI: add non-LLVM backends to the test matrix
2022-05-06 22:51:55 -04:00
Jakub Konka
efeb031b79 macho: skip cache if cache_mode is .whole 2022-05-07 01:52:00 +02:00
Jakub Konka
a2dbe6589e macho: share traditional codepaths with stage2+llvm backend 2022-05-07 01:44:26 +02:00
Andrew Kelley
a2b8a9756f CI: macos: disable stage2 test-behavior
stage2 on macOS is not yet capable of passing these tests. Such
improvements will be done in a follow-up change.
2022-05-06 16:26:04 -07:00