Commit Graph

2619 Commits (ed5a6d74ad980474ed46732828c7f8363dd5b80d)

Author SHA1 Message Date
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 c051904903 Fixed parser for extern threadlocal variables 2019-05-11 18:48:52 +02:00
Andrew Kelley 5f4c3e6557
stage2 translate-c: simple function definitions
See #1964
2019-05-10 23:35:46 -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 1c0223899c
translate-c: progress on self-hosted function prototypes
See #1964
2019-05-10 01:24:00 -04:00
Andrew Kelley 09cff0d2bd
fix translate-c regression
introduced in eb65410b62
2019-05-09 20:11:56 -04:00
Andrew Kelley eea2de108d
translate-c: progress on self-hosted function prototypes
See #1964
2019-05-09 16:52:30 -04:00
Andrew Kelley 214625587c
translate-c: use C API for builtin types
See #1964
2019-05-09 15:46:48 -04:00
Andrew Kelley 010963ce43
stage1: make some asserts print source location 2019-05-09 14:52:06 -04:00
Andrew Kelley c459edac18
compile error for attempt to cast enum literal to error
closes #2203
2019-05-09 13:18:13 -04:00
Andrew Kelley eb65410b62
translate-c: enough C tokenization/parsing to handle shifting in macros
See #2451
2019-05-09 12:48:38 -04:00
Andrew Kelley 62065a9aea
translate-c: handle int to ptr and ptr to int casting
See #2451
2019-05-09 12:17:23 -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 46e1c34fcf
self-hosted translate-c progress on function decls
See #1964
2019-05-08 22:05:59 -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 3bd5c16f39
stage1: remove unneeded extern function 2019-05-08 19:33:57 -04:00
Andrew Kelley e3542196c0
translate-c: NULL pointers translate to `null`
See #1967
2019-05-08 19:21:54 -04:00
Andrew Kelley a4aee8b24d
C pointers support if and orelse
See #1967
2019-05-08 18:47:14 -04:00
Andrew Kelley 0099583bd3
C pointers support .? operator
see #1967
2019-05-08 17:39:00 -04:00
Andrew Kelley 50bbb34594
C pointers support `null`
See #1967
2019-05-08 16:06:34 -04: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
Andrew Kelley bd9c629c4c
always respect threadlocal for variables with external linkage
Previously if you had, for example:

extern "c" threadlocal var errno: c_int;

This would turn errno into a normal variable for --single-threaded
builds. However for variables with external linkage, there is an ABI
to uphold.

This is needed to make errno work for DragonFly BSD. See #2381.
2019-05-03 14:39:54 -04:00
Benjamin Feng 8d58dc715b Switch wasm export-all to only values marked exports 2019-05-03 13:23:02 -04:00
Andrew Kelley 3552180143
optimize `@memset` with `undefined`
When using `@memset` to set bytes to `undefined`, Zig notices this
case and does a single Valgrind client request rather than N.

Speeds up all allocators in safe modes.

Closes #2388
2019-05-03 01:25:03 -04:00
Dong-hee Na c00c18de6a main: change --enable-pic and --disable-pic to -fPIC and -fno-PIC 2019-05-01 16:11:08 -04:00
Andrew Kelley b4f8d68e2e
translate-c: fix using wrong enum
closes #2385
2019-04-30 03:14:45 -04:00
Andrew Kelley a7f99c8ee9
self-hosted translate-c: iterate over top level decls
See #1964
2019-04-30 00:21:45 -04:00
LemonBoy 77383f968d translate-c: Emit @ptrCast + @alignPtr sequence
Avoid producing Zig code that doesn't compile due to mismatched
alignments between pointers.

Always emit a @alignOf instead of hardcoding the alignment value
returned by LLVM for portability sake of the generated code.
2019-04-29 21:30:19 -04:00
Matt Stancliff a4e506510b Fix crash due to command line argument parsing
zig --help -> ok
zig --help --c-source -> ok
zig --c-source --help -> crash [fixed]

'i' was being incremented without regard for the 'argc' limit, so
we were running off the end of 'argv'.
2019-04-29 17:34:23 -04:00
Andrew Kelley 8afa1e800b
fix build (unused function warning)
d3c88a89 needed some #ifdefs shuffled around
2019-04-29 13:18:16 -04:00
Andrew Kelley d3c88a8949
Merge pull request #2139 from emekoi/lib-on-mingw
implement linking to libc on mingw
2019-04-29 13:16:41 -04:00
LemonBoy 9902b604cb Fix generation of container initializers
The code creates temporary ConstExprValue with global_refs set to
nullptr and that's carried over to the final value. Doing so prevents
the deduplication mechanism to work correctly, causing all sorts of
runtime crashes.

Fixes #1636
Fixes #1608 (Even though it was already fixed by #1991)
2019-04-28 13:13:42 -04:00
emekoi 6057513cc7 fixed visibility of zig_libc_cc_print_file_name 2019-04-27 16:17:07 -05:00
emekoi dfada0cc77 added static_crt_dir to libc file 2019-04-27 00:24:26 -05:00
Andrew Kelley 2d6520d5d4
zig fmt is built directly into stage1 rather than child process
Previously, `zig fmt` on the stage1 compiler (which is what we currently
ship) would perform what equates to `zig run std/special/fmt_runner.zig`

Now, `zig fmt` is implemented with the hybrid zig/C++ strategy outlined
by #1964.

This means Zig no longer has to ship some of the stage2 .zig files, and
there is no longer a delay when running `zig fmt` for the first time.
2019-04-26 20:46:28 -04:00
Andrew Kelley c82acdbb9e
clean up test output
After 4df2f3d74f test names have the word "test" in them so the
redundant word is removed from test runner. Also move the prefix/suffix
to where it logically belongs in the fully qualified symbol name.
2019-04-26 15:10:13 -04:00
Andrew Kelley 1d95fdaf6e
Fix path canonicalization when $HOME has a trailing slash 2019-04-26 14:37:26 -04:00
LemonBoy 9ec4ccc68f Do not invoke UB in BigInt shr operations
Shifting a value of type T by an amount that's greater or equal to the
size of the type itself is UB.

Spotted by @tgschultz
2019-04-26 14:24:35 -04:00
rylmovuk 4df2f3d74f Change symbol name of tests in codegen
Tests now have the symbol name of the format `test "<name>"` in order
to be more easily distinguished from functions with similar names.
See issue #2267.
2019-04-26 14:23:56 -04:00
Andrew Kelley e1bf74fca3
translate-c: put -x c back in there, it's necessary 2019-04-25 00:06:58 -04:00
Andrew Kelley 712274997e
translate-c: unify API for self-hosted and C++ translate-c
See #1964
2019-04-25 00:06:57 -04:00
Andrew Kelley 976080462c
translate-c: a little closer to self-hosted implementation 2019-04-25 00:06:54 -04:00