Commit Graph

4994 Commits

Author SHA1 Message Date
LemonBoy 08d41da916 Fix formatting for multiline asm expressions 2019-05-13 12:20:11 -04:00
Andrew Kelley 66d86eccbe Merge branch 'LemonBoy-asm-cc' 2019-05-13 12:16:17 -04:00
Andrew Kelley 7330a6102f cache_add_dep_file: handle ErrorFileNotFound specially 2019-05-13 12:15:55 -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
Andrew Kelley c1793d6106 zig fmt on the standard library 2019-05-12 12:56:01 -04:00
Andrew Kelley ed5a6d74ad Merge pull request #2405 from hryx/stage2-recursive-parser
Recursive stage2 parser
2019-05-12 12:53:10 -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 edcc7c72d1 Merge pull request #2459 from LemonBoy/enum-num-um-m
Signed types for enum tags
2019-05-11 20:38:13 -04:00
LemonBoy d210628c91 Amend the error messages 2019-05-11 21:29:55 +02:00
LemonBoy b05e8d46ec Change the enum value allocation strategy 2019-05-11 21:29:53 +02:00
LemonBoy 655794f44f amend type_is_valid_extern_enum_tag 2019-05-11 21:29:00 +02:00
LemonBoy c766f3f9ca Support signed types as enum tags 2019-05-11 21:28:58 +02:00
LemonBoy 917bd4192d Validate enum tag for extern enum
The C specification mandates the enum to be compatible with signed char,
signed int or unsigned int.
2019-05-11 21:27:58 +02:00
Jimmi Holst Christensen 6cf7fb1177 fixes #2235 2019-05-11 20:51:59 +02:00
Jimmi Holst Christensen ba3d18a80e added grammar rule for enum literal to docs 2019-05-11 20:26:41 +02:00
Jimmi Holst Christensen e5a0e21a53 Merge branch 'master' of github.com:ziglang/zig 2019-05-11 20:12:08 +02:00
Jimmi Holst Christensen fb3b943b07 added tests for global variable declaration syntax 2019-05-11 20:11:56 +02:00
Andrew Kelley 32efa68f90 Merge pull request #2449 from Sahnvour/directallocator
Rework of windows' DirectAllocator
2019-05-11 13:04:20 -04:00
Jimmi Holst Christensen b2a196e01d Merge branch 'master' of github.com:ziglang/zig 2019-05-11 18:49:23 +02:00
Jimmi Holst Christensen c051904903 Fixed parser for extern threadlocal variables 2019-05-11 18:48:52 +02:00
Andrew Kelley 10e9d47b49 stage2 translate-c: implement functions with no prototype
stage1 translate-c actually has this wrong. When exporting a function,
it's ok to use empty parameters. But for prototypes, "no prototype"
means that it has to be emitted as a function that accepts anything,
e.g. extern fn foo(...) void;

See #1964
2019-05-11 12:09:11 -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 5f4c3e6557 stage2 translate-c: simple function definitions
See #1964
2019-05-10 23:35:46 -04:00
Andrew Kelley dbb5da14f4 stage2 translate-c: builtin types and pub
See #1964
2019-05-10 17:56:00 -04:00
Andrew Kelley 82219b1fd5 translate-c: better handling of restore points 2019-05-10 17:44:47 -04:00
Andrew Kelley 2933d6b848 add test case for previous commit
closes #2467
2019-05-10 16:57:37 -04:00
Andrew Kelley fee0e6c8b9 fix hang for some compile errors
see #2467
2019-05-10 16:39:50 -04:00
Andrew Kelley a6f7a9ce2b translate-c: we have our first test of self-hosted
See #1964
2019-05-10 16:03:54 -04:00
Michael Dusan d065f297ab stage1: compile error for loop expr val ignored
closes #2460
2019-05-10 10:05:40 -04:00
Jimmi HC 6b10f03b4a Fixes and simplifications for stage 1 parser 2019-05-10 16:09:58 +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
Andrew Kelley 1c0223899c translate-c: progress on self-hosted function prototypes
See #1964
2019-05-10 01:24:00 -04:00
Andrew Kelley f8b7ea119f Merge pull request #2461 from LemonBoy/dwarf-leb128
Fix minor bug in LEB128 parsing
2019-05-09 20:14:20 -04:00
Andrew Kelley 09cff0d2bd fix translate-c regression
introduced in eb65410b62
2019-05-09 20:11:56 -04:00