70 Commits

Author SHA1 Message Date
Andrew Kelley
72404db31f stage1: update to LLVM 12 sret callsite requirements
Without this, the LLVM IR that zig generates cannot be compiled by LLVM.
2021-02-28 22:01:13 -07:00
LemonBoy
b706b9bce7 stage1: Fix emission of sret annotation for LLVM
LLVM12 deprecated `sret` and replaced it with the `sret(<Ty>)` form.

Closes #8075
2021-02-26 12:48:27 -08:00
Andrew Kelley
431801707f Revert "stage1: upgrade to new LLVM sret attribute requirement"
This reverts commit 685b5c26b703d54381a74b71361816ad85ec8584.

@LemonBoy has a better patch, so reverting this to merge that one.
2021-02-26 13:47:33 -07:00
Andrew Kelley
685b5c26b7 stage1: upgrade to new LLVM sret attribute requirement
LLVM 12 requires sret attributes to have the struct type as a parameter,
and provides no C function for supplying it. Therefore, we must add
another C++ wrapper API for adding the sret attribute.

Fixes ability to build from source in the llvm12 branch.
2021-02-26 13:32:04 -07:00
Andrew Kelley
0b58b61799 Merge remote-tracking branch 'origin/master' into llvm12
Conflicts:
 * src/clang.zig
 * src/llvm.zig
   - this file got moved to src/llvm/bindings.zig in master branch so I
     had to put the new LLVM arch/os enum tags into it.
 * lib/std/target.zig, src/stage1/target.cpp
   - haiku had an inconsistency with its default target ABI, gnu vs
     eabi. In this commit we make it gnu in both places to match the
     latest changes by @hoanga.
 * src/translate_c.zig
2021-02-25 21:04:23 -07:00
Michael Dusan
dc325669e3 fix to compile against 12.0.0-rc2 2021-02-25 19:41:30 -08:00
Andrew Kelley
0d4b6ac741 add LTO support
The CLI gains -flto and -fno-lto options to override the default.
However, the cool thing about this is that the defaults are great! In
general when you use build-exe in release mode, Zig will enable LTO if
it would work and it would help.

zig cc supports detecting and honoring the -flto and -fno-lto flags as
well. The linkWithLld functions are improved to all be the same with
regards to copying the artifact instead of trying to pass single objects
through LLD with -r. There is possibly a future improvement here as
well; see the respective TODOs.

stage1 is updated to support outputting LLVM bitcode instead of machine
code when lto is enabled. This allows LLVM to optimize across the Zig and
C/C++ code boundary.

closes #2845
2021-01-23 18:18:07 -07:00
Andrew Kelley
4d8c5dd4be stage1: add tsan LLVM passes when appropriate 2020-12-24 01:18:48 -07:00
Jakub Konka
1c40a4df09 Update zig_llvm.cpp and other bits
Include updates to corresponding zig sources

llvm commit b2851aea80e5a8f0cfd6c3c5a56a6b00fb28c6b6
2020-12-16 18:13:58 +01:00
Andrew Kelley
72f6c6e634 invoke LLD as a child process rather than a library
Closes #3825
2020-12-08 20:00:16 -07:00
Andrew Kelley
55ab50efbd Merge branch 'piepiepie' of https://github.com/LemonBoy/zig into pie
Conflicts:
 lib/std/dynamic_library.zig (fixed in this commit)
 src/all_types.hpp
 src/codegen.cpp
 src/link.cpp
 src/main.cpp

Will manually apply the diffs to these deleted files to the new zig
code in a followup commit.
2020-11-22 12:39:44 -07:00
LemonBoy
0d6a7088dc stage1: Implement Add/Mul reduction operators 2020-11-01 14:30:31 -07:00
LemonBoy
22b5e47839 stage1: Implement @reduce builtin for vector types
The builtin folds a Vector(N,T) into a scalar T using a specified
operator.

Closes #2698
2020-10-05 04:51:45 -04:00
Andrew Kelley
ada19c498d stage2: building DLL import lib files 2020-09-28 19:20:58 -07:00
Andrew Kelley
c58e9951ef revert bogus enum keywords in zig_llvm.h 2020-09-14 10:31:34 -07:00
Andrew Kelley
c903dad915 fix zig_llvm.h not complying with C 2020-09-12 00:50:17 -07:00
Andrew Kelley
11b50e3ad8 change the default ABI of riscv64-linux-musl
Before, this would cause a link failure when mixing Zig and C code for
RISC-V targets.

Now, the ABIs match and Zig and C code can be mixed successfully.

I will file a follow-up issue for the ability to deal more explicitly
with ABIs.

closes #4863
2020-04-03 13:13:09 -04:00
Andrew Kelley
f33bf48af7
Merge remote-tracking branch 'origin/master' into llvm10 2020-02-25 16:30:40 -05:00
Andrew Kelley
61c67a9833
remove sub-arch from stage1 2020-02-21 11:47:34 -05:00
Andrew Kelley
d7968c6d33
improvements which allow zig to emit multiple things at once
example: zig build-obj test.zig -femit-llvm-ir -femit-asm

this will generate all three: test.o test.s test.ll
2020-02-18 21:59:43 -05:00
Andrew Kelley
79fb486017
link: update to llvm 10 API 2020-01-23 17:28:13 -05:00
Andrew Kelley
fb8e681ea8
update zig_llvm.h and zig_llvm.cpp to llvm 10 2020-01-22 18:43:30 -05:00
LemonBoy
435528a7c5 Use the LLVM C++ API 2020-01-02 18:57:09 +01:00
Vexu
ab7fc33c83
add zig llvm wrapper for atomicrmw 2019-12-23 11:55:00 +02:00
LemonBoy
333eec557f Initial support for static PIE executables 2019-12-21 17:34:05 +01:00
LemonBoy
f1407b4b7e Generate the fn pointers into the correct address space
Fixes #3645
2019-12-15 14:42:53 -05:00
Andrew Kelley
1f602fe8c5
implement @call
closes #3732
2019-12-05 17:07:15 -05:00
Vexu
8edf27343f
self hosted compiler: fix zig_llvm.h function signature 2019-11-07 10:29:44 +02:00
LemonBoy
2b624fea84 Add dlltool functionality
Don't need no patched lld --kill-at behaviour now.
2019-10-12 10:56:16 +02:00
LemonBoy
093ffe9f16 Correct stack alignment for new stack 2019-09-21 11:39:50 +02:00
Andrew Kelley
6529658ad8
Merge remote-tracking branch 'origin/master' into llvm9 2019-08-16 16:43:56 -04:00
Andrew Kelley
7b3686861f
@frameSize works via PrefixData 2019-07-25 22:24:01 -04:00
Andrew Kelley
ead2d32be8
calling an inferred async function 2019-07-25 00:03:06 -04:00
Andrew Kelley
2c1e955de7
always give the type to byval attribute 2019-07-20 13:32:50 -04:00
Andrew Kelley
8f92a49dfd
update to llvm9 trunk 2019-07-16 22:23:48 -04:00
Timon Kruiper
bbc0d440b8 Added ZigLLVMCreateTargetMachine and pass function-sections flag
Also added extra cache line

Added the ZigLVVMCreateTargetMachine to self hosted zig code
2019-07-02 19:54:29 +02:00
Timon Kruiper
7586f613d5 Added function-section functionality 2019-07-01 17:49:08 +02:00
LemonBoy
80cd142c96 Propagate DIFlags to LLVM 2019-06-04 09:05:33 +02:00
Andrew Kelley
2dcf1a2392
Merge remote-tracking branch 'origin/master' into llvm8 2019-02-28 09:19:18 -05:00
Andrew Kelley
ade10387a5
breaking changes to the way targets work in zig
* CLI: `-target [name]` instead of `--target-*` args.
   This matches clang's API.
 * `builtin.Environ` renamed to `builtin.Abi`
   - likewise `builtin.environ` renamed to `builtin.abi`
 * stop hiding the concept of sub-arch. closes #1526
 * `zig targets` only shows available targets. closes #438
 * include all targets in readme, even those that don't
   print with `zig targets` but note they are Tier 4
 * refactor target.cpp and make the naming conventions
   more consistent
 * introduce the concept of a "default C ABI" for a given
   OS/Arch combo. As a rule of thumb, if the system compiler
   is clang or gcc then the default C ABI is the gnu ABI.
2019-02-26 15:58:10 -05:00
Andrew Kelley
06be65a602
fix vector debug info tripping LLVM assertion 2019-02-04 22:16:16 -05:00
Andrew Kelley
d974afde1d
fix vector debug info tripping LLVM assertion 2019-02-04 22:14:35 -05:00
Andrew Kelley
f32f7a937f
Merge remote-tracking branch 'origin/master' into llvm8 2019-02-04 21:26:50 -05:00
Andrew Kelley
545064c1d9
introduce vector type for SIMD
See #903

 * create with `@Vector(len, ElemType)`
 * only wrapping addition is implemented

This feature is far from complete; this is only the beginning.
2019-01-30 23:39:25 -05:00
Andrew Kelley
1411df4e27 update to llvm8 trunk. all tests passing 2019-01-24 09:31:00 -05:00
Andrew Kelley
75d142c3c7 llvm8: fix ZigLLVMCreateFunction 2018-12-23 18:22:30 -05:00
Andrew Kelley
16b8467a5e llvm8: fix build errors 2018-12-23 17:36:41 -05:00
Andrew Kelley
5b96cc236c update to build against llvm trunk 2018-11-05 11:17:35 -05:00
Andrew Kelley
f8d6f5daff Merge remote-tracking branch 'origin/master' into llvm8 2018-11-05 10:56:42 -05:00
Andrew Kelley
5a3c02137e
support building static libraries
closes #1493
closes #54
2018-10-09 13:15:14 -04:00