Commit Graph

1914 Commits

Author SHA1 Message Date
Andrew Kelley
5a57610039
clean up code now that #769 is implemented 2019-05-14 19:23:31 -04:00
Marc Tiehuis
b64cee2ec2
Merge pull request #2482 from ziglang/linux-elf-read
Mmap debug info on linux
2019-05-14 16:43:21 +12:00
LemonBoy
08d41da916 Fix formatting for multiline asm expressions 2019-05-13 12:20:11 -04:00
Andrew Kelley
f3db3b3c13
Merge branch 'asm-cc' of https://github.com/LemonBoy/zig into LemonBoy-asm-cc 2019-05-13 12:10:21 -04:00
LemonBoy
a038ef3570 Assemble asm files using CC
Stuffing all the files together and compiling the resulting blob with
the main program is a terrible idea.

Some files, namely the .S ones, must be run trough the C preprocessor
before assembling them (#2437).

Beside that the aggregate may be mis-compiled due to the presence of
some flags that affect the following code.

For example let's consider two files, a.s and b.s

a.s
```
fn1:
    ret
.data
data1:
    .word 0
```

b.s
```
fn2:
    ret
```

Now, fn1 and fn2 will be both placed in the .text section as intended if
the two files are compiled separately. But if we merge them the `.data`
flag ends up placing fn2 in the wrong section!

This fixes a nasty crash where musl's memset ended up in the
non-executable data segment, leading to too many hours of
head-scratching.
2019-05-13 16:41:07 +02:00
Marc Tiehuis
c4d1597f50 Mmap debug info on linux
Closes #907.
2019-05-13 20:04:25 +12:00
Andrew Kelley
c1793d6106
zig fmt on the standard library 2019-05-12 12:56:01 -04:00
hryx
173142b16a
Undo parse2 import 2019-05-12 03:24:48 -07:00
hryx
0d629421c9
Recursive rewrite of stage2 parser, final sync 2019-05-12 02:10:27 -07:00
hryx
3a3a738478
Recursive rewrite of stage2 parser, part 3 2019-05-12 02:01:45 -07:00
hryx
3787f34286
Merge branch 'master' into rebased 2019-05-12 02:00:49 -07:00
Tyler Philbrick
16aee1f58a
Fix memory leak in parser tests
The `arena` instance being used bythe parse tree was valid and
pointed to valid memory, but existed as a local variable inside the
stack frame of the `parse` function (the `const arena`), which was never
stored anywhere before leaving the scope.

This meant that code above the `parse` function saw a valid instance of
an `ArenaAllocator` that pointed to the same backing memory, but didn't
posess any of the local state built up after the call to `parseRoot`,
basically the caller saw an empty arena.

This meant that when `deinit` was called, it saw an Arena with 0
allocations in it's `buffer_list` and wasn't able to destroy any of the
memory.  This caused it to leak and caused FailingAllocator to balk.

The fix is to make sure the parse tree is using the same instance of
ArenaAllocator as is reported up the call stack, the one inside the
`Tree{}` object.  I'm not sure why that field is marked with a comment
to remove it, as it's used by the `std.ast.Tree.deinit()` function, but
this change seems to solve the problem.
2019-05-12 01:54:30 -07:00
hryx
4e28c2571d
Recursive rewrite of stage2 parser, part 1 2019-05-12 01:52:16 -07:00
Andrew Kelley
32efa68f90
Merge pull request #2449 from Sahnvour/directallocator
Rework of windows' DirectAllocator
2019-05-11 13:04:20 -04:00
Andrew Kelley
2ef2f9d71f
Merge pull request #2475 from LemonBoy/linux-wo-vdso
Fix clock_gettime on systems without VDSO
2019-05-11 12:01:52 -04:00
Sahnvour
cd537f822b Use unprotected heap when in single_threaded mode. 2019-05-11 16:41:13 +02:00
Sahnvour
a2d5b0fabe Implement Windows' DirectAllocator on top of VirtualAlloc and VirtualFree. 2019-05-11 16:41:13 +02:00
daurnimator
3d93c89fc5 std: the failing allocator didn't actually count allocations
Add a field '.allocations' to actually track the number of allocations.

Additionally, only increment '.deallocations' when memory is freed
2019-05-11 09:55:41 -04:00
LemonBoy
6756e545f4 Fix more corner cases in LEB128 parsing 2019-05-11 09:54:48 -04:00
LemonBoy
1b23348f30 linux: Minor zig fmt induced reformatting 2019-05-11 10:34:22 +02:00
LemonBoy
715d808f14 linux: Fix clock_gettime on systems w/o VDSO 2019-05-11 10:33:41 +02:00
Andrew Kelley
bcf4d20289
Merge pull request #2465 from LemonBoy/builtins-for-wasm
A few builtins for wasm
2019-05-10 08:44:27 -04:00
LemonBoy
1606dae728 Fix erroneous test case
The *Mem variants cannot return EndOfStream and are generally unsafe to
use.
Proper order of checks, try both the variants and make sure they return
the same error/result.
Run the leb128.zig tests.
2019-05-10 08:40:36 -04:00
LemonBoy
7fb55ce2bb compiler-rt: Add __ashrti3 2019-05-10 13:26:33 +02:00
LemonBoy
fbffece1b5 compiler-rt: Add __lshrti3 2019-05-10 13:26:33 +02:00
LemonBoy
7db2aa1c25 compiler-rt: Add __ashlti3 2019-05-10 13:26:33 +02:00
LemonBoy
8cc4eaea9f Use matching types when parsing fields 2019-05-10 00:44:24 +02:00
LemonBoy
4d8f96dd88 Fix minor bug in LEB128 parsing 2019-05-10 00:41:05 +02:00
Andrew Kelley
72899da44b
fix std.os.copyFile
closes #2454
2019-05-09 13:05:06 -04:00
Andrew Kelley
a7346ea49f fix build on macOS
Sadly due to a workaround for LLD linker limitations on macOS
we cannot put libuserland into an .a file; instead we have to use object
files. Again due to linker limitations, bundling compiler_rt.o into
another relocatable object also doesn't work. So we're left with
disabling stack probing on macOS for the stage1 self-hosted code.

These workarounds could all be removed if the macos support in the LLD
linker improved, or if Zig project had its own linker that did not have
these issues.
2019-05-08 22:45:49 -04:00
Andrew Kelley
4b9e12be50
Merge pull request #2452 from LemonBoy/more-more-builtins
More more builtins
2019-05-08 22:24:12 -04:00
Andrew Kelley
9bbd71c9ab
add --bundle-compiler-rt function to link options
and use it when building libuserland.a

The self-hosted part of stage1 relies on zig's compiler-rt, and so we
include it in libuserland.a.

This should potentially be the default, but for now it's behind a linker
option.

self-hosted translate-c: small progress on translating functions.
2019-05-08 20:51:49 -04:00
Andrew Kelley
9c12237d2d
std.debug: fix stack trace iteration code
Previously, the stack trace iteration code was using the number of
frames collected as the number of frames to print, not recognizing the
fixed size of the buffer. So it would redundantly print items, matching
the total number of frames ever collected.

Now the iteration code is limited to the actual stack trace frame count,
and will not print duplicate frames.

Closes #2447
Closes #2151
2019-05-08 19:11:01 -04:00
LemonBoy
4208fa9ad9 compiler-rt: add __floatsitf 2019-05-09 00:25:50 +02:00
LemonBoy
383b8a032e compiler-rt: Add __aeabi_unwind_cpp_pr{0,1,2} 2019-05-09 00:07:46 +02:00
LemonBoy
2dce137d92 compiler-rt: Add __extendsfdf2
Add AEABI builtin __aeabi_f2d
2019-05-09 00:07:46 +02:00
LemonBoy
2be066d057 compiler-rt: Add __floatdidf
Add AEABI builtin __aeabi_l2d
2019-05-08 23:57:09 +02:00
LemonBoy
d4434dfb67 compiler-rt: Add __floatundidf & __floatunsidf
Add AEABI builtins __aeabi_ul2d, __aeabi_ui2d
2019-05-08 23:57:09 +02:00
LemonBoy
92fd2df054 compiler-rt: Add __truncdfsf2
Add AEABI builtin __aeabi_d2f
2019-05-08 23:57:09 +02:00
LemonBoy
c00167e91a compiler-rt: More division intrinsics 2019-05-08 22:30:20 +02:00
LemonBoy
917103710e compiler-rt: Add __floatsidf & __floatsisf
Also add their AEABI aliases, __aeabi_i2f & __aeabi_i2d
2019-05-08 22:26:54 +02:00
LemonBoy
be7cacfbbe Implement stack probes for x86/x86_64
Enabled on non-Windows systems only since it already requires stack
probes.
2019-05-08 12:36:54 -04:00
Sahnvour
d665948dcf Duplicate windows's DirectAllocator as HeapAllocator, which it is in reality. 2019-05-08 18:19:36 +02:00
Andrew Kelley
9c0596e627
Merge pull request #2427 from LemonBoy/linux-tls
Proper support for TLS on linux
2019-05-07 12:26:26 -04:00
Andrew Kelley
097a62555e
Merge pull request #2439 from LemonBoy/fixes-fixes-fixes
A batch of miscellaneous fixes
2019-05-07 12:26:02 -04:00
LemonBoy
043bd71621 Add ARCH_SET_* definitions for x86_64 2019-05-07 13:19:38 +02:00
LemonBoy
b1db696c10 Less error messages
Decrease the overall size of the binary, programming errors are caught
with unreachable.
2019-05-07 13:09:20 +02:00
LemonBoy
2f041239cb Always initialize the TLS 2019-05-07 13:09:20 +02:00
LemonBoy
cfcf02489d std: Implement on-demand TLS allocation 2019-05-07 13:09:19 +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