Commit Graph

61 Commits

Author SHA1 Message Date
LemonBoy
2f041239cb Always initialize the TLS 2019-05-07 13:09:20 +02:00
LemonBoy
d8ab301aa8 std: Implement TLS support for Linux
Tested on x86_64, i386, ARM, AARCH64
2019-05-07 13:09:18 +02:00
Shritesh Bhattarai
f5d84250a3 wasi: switch to "standard" wasi_unstable module fn 2019-04-15 18:44:33 -04:00
Shritesh Bhattarai
fe9cd0b4bc wasi: use __wasi_proc_exit instead of posix.exit 2019-04-13 21:36:53 -05:00
Shritesh Bhattarai
72bcd5a4a5 WIP: hello world 2019-04-13 15:15:39 -05:00
Andrew Kelley
e4d595a8ba
fix thread local variables for non- position independent code
This fixes comes thanks to Rich Felker from the musl libc project,
who gave me this crucial information:

"to satisfy the abi, your init code has to write the same value
to that memory location as the value passed to the [arch_prctl]
syscall"

This commit also changes the rules for when to build statically
by default. When building objects and static libraries, position
independent code is disabled if no libraries will be dynamically
linked and the target does not require position independent code.

closes #2063
2019-04-04 01:08:26 -04:00
Shawn Landden
65e234adfd fix build on arm64 2019-03-27 01:14:29 +00:00
Andrew Kelley
67b4de33d2
compile error for import outside package path
closes #2024

there's a new cli option `--main-pkg-path` which you can use to choose
a different root package directory besides the one inferred from the
root source file

and a corresponding build.zig API:
foo.setMainPkgPath(path)
2019-03-02 10:38:27 -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
00d8f4a1bb
introduce std.debug.captureStackTrace
and fix the implementation of writeStackTrace
it was printing the first frame in the wrong place
2019-02-23 13:19:06 -05:00
Andrew Kelley
89ffb58197 implement Thread Local Storage on Windows 2019-02-06 18:32:41 -05:00
Andrew Kelley
d2602b442e
require running std lib tests coherently
this should actually improve CI times a bit too

See the description at the top of std/os/startup.zig (deleted in this
commit) for a more detailed understanding of what this commit does.
2019-02-06 14:32:20 -05:00
Andrew Kelley
b1775ca168
thread local storage working for linux x86_64 2019-02-06 13:48:04 -05:00
Marcio Giaxa
1fc56b82ad freebsd: link against libc
Since the stable kernel ABI is through libc #1759
2018-12-19 18:42:00 -02:00
Andrew Kelley
4dafdc00d5
zig fmt 2018-11-19 17:28:18 -05:00
Greg V
f3bc1c38bf Specify 16-byte stack alignment in _start on FreeBSD 2018-10-20 15:21:35 +03:00
Marc Tiehuis
19659c3bd3 freebsd: Fix argc resolution in _start
FreeBSD appears to use rdi instead of rsp as in other posix systems.
According to some loose documentation, x86 passes values on the stack,
so amd64 freebsd may be the only exception.
2018-10-20 15:15:01 +03:00
Andrew Kelley
84690ee05e
std/special/bootstrap: inline some functions to improve stack traces 2018-10-09 13:16:50 -04:00
Shawn Landden
17cb69cebc fix elf auxv handling
Auxillery vectors are not guaranteed to be in any order, this
just happens to work on x86_64.
2018-09-08 14:47:21 +00:00
Shawn Landden
342cff28f5 initial arm64 support 2018-09-08 03:52:28 +00:00
Andrea Orru
d2f5e57b68 Merge branch 'master' into zen_stdlib 2018-08-06 01:43:19 -04:00
Andrew Kelley
7912061226 remove integer and float casting syntax
* add `@intCast`
 * add `@floatCast`
 * add `@floatToInt`
 * add `@intToFloat`

See #1061
2018-06-17 02:57:07 -04:00
Andrew Kelley
ec1b6f6673
breaking syntax change: ??x to x.? (#1095)
See #1023

This also renames Nullable/Maybe to Optional
2018-06-09 23:42:14 -04:00
Andrew Kelley
bd13e757e7 disable deref syntax for unknown length pointers
See #770
2018-06-05 23:26:43 -04:00
Andrew Kelley
96164ce613 disallow single-item pointer indexing
add pointer arithmetic for unknown length pointer
2018-06-04 01:39:57 -04:00
Andrew Kelley
fcbb7426fa use * for pointer type instead of &
See #770

To help automatically translate code, see the
zig-fmt-pointer-reform-2 branch.

This will convert all & into *. Due to the syntax
ambiguity (which is why we are making this change),
even address-of & will turn into *, so you'll have
to manually fix thes instances. You will be guaranteed
to get compile errors for them - expected 'type', found 'foo'
2018-05-31 17:28:07 -04:00
Andrew Kelley
0c16cd2d0e run zig fmt on the codebase
See #1003
2018-05-29 04:23:38 -04:00
Andrew Kelley
ac4d55dec1 behavior tests passing with new pointer deref syntax 2018-05-01 01:53:04 -04:00
Andrew Kelley
21767144fc linux: support VDSO for clock_gettime
also fix a compiler crash when using cmpxchg with nullable pointer
2018-04-22 18:11:50 -04:00
Andrea Orru
b01c5a95c4 Update zen library 2018-04-11 00:31:32 -07:00
Andrea Orru
43cdfa275a Zen specific hacks 2018-03-20 16:09:30 -04:00
Andrea Orru
d0621391bc zen-specific: main -> _start 2018-03-10 16:59:28 -08:00
Andrew Kelley
0d5ff6f462 error sets - most tests passing 2018-02-08 02:08:45 -05:00
Andrew Kelley
3671582c15 syntax: functions require return type. remove ->
The purpose of this is:

 * Only one way to do things
 * Changing a function with void return type to return a possible
   error becomes a 1 character change, subtly encouraging
   people to use errors.

See #632

Here are some imperfect sed commands for performing this update:

remove arrow:

```
sed -i 's/\(\bfn\b.*\)-> /\1/g' $(find . -name "*.zig")
```

add void:

```
sed -i 's/\(\bfn\b.*\))\s*{/\1) void {/g' $(find ../ -name "*.zig")
```

Some cleanup may be necessary, but this should do the bulk of the work.
2018-01-25 04:10:11 -05:00
Andrew Kelley
7b57454cc1 clean up error return tracing
* error return tracing is disabled in release-fast mode
 * add @errorReturnTrace
 * zig build API changes build return type from `void` to `%void`
 * allow `void`, `noreturn`, and `u8` from main. closes #535
2018-01-15 00:01:02 -05:00
Andrea Orru
98a95cc698 exit, createThread for zen 2018-01-08 12:16:23 -05:00
Andrew Kelley
632d143bff replace a %% b with a catch b
See #632

better fits the convention of using keywords for control flow
2018-01-07 17:28:20 -05:00
Andrea Orru
3182857224 Adding zen support 2018-01-07 04:43:08 -05:00
Andrew Kelley
9d9201c3b4 bring back code that uses export and fix tests
partial revert of 1fdebc1dc4
2017-12-19 02:39:43 -05:00
Andrew Kelley
1fdebc1dc4 wip export rewrite 2017-12-18 09:59:57 -05:00
Andrew Kelley
62c25af802 add higher level arg-parsing API + misc. changes
* add @noInlineCall - see #640
   This fixes a crash in --release-safe and --release-fast modes
   where the optimizer inlines everything into _start and
   clobbers the command line argument data.
   If we were able to verify that the user's code never reads
   command line args, we could leave off this "no inline"
   attribute.
 * add i29 and u29 primitive types. u29 is the type of alignment,
   so it makes sense to be a primitive.
   probably in the future we'll make any `i` or `u` followed by
   digits into a primitive.
 * add `aligned` functions to Allocator interface
 * add `os.argsAlloc` and `os.argsFree` so that you can get
   a `[]const []u8`, do whatever arg parsing you want, and then free
   it. For now this uses the other API under the hood, but it could
   be reimplemented to do a single allocation.
 * add tests to make sure command line argument parsing works.
2017-12-06 18:12:05 -05:00
Andrew Kelley
8ab5313043 implement environment variables for windows 2017-10-15 01:23:10 -04:00
Andrew Kelley
b61a6ec8a6 implement command line argument parsing for windows
See #302
2017-10-11 22:50:16 -04:00
Andrew Kelley
b505462509 replace __chkstk function with a stub that does not crash
Closes #508
See #302
2017-10-03 00:29:41 -04:00
Andrew Kelley
f1bd02e6f4 add @setAlignStack builtin 2017-10-03 00:29:27 -04:00
Andrew Kelley
6a93dda3e1 progress toward windows hello world working 2017-06-14 00:04:34 -04:00
Andrew Kelley
199bbb6292 progress toward hello world without libc in windows 2017-06-04 10:08:55 -04:00
Andrew Kelley
e5b90651ba compileError builtin includes "referenced by" notes
to help track down the cause

closes #278
2017-06-03 15:09:40 -04:00
Andrew Kelley
051ee8e626 change slicing syntax from ... to ..
See #359
2017-05-19 10:39:59 -04:00
Andrew Kelley
698829b772 change while syntax
Old:

```
while (condition; expression) {}
```

New:

```
while (condition) : (expression) {}
```

This is in preparation to allow nullable and
error union types as the condition. See #357
2017-05-03 18:12:07 -04:00