joachimschmidt557
a7da90071e
stage2: fix bug in genArg
...
When an argument is unused in the function body, still increment
arg_index so we still select the correct arguments in the args slice.
2021-01-10 00:41:02 -08:00
Andrew Kelley
29928af600
Merge pull request #7729 from jayschwa/remove-deprecated-stream
...
Remove deprecated stream aliases
2021-01-09 13:04:08 -08:00
Jay Petacat
a0ad2dee6a
builtin: Add zig_version
...
This will enable code to perform version checks and make it easier to
support multiple versions of Zig.
Within the SemVer implementation, an intermediate value needed to be
coerced to a slice to workaround a comptime bug.
Closes #6466
2021-01-09 12:50:39 -08:00
Andrew Kelley
5c49a137d5
Merge pull request #7725 from FireFox317/even-more-llvm
...
stage2: initial implementation of control flow in LLVM backend + TZIR printing
2021-01-09 12:32:10 -08:00
xackus
e4b8148e9c
Fix system library path detection on linux
...
Uses the NativeTargetInfo results instead of std.Target.current.
2021-01-08 20:07:59 -07:00
LemonBoy
eb696e453f
stage2: Implicitly enable --eh_frame_hdr when compiling c/c++ files
...
Matches what Clang/GCC driver do.
Closes #7711
2021-01-08 19:01:05 -08:00
Sobeston
95e66a915b
added mem.containsAtLeast
2021-01-08 18:12:30 -08:00
Jakub Konka
7e0e27e738
libstd: add missing MachO rebase opcodes in macho.zig
2021-01-08 23:41:51 +01:00
Jay Petacat
e72472d953
io: FindByteOutStream to FindByteWriter
...
See #4917
2021-01-08 16:54:56 -05:00
Jay Petacat
1595ce273e
Remove deprecated stream aliases
2021-01-08 16:54:56 -05:00
Timon Kruiper
56c059077c
stage2: add initial impl of control flow in LLVM backend
...
The following TZIR instrutions have been implemented in the backend:
- all cmp operators (lt, lte, gt, gte, eq, neq)
- block
- br
- condbr
The following LLVMIR is generated for a simple assert function:
```
define void @assert(i1 %0) {
Entry:
%1 = alloca i1, align 1
store i1 %0, i1* %1, align 1
%2 = load i1, i1* %1, align 1
%3 = xor i1 %2, true
br i1 %3, label %Then, label %Else
Then: ; preds = %Entry
call void @llvm.debugtrap()
unreachable
Else: ; preds = %Entry
br label %Block
Block: ; preds = %Else
ret void
}
```
See tests for more examples.
2021-01-08 19:30:52 +01:00
Timon Kruiper
3715ed7b54
stage2: implement TZIR printing for block and condbr
...
Zig code:
```
fn assert(ok: bool) void {
if (!ok) unreachable;
}
```
TZIR:
```
Module.Function(name=assert):
@0: void = {};
%0: bool = arg(ok)
%1: void = dbg_stmt()
%2: void = block(
%3: bool = not(%0)
%4: noreturn = condbr(%3,
then:
%5: void = breakpoint()
%6: noreturn = unreach()
else:
%7: noreturn = br(%2, @0)
)
)
%8: noreturn = retvoid()
```
2021-01-08 12:13:27 +01:00
Julius Putra Tanu Setiaji
2b3b355a23
Add compileError message for StringHashMap in AutoHashMap
2021-01-07 23:51:53 -08:00
Andrew Kelley
3fdffe85c0
Merge pull request #7720 from Snektron/sockopt
...
Some sockopt stuff
2021-01-07 23:50:34 -08:00
Jonathan Marler
31802c6c68
remove z/Z format specifiers
...
Zig's format system is flexible enough to add custom formatters. This PR removes the new z/Z format specifiers that were added for printing Zig identifiers and replaces them with custom formatters.
2021-01-07 23:49:22 -08:00
Jay Petacat
a9b505fa77
Reduce use of deprecated IO types
...
Related: #4917
2021-01-07 23:48:58 -08:00
Michael Dusan
8e9a1ac364
builder: propagate env_map for child processes
2021-01-07 23:48:24 -08:00
Jakub Konka
70771283c5
Want native headers when linking with frameworks
...
This PR ensures we use system libc headers and system search paths for
framework headers when linking against frameworks and compiling natively
on macOS.
2021-01-07 23:47:37 -08:00
Robin Voetter
ec7adeda2b
Add EPERM to std.os.setsockopt
2021-01-08 02:34:42 +01:00
Robin Voetter
83fad7d4f7
Add IP_ constants
2021-01-08 01:35:52 +01:00
Andrew Kelley
c7666ff885
ci: import the update-download-page from www repo
2021-01-07 16:49:13 -07:00
Andrew Kelley
d8eba037a4
ci: fix path to update-download-page.zig script
2021-01-07 15:49:43 -07:00
Andrew Kelley
aa2422e830
ci: add github.com's public key for the ssh clone
2021-01-07 12:28:55 -07:00
Timon Kruiper
36950815a4
stage2 test: make sure to pass the dynamic linker to Compilation
...
Because this was not set, the `-dynamic-path` argument was not passed
to LLD when linking an ELF binary. This would still generate a valid glibc
binary, however when executing would result in a segfault.
2021-01-07 11:37:52 +01:00
Andrew Kelley
87aa052e23
ci: pass --override-lib-dir to emit std lib docs
...
Otherwise we get errors from conflicting std libs.
2021-01-07 02:58:27 -07:00
Andrew Kelley
ee1b370404
ci: don't use ninja on linux
...
I got this error when re-running the cmake line setting
-DZIG_EXECUTABLE:
```
ninja: warning: multiple rules generate zig1.o. builds involving
this target will not be correct; continuing anyway
[-w dupbuild=warn]
```
But it works fine with make.
2021-01-07 00:38:48 -07:00
Andrew Kelley
a279cf81b2
ci: add missing target/mcpu args to zig cc
...
In the previous commit, I forgot to add these.
2021-01-07 00:18:28 -07:00
Andrew Kelley
ce5222d945
ci: rework linux script
...
* no longer depend on apt.llvm.org, instead we rely on a zig-bootstrap
tarball with pre-built Zig, LLVM, LLD, and Clang. Similar to the
Windows Dev Kit but for Linux. This also makes the script no longer
depend on Docker, libxml2, or GCC.
* remove bash retry logic; it was only needed for flaky apt.llvm.org
and isn't needed for the other resources we download.
* build and upload the experimental std lib automatically generated
docs. langref.html is moved to docs/langref.html because the std lib
docs are in docs/std/.
* the superfluous "zig" directory in $prefix/lib/zig/std/std.zig is
removed from the tarball.
* update_download_page makes a commit in the www.ziglang.org repository
updating data/releases.json so that repository can manage deploys.
2021-01-06 23:40:17 -07:00
Jonathan Marler
f1ef0a80f1
fix LRESULT and LPARAM typedefs
...
LRESULT and LPARAM are currently typedef'd as ?*c_void, however, they are supposed to be typedef'd as LONG_PTR which is equivalent to isize in Zig.
2021-01-06 16:41:40 -08:00
Andrew Kelley
5ee0431527
stage2: update to new ArrayListHashMap API
2021-01-06 17:40:25 -07:00
Andrew Kelley
2f58efcc1f
std.SpinLock: flatten and remove init/deinit
...
structs which are intended to be directly initialized and support static
initialization should not have init/deinit methods.
2021-01-06 17:36:06 -07:00
Andrew Kelley
d7d905696c
Merge pull request #7622 from tetsuo-cpp/array-hash-map-improvements
...
std: Support equivalent ArrayList operations in ArrayHashMap
2021-01-06 16:32:23 -08:00
Andrew Kelley
76870a2265
Merge pull request #7700 from FireFox317/more-stage2-stuff-llvm
...
stage2: improvements to LLVM backend
2021-01-06 16:06:32 -08:00
BinaryWarlock
148c887ace
spinlock: Default SpinLock.state to .Unlocked to allow default struct initialization
...
std.Mutex, which is struct initialized, is possibly defined to be std.SpinLock.
2021-01-06 15:54:30 -08:00
Andreas Karlsson
50af87a9e3
Fix example code in comments for asc and desc
2021-01-06 15:53:53 -08:00
joachimschmidt557
be6ac82ee1
stage2 ARM: fix stack offsets for genSetReg and genSetStack
2021-01-06 15:53:10 -08:00
joachimschmidt557
480d6182ad
stage2 ARM: fix offsets in exitlude jump relocations
2021-01-06 15:53:10 -08:00
Frank Denis
5afd6204e8
Azure CI: update MSYS version
2021-01-06 15:52:34 -08:00
Andrew Kelley
efe94a9a12
stage2: C backend: support unused Decls
2021-01-06 16:47:09 -07:00
Timon Kruiper
b1cfa923be
stage2: rename and move files related to LLVM backend
2021-01-06 10:52:20 +01:00
Timon Kruiper
31d1ec4c2f
stage2: make use of llvm.Context in LLVM backend
...
This for example allows for multiple LLVM instances to run in parallel.
Also rename some functions in llvm_bindings.zig.
Fixes #7688
2021-01-06 10:52:20 +01:00
Timon Kruiper
5d5db833f2
stage2: hoist alloca instructions to top of function in LLVM backend
...
This way the generated code only has to setup the stack size at the
beginning of a function and this improves codegen.
Fixes #7689
```
fn foo() void {}
export fn hello(z: i8) void {
var x: i16 = undefined;
foo();
var y: i32 = 1;
y += z;
}
```
llvm-ir:
```
define void @hello(i8 %0) {
Entry:
%1 = alloca i8, align 1
%2 = alloca i16, align 2
%3 = alloca i32, align 4
store i8 %0, i8* %1, align 1
%4 = load i8, i8* %1, align 1
store i16 undef, i16* %2, align 2
call void @foo()
store i32 1, i32* %3, align 4
%5 = load i32, i32* %3, align 4
%6 = sext i8 %4 to i32
%7 = add nsw i32 %5, %6
store i32 %7, i32* %3, align 4
ret void
}
```
2021-01-06 10:52:20 +01:00
Timon Kruiper
1149cd593e
stage2: rename *const llvm.ValueRef to *const llvm.Value in LLVM backend
...
The same has been done for all the other LLVM types.
2021-01-06 10:52:19 +01:00
Timon Kruiper
70f6d16ae2
stage2: add initial impl for generating global decls in LLVM backend
...
Also adds support for extern functions, simple pointer and simple array
types and values.
A simple hello world now compiles:
`zig build-exe example.zig -fLLVM -lc`
```
extern fn puts(s: [*:0]const u8) c_int;
export fn main() c_int {
_ = puts("hello world!");
return 0;
}
```
2021-01-06 10:52:07 +01:00
Andrew Kelley
91e3431d4a
stage2 test harness: don't try to run non-native C backend tests
2021-01-05 20:44:19 -07:00
g-w1
ab5f7b5156
stage2: add compile log statement
2021-01-05 18:43:41 -07:00
Andrew Kelley
38572ee894
Merge branch 'stage2-rework-cbe'
...
Reworks the C backend and -femit-h to properly participate in
incremental compilation.
closes #7602
2021-01-05 17:42:16 -07:00
Andrew Kelley
3e39d0c44f
minor fixups from moving identifiers and files around
2021-01-05 17:41:22 -07:00
Andrew Kelley
1a2dd85570
stage2: C backend: re-implement emit-h
...
and also mark functions as `extern "C"` as appropriate to support c++
compilers.
2021-01-05 17:41:14 -07:00
Andrew Kelley
cd95444e47
stage2: C backend: remove format() hackery
...
All C backend tests passing now, except for emit-h tests. Next task in
the branch is to restore emit-h.
2021-01-05 17:41:14 -07:00