15853 Commits

Author SHA1 Message Date
Andrew Kelley
6afcaf4a08 stage2: fix the build for 32-bit architectures
* Introduce a mechanism into Sema for emitting a compile error when an
   integer is too big and we need it to fit into a usize.
 * Add `@intCast` where necessary
 * link/MachO: fix an unnecessary allocation when all that was happening
   was appending zeroes to an ArrayList.
 * Add `error.Overflow` as a possible error to some codepaths, allowing
   usage of `math.intCast`.

closes #9710
2021-11-21 19:43:08 -07:00
Andrew Kelley
96e5f661bd zig cc: add -fcolor-diagnostics and -fcaret-diagnostics integration
Closes #6290
2021-11-21 17:07:18 -07:00
Andrew Kelley
ceeb230c23 zig cc: add -ffunction-sections integration
Also update to latest LLVM 13 command line options.

See #6290
2021-11-21 17:01:07 -07:00
Trioct
b644d49365 Fix type error for u8 in writeIntSlice 2021-11-21 16:47:39 -05:00
J.C. Moyer
939f51aebb compiler_rt: export floorf, floor, and floorl
This fixes a stage1 linker error when compiling with VS2022 on Windows.
2021-11-21 16:44:21 -05:00
Dante Catalfamo
12140ead43 Change darwin c.VMIN -> c.V.MIN to match Linux 2021-11-21 16:43:16 -05:00
Jakub Konka
05330bbe0d stage2: ensure 16byte stack alignment on macOS x86_64 2021-11-21 20:43:10 +01:00
Jakub Konka
110c185886 stage2: add x86_64 NOP MIR inst and lowering
If we don't touch the stack, ellide `sub rsp, imm32` to `nop`.
2021-11-21 20:43:10 +01:00
Evan Haas
c6b4fe0066 translate-c: coerce boolean results to c_int when negated
Fixes #10175
2021-11-20 19:52:06 -05:00
Andrew Kelley
4e5a88b288 stage2: default dynamic libraries to be linked as needed
After this change, the default for dynamic libraries (`-l` or
`--library`) is to only link them if they end up being actually used.

With the Zig CLI, the new options `-needed-l` or `--needed-library` can
be used to force link against a dynamic library.

With `zig cc`, this behavior can be overridden with `-Wl,--no-as-needed`
(and restored with `-Wl,--as-needed`).

Closes #10164
2021-11-20 17:23:44 -07:00
Ali Chraghi
a699d678b2
add NotLink error (#9877)
Closes #9872

Co-authored-by: Ryan Liptak <squeek502@hotmail.com>
2021-11-20 15:49:22 -05:00
Evan Haas
3fefdc1a0b translate-c: Allow negative denominator in remainder (%) operator
Fixes #10176
2021-11-20 13:52:07 -05:00
joachimschmidt557
e8112f7744 stage2 RISCV64: implement basic function prologue and epilogue 2021-11-20 19:25:59 +01:00
Meghan
c84147f90d
std: add writer methods on all crypto.hash types (#10168) 2021-11-20 01:37:17 -08:00
Dante Catalfamo
54bcd1cd51
Add OpenBSD termios constants to std.c.openbsd (#10178) 2021-11-20 01:34:53 -08:00
Rohlem
a83fb9289f std.bounded_array: fix self parameter type in constSlice
Because `.buffer` is an inline array field, we actually require `self` to be passed as a pointer.
If the compiler decided to pass the object by copying, we would return a pointer to to-be-destroyed stack memory.
2021-11-20 02:35:36 -05:00
Andrew Kelley
e24dcd2707 std.builtin.StackTrace: format() workaround on freestanding
This whole thing needs to be reworked but for now at least don't cause a
compile error when building for a target that doesn't have stderr or
detectTTYConfig.
2021-11-19 19:15:14 -07:00
Jakub Konka
696e51be49 stage2: re-enable all tests
I've committed what I didn't want to by mistake...
2021-11-19 22:41:10 +01:00
Jakub Konka
ad5533fdfb stage2,x86_64: revert fixing callee preserved regs
This will require further rework in the codegen so reverting for now.
2021-11-19 22:18:56 +01:00
Jakub Konka
18a909f61d Merge branch 'g-w1-callee-preserved' 2021-11-19 20:30:20 +01:00
Jakub Konka
bc59a630ab stage2,x86_64: fix genBinMathOp and clarify callee-saved regs
Previously, we have confused callee-saved with caller-saved registers
(the actual register sets were swapped). This commit fixes that
for both `.x86` and `.x86_64` native backends.

This commit also fixes the register allocation logic in `genBinMathOp`
for `.x86_64` native backend where in a situation such that we require
to spill a register, we would end up spilling the register that is
already involved in the instruction as the other operand. In such a
case, we make a note of this and spill a subsequent register instead.
2021-11-19 20:01:35 +01:00
Jacob G-W
149bc79486 add tests for previous commit 2021-11-19 09:38:36 +01:00
Jacob G-W
8fc3a707a4 x86_64/Emit: implement restoring callee_preserved_registers 2021-11-19 09:38:36 +01:00
Jacob G-W
f950d763a1 stage2 x86_64 codegen: don't count return registers as callee-preserved 2021-11-19 09:38:36 +01:00
Jakub Konka
6cf8a49bb0 macho: sync .variable decl handling with elf linker 2021-11-18 21:41:44 +01:00
Jakub Konka
7747bf07c7 stage2: use correct register alias for mem operands
When loading/storing on the stack, use `registerAlias` to correctly
workout the size of the register and thus correctly select target
instruction.
2021-11-18 19:46:56 +01:00
Kenta Iwasaki
00966b7258 compiler_rt: disable spinlocks for atomic instrinsics for bpf
The BPF target does not support mutable global variables. Mark the BPF
target as a target that does not support atomic variables in order to
avoid including the global spinlock table provided in compiler_rt.
2021-11-18 13:16:35 -05:00
Felix "xq" Queißner
2fefd4ea8e Fixes invalid errno definition for ***-linux-android 2021-11-18 12:58:28 -05:00
Vincent Rischmann
3d528161c8 io_uring: implement register_files_update 2021-11-16 19:54:19 -05:00
joachimschmidt557
d94b032e92 stage2 ARM: Introduce MIR 2021-11-16 19:52:21 -05:00
Andrew Kelley
0e8673f534
Merge pull request #10152 from drew-gpf/master
C backend: fix most cast and all pointer+generics behavior tests
2021-11-16 19:50:39 -05:00
Andrew Kelley
09588c795c stage2: LLVM backend: memset to 0xaa for undefined stores
Also support `one` and `int_big_positive` tags for const pointers.
2021-11-16 17:46:39 -07:00
Drew P
68fe391de0 typo 2021-11-16 16:51:31 -07:00
Drew P
30ed91b7b9 fix tests failing on stage2 release modes due to setRuntimeSafety not being recognized 2021-11-16 16:51:31 -07:00
drew
a1d7604162 correct misnamed variables caused by copy-paste 2021-11-16 16:51:31 -07:00
drew
0249344a47 cast -> cast_llvm, cast_c -> cast (doesn't work on LLVM backend) 2021-11-16 16:51:31 -07:00
drew
f33af8f071 fix array airStoreUndefined for arrays 2021-11-16 16:51:31 -07:00
drew
cf99afc525 add generics behavior test
-airLoad and airStore now properly report an error if they are used with an array, instead of having the C compiler emit a vague error
-airStoreUndefined now works with array types
-structFieldPtr now works with array types, allowing generics' tests to pass
2021-11-16 16:51:31 -07:00
drew
3896de3078 simplify things 2021-11-16 16:51:31 -07:00
drew
0300ec4ef7 fix assumption where all positive big ints are unsigned 2021-11-16 16:51:31 -07:00
drew
89793bdfa7 add additional negative big int constant test case 2021-11-16 16:51:31 -07:00
drew
dffa6dcaf9 make it more clear we should do UB wrapping optimizations for ptr arithmetic 2021-11-16 16:51:31 -07:00
drew
ad4627ea3b small changes + align tests obviously shouldn't have passed 2021-11-16 16:51:31 -07:00
drew
34684725aa fmt 2021-11-16 16:51:31 -07:00
drew
9bf1681990 C backend: basic big ints, fix airPtrToInt, array references, pointer arithmetic UB with NULL, implement airPtrElemPtr/Val, fix redundant indirection/references with arrays
-add additional test cases that were found to be passing
-add basic int128 test cases which previously did not pass but weren't covered
-most test cases in cast.zig now pass
-i128/u128 or smaller int constants can now be rendered
-unsigned int constants are now always suffixed with 'u' to prevent random compile errors
-pointers with a val tag of 'zero' now just emit a 0 constant which coerces to the pointer type and fixes some warnings with ordered comparisons
-pointers with a val tag of 'one' are now casted back to the pointer type
-support pointers with a u64 val
-fix bug where rendering an array's type will emit more indirection than is needed
-render uint128_t/int128_t manually when needed
-implement ptr_add/sub AIR handlers manually so they manually cast to int types which avoids UB if the result or ptr operand is NULL
-implement airPtrElemVal/Ptr
-airAlloc for arrays will not allocate a ref as the local for the array is already a reference/pointer to the array itself
-fix airPtrToInt by casting to the int type
2021-11-16 16:51:31 -07:00
LemonBoy
952d865bd2 stage1: Fix caching of LLVM builtin fns
The cache entry must take into account the fact some functions operate on scalar types and some other on vectors of scalar types.

Fixes #10147
2021-11-16 16:35:56 -05:00
Jonathan Marler
9c1c1d478d add print field to RunStep
A new print field is added to RunStep that will control whether it prints the cmd before running it.  By default it will be set to builder.verbose which means it will print only if builder.verbose is true.
2021-11-16 16:35:12 -05:00
Marc Tiehuis
dcd88ae568 std/json: use bit-stack for nesting instead of large LLVM integer type
The stack has been adjusted so that instead of pushing to index 0 in the
integer we push to the current end/index of the underlying integer. This
means we don't require a shift for every limb after each push/pop and
instead only require a mask/or and add/sub on a single element of the array.

Fixes #5959.
2021-11-16 16:33:56 -05:00
Andrew Kelley
c587be78d7
Merge pull request #10016 from courajs/array-build-options
Various build options (OptionsStep) fixes
2021-11-16 16:31:46 -05:00
Andrew Kelley
85e427e4b2 stage2: equality compare optional with non-optional 2021-11-16 14:01:07 -07:00