Commit Graph

5028 Commits

Author SHA1 Message Date
Shritesh Bhattarai
9e65a144fa docs: clarify why wasm_allocator should be used 2019-05-22 07:43:17 -07:00
Shritesh Bhattarai
3b6fc3fdc7 docs: wasm 2019-05-19 19:32:28 -07:00
emekoi
1c73c08298 ran zig fmt on stdlib 2019-05-19 16:33:31 -04:00
LemonBoy
6672ee9eb3 Fix too eager comptime evaluation of error ptr 2019-05-19 15:53:32 -04:00
LemonBoy
b660134a18 Use the correct scope for use
use expressions outside the top-level scope now work as intended.
2019-05-19 00:32:49 -04:00
Andrew Kelley
860684cc2f
Merge pull request #2516 from LemonBoy/32bfix
More 32bit fixes for stdlib
2019-05-19 00:31:16 -04:00
LemonBoy
0a3aec020a Fix load/store of non-integer fields in packed struct 2019-05-18 19:59:47 -04:00
LemonBoy
232bc1bdee Remove more 64bit-centric assumptions from stdlib 2019-05-18 11:08:04 +02:00
LemonBoy
6957927194 Fix some test cases to run on 32bit systems 2019-05-18 10:59:56 +02:00
LemonBoy
51aaa02679 VDSO calls must use the C CC 2019-05-16 22:10:38 -04:00
Andrew Kelley
2eba779af5
stage1 tokenizer: add more missing break statements 2019-05-16 16:50:24 -04:00
SamTebbs33
87901baa28 Add break after digit_value check in TokenizeStateCharCode 2019-05-16 16:49:26 -04:00
Andrew Kelley
e09c05f689
Merge branch 'shawnl-builtins' 2019-05-16 16:38:06 -04:00
Andrew Kelley
80983ca1ca
fixups to the previous commit 2019-05-16 16:37:58 -04:00
Shawn Landden
1fdb24827f
breaking changes to all bit manipulation intrinsics
* `@clz`, `@ctz`, `@popCount`, `@bswap`, `@bitreverse` now
   have a type parameter
 * rename @bitreverse to @bitReverse
 * rename @bswap to @byteSwap

Closes #2119
Closes #2120
2019-05-16 16:37:58 -04:00
Shritesh Bhattarai
56a905c7d1 docgen: add lib codeblock type and use it for wasm32-freestanding 2019-05-16 14:58:10 -04:00
Andrew Kelley
8468ff0fe1
Merge pull request #2507 from ziglang/wasm-libs
improvements to build-lib use case of WebAssembly
2019-05-16 14:31:54 -04:00
Andrew Kelley
978fab817c
the wasm freestanding _start function is return value void 2019-05-16 14:19:13 -04:00
Andrew Kelley
81e960eb74
improvements to build-lib use case of WebAssembly
* build-exe does include the startup code that supplies _start for the
   wasm32-freestanding target. Previously this did not occur because
   of logic excluding "freestanding".
 * build-lib for wasm32-freestanding target gets linked by LLD. To avoid
   infinite recursion, compiler_rt and zig libc are built as objects
   rather than libraries.
   - no "lib" prefix and ".wasm" extension instead of ".a". Rather than
   build-lib foo.zig producing "libfoo.a", now it produces "foo.wasm".
 * go back to using `.o` extension for webassembly objects
 * zig libc only provides _start symbol for wasm when linking libc.
2019-05-16 13:56:56 -04:00
Andrew Kelley
07d0aee11a
clang C API wrapper: small progress 2019-05-16 12:55:45 -04:00
daurnimator
e30cd800e2 std: update linux syscalls to 5.1 2019-05-16 12:38:40 -04:00
Andrew Kelley
6b36b756eb
fix static builds of zig from requiring c compiler
to be installed when linking libc.

When zig links against libc, it requires a dynamic linker path.
Usually this can be determined based on the architecture and operating
system components of the target. However on some systems this is not
correct; because of this zig checks its own dynamic linker.

When zig is statically linked, this information is not available, and so
it resorts to using cc -print-filename=foo to find the dynamic linker
path.

Before this commit, Zig incorrectly exited with an error if there was
no c compiler installed. Now, Zig falls back to the dynamic linker
determined based on the arch and os when no C compiler can be found.
2019-05-15 21:50:56 -04:00
Shritesh Bhattarai
b64e6cb813 change wasm obj ext to .wasm 2019-05-15 20:41:22 -04:00
Andrew Kelley
14cdb01f35 improvements to zig's implementation of libc and WebAssembly
* rename std/special/builtin.zig to std/special/c.zig
   not to be confused with @import("builtin") which is entirely
   different, this is zig's multi-target libc implementation.
 * WebAssembly: build-exe is for executables which have a main().
   build-lib is for building libraries of functions to use from,
   for example, a web browser environment.
   - for now pass --export-all for libraries when there are any
     C objects because we have no way to detect the list of exports
     when compiling C code.
   - stop passing --no-entry for executables. if you want --no-entry
     then use build-lib.
 * make the "musl" ABI the default ABI for wasm32-freestanding.
 * zig provides libc for wasm32-freestanding-musl.
2019-05-15 20:14:58 -04:00
Andrew Kelley
3aa43dc31c
update libclang C API wrapper 2019-05-15 11:57:55 -04:00
LemonBoy
787fd0f1be Fix off-by-one error in LEB128 parsing 2019-05-15 11:11:16 -04:00
Andrew Kelley
057a5d4898
slice types no longer have field access
* fix crash when doing field access of slice types. closes #2486
 * remove the deprecated Child property from slice types
 * add -Dskip-non-native build option to build script
2019-05-14 21:21:59 -04:00
Andrew Kelley
5a57610039
clean up code now that #769 is implemented 2019-05-14 19:23:31 -04:00
Andrew Kelley
e93a05b6e4
switching on error sets makes new error set for capture values
closes #769
2019-05-14 19:11:37 -04:00
Andrew Kelley
c08c222d5e
fix regression on switch capture value for multiple cases 2019-05-14 18:25:14 -04:00
Andrew Kelley
df4f77024e
else value when switching on error set has
optional capture value which is subset.

see #769
2019-05-14 18:06:57 -04:00
LemonBoy
6536b409df Don't emit DW_TAG_lexical_block for VarDecls 2019-05-14 14:34:49 -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
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
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
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