14088 Commits

Author SHA1 Message Date
Andrew Kelley
d888fa12a8 stage1 parser: fix the TODOs 2021-05-28 16:11:27 -07:00
Andrew Kelley
f5d4fe3e17 stage1: memoize strings in the AST
Currently, stage1 runs astgen for every comptime function call,
resulting in identifier strings being allocated multiple times,
wasting memory. As a workaround until the code is adjusted to
make astgen run only once per source node, we memoize the
result into the AST.

 * Rename `ir_gen_*` to `astgen_*`
   - Oops, meant to do this in a separate commit. My bad.
 * tokenizer: avoid using designated initializer syntax.
   MSVC does not support it.
2021-05-28 15:22:03 -07:00
Andrew Kelley
52b3daa90e stage1: get test-compile-errors passing again 2021-05-28 14:19:08 -07:00
Andrew Kelley
9de2c1b76e stage1: tokenizer: backport recent stage2 changes
This backports ec10595b65490126e1b7d231f655be6d7d198acf stage2 tokenizer
logic to stage1.
2021-05-28 13:26:16 -07:00
Andrew Kelley
01e0a4b2f0 stage1: rename IrBasicBlockSrc to Stage1ZirBasicBlock 2021-05-28 12:58:40 -07:00
Andrew Kelley
548ef78070 stage1: remove source_node field from Stage1Zir
This field is unneeded because we always have the source node available
in the context that we have a Stage1Zir object.
2021-05-28 12:58:40 -07:00
Andrew Kelley
554dd52c36 stage1: remove c_import_buf from Stage1Zir
All we need is a boolean in Stage1AstGen. This is part of an effort to
make Stage1Zir immutable.
2021-05-28 12:58:40 -07:00
Andrew Kelley
4ea421f8cb stage1: move the ZigFn from Stage1Zir to Stage1AstGen
Part of an effort to make Stage1Zir immutable.
2021-05-28 12:58:40 -07:00
Andrew Kelley
42f4ee0aeb stage1: rename IrBuilderSrc to Stage1AstGen 2021-05-28 12:58:40 -07:00
Andrew Kelley
2440c08ab0 stage1: move next_debug_id from Stage1Zir to IrBuilderSrc
Part of an effort to make Stage1Zir immutable.
2021-05-28 12:58:40 -07:00
Andrew Kelley
b11ac9c5bf stage1: move some mutable state from Stage1Zir to IrAnalyze
This is progress towards making Stage1Zir immutable, so that we can
avoid generating it for every comptime function call.

Also rename IrExecutableGen to Stage1Air.
2021-05-28 12:58:40 -07:00
Andrew Kelley
e072ace436 stage1: rename IrExecutableSrc to Stage1Zir
and make IrBuilderSrc private to astgen.cpp
2021-05-28 12:58:40 -07:00
Andrew Kelley
eb37722d79 lol that's never going to happen in stage1 2021-05-28 12:58:40 -07:00
Andrew Kelley
2a990d6966 stage1: rework tokenizer to match stage2
* Extracts AstGen logic from ir.cpp into astgen.cpp. Reduces the
   largest file of stage1 from 33,551 lines to 25,510.
 * tokenizer: rework it completely to match the stage2 tokenizer logic.
   They can now be maintained together; when one is changed, the other
   can be changed in the same way.
   - Each token now takes up 13 bytes instead of 64 bytes. The tokenizer
     does not parse char literals, string literals, integer literals,
     etc into meaningful data. Instead, that happens during parsing or
     astgen.
   - no longer store line offsets. Error messages scan source
     files to find the line/column as needed (same as stage2).
   - main loop: instead of checking the loop, handle a null byte
     explicitly in the switch statements. This is a nice improvement
     that we may want to backport to stage2.
   - delete some dead tokens, artifacts of past syntax that no longer
     exists.
 * Parser: fix a TODO by parsing builtin functions as tokens rather than
   `@` as a separate token. This is how stage2 does it.
 * Remove some debugging infrastructure. These will need to be redone,
   if at all, as the code migrates to match stage2.
   - remove the ast_render code.
   - remove the IR debugging stuff
   - remove teh token printing code
2021-05-28 12:58:40 -07:00
Matthew Borkowski
673ae5b457 update comments to match changes to the formal grammar 2021-05-27 21:03:49 -04:00
Jakub Konka
c0aa9292ba
build: allow specifying rpaths explicitly (#8912)
It currently looks like that if the user links in a dylib using
`lib_or_exe.linkSystemLibrary`, and the linked lib doesn't have
a hardcoded path in its description load command but rather it
allows for any runtime path via `@rpath`, then it is not possible
to specify the runtime path explicitly using the build system.
2021-05-27 21:01:32 -04:00
Isaac Freund
ec10595b65 stage2: disallow trailing dot on float literals
This disallows e.g. `1.` or `0x1.` as a float literal, which is
consistent with the grammar.
2021-05-27 21:00:44 -04:00
Andrew Kelley
4bf8ec9952
Merge pull request #8910 from mattbork/parser-small-allocs
Use shared scratch buffer to avoid allocating and freeing many small lists in parse.zig
2021-05-27 17:39:55 -04:00
Frank Denis
7674a8b43d p256: update to the last fiat-crypto code & share PC tables
fiat-crypto now generates proper types, so take advantage of that.

Add mixed subtraction and double base multiplication.

We will eventually leverage mixed addition/subtraction for fixed
base multiplication. The reason we don't right now is that
precomputing the tables at comptime would take forever.
We don't use combs for the same reason. Stage2 + less function
calls in the fiat-crypto generated code will eventually address
that.

Also make the edwards25519 code consistent with these changes.

No functional changes.
2021-05-27 16:35:10 -04:00
Matthew Borkowski
80c86ec960 keep temporary list from escaping parseParamDeclList, make SmallSpan.multi hold Node.SubRange instead of owned memory 2021-05-27 14:30:42 -04:00
Jakub Konka
d8d92dafe8 zld: search for .a before .dylib by default
Change default behaviour to search for static archives before searching
for dynamic libraries if no flag such as `-search_paths_first` is
specified. Also, fix a bug with early break from outer loop (label
in the wrong place).
2021-05-27 15:33:48 +02:00
Jakub Konka
ae15281c05 zld: dylib paths need nul terminator included 2021-05-27 11:36:13 +02:00
Matthew Borkowski
9ddd12ea14 parse.zig: use shared scratch buffer to avoid allocating and freeing many small lists 2021-05-26 22:01:04 -04:00
Matthew Borkowski
f750618846 stop tokenizer from recognizing lone @ or @ followed by a digit as a builtin 2021-05-26 04:13:04 -04:00
Andrew Kelley
44de884980 tokenizer: fix crash on multiline string with only 1 backslash
Closes #8904
2021-05-25 18:13:10 -07:00
LemonBoy
3ed6379192 stage1: Store target info in the LLVM module
This is needed to let LLVM (or, better, libLTO) produce code using the
target options specified by the user.

Fix #8803
2021-05-25 18:03:05 -04:00
Andrew Kelley
2f538f30fd
Merge pull request #8894 from xxxbxxx/standalone_buildmodes
add standalone test for c compiler with build modes
2021-05-25 15:44:38 -04:00
Andrew Kelley
5c25160452
Merge pull request #8892 from mattbork/prec-doc
fix position of `orelse` and `catch` in precedence table documentation
2021-05-25 15:39:43 -04:00
joachimschmidt557
4c75f834e7 Re-enable building the self-hosted compiler for 32-bit targets 2021-05-25 15:38:32 -04:00
Matthew Borkowski
b01e5d9301 fix position of .* and .? in operator precedence table documentation 2021-05-25 00:09:28 -04:00
xavier
acaa0b8f08 remove reduntant new/delete implementation
The same code is provided by both libxx and libxxabi, and removed at linktime.
2021-05-25 00:42:39 +02:00
xavier
32154fbf0d add a standalone for zig as a c/c++ compiler 2021-05-25 00:42:31 +02:00
xavier
7e4f28fac9 standalone tests may now test cross targets and build modes. 2021-05-25 00:19:23 +02:00
Matthew Borkowski
46d8e010a0 fix position of orelse and catch in precedence table and remove misplaced error union operator 2021-05-24 16:58:20 -04:00
Andrew Kelley
8c5d4295e5
Merge pull request #8876 from xxxbxxx/cxx-lto
build libc++ with lto and function-sections
2021-05-24 13:58:02 -04:00
xavier
8275c771c8 zig cc: expose header files when linking libunwind 2021-05-24 13:48:49 -04:00
Jens Goldberg
1df993706a Fix socklen_t cast in win32 recvfrom
All other uses of `ws2_32.socklen_t` in windows.zig casts the value to an i32. `recvfrom` should do so as well; it currently errors out with `expected type '?*i32', found '?*u32'`.
2021-05-24 13:46:35 -04:00
Andrew Kelley
0a99898b98
Merge pull request #8862 from hoanga/haiku-support-linker
further haiku support    initial compile and link
2021-05-24 13:45:47 -04:00
Andrew Kelley
156b968ad8 stage2: remove dead code; rename crtbegin_dir to gcc_dir 2021-05-24 10:41:59 -07:00
Al Hoang
e8cf15236d add haiku case to csu 2021-05-24 10:39:02 -07:00
Al Hoang
5280ea5d22 update compilation and elf link for haiku case
* for some reason part of the linkable bits for the crt libraries
  are split in different locations for haiku. this changeset
  accomodates this situation (crtbegin_dir lookup)
2021-05-24 10:39:02 -07:00
Al Hoang
c4a4330cc7 haiku case for libc link flags 2021-05-24 10:39:01 -07:00
Al Hoang
2be2c983cb enable symbol lookup for haiku 2021-05-24 10:39:01 -07:00
Al Hoang
db8eae65de avoid usage of execv on Haiku 2021-05-24 10:39:01 -07:00
Michael Dusan
8cebbc352a housekeeping: builtin.arch → builtin.cpu.arch 2021-05-24 13:38:47 -04:00
Michael Dusan
1dc7764f2d clang driver: fix lost argv[0] 2021-05-24 13:26:52 -04:00
Ryan Liptak
6426519e32 zig fmt: Remove workaround for . and .. path handling on Windows
Added in #4655/#5187, obsoleted by #7664
2021-05-24 13:24:21 -04:00
Michael Dusan
75cd37b8f7 dragonfly: pass zig build test 2021-05-24 10:24:41 -04:00
Andrew Kelley
55811d8dac stage2: introduce clangAssemblerSupportsMcpuArg
Clang has a completely inconsistent CLI for its integrated assembler for
each target architecture. For x86_64, for example, it does not accept
an -mcpu parameter, and emits "warning: unused parameter". However, for
ARM, -mcpu is needed in order to properly lower assembly to machine code
instructions (see new standalone test case provided thanks to @g-w1).

This is a compromise between
b8f85a805bf61ae11d6ee2bd6d8356fbc98ee3ba and
afb9f695b1bdbf81185e7d55d5783bcbab880989.
2021-05-23 21:51:10 -07:00
Andrew Kelley
609207801a make "gnu" (mingw-w64) the default C ABI on Windows
Closes #6565
2021-05-24 00:13:54 -04:00