14112 Commits

Author SHA1 Message Date
Andrew Kelley
a23fa896ef Tweak license in celebration of the upcoming 0.8.0 release :) 2021-05-31 14:12:20 -07:00
protty
eb6975f088
std.sync.atomic: extended atomic helper functions (#8866)
- deprecates `std.Thread.spinLoopHint` and moves it to `std.atomic.spinLoopHint`
- added an Atomic(T) generic wrapper type which replaces atomic.Bool and atomic.Int
- in Atomic(T), selectively expose member functions depending on T and include bitwise atomic methods when T is an Integer
- added fence() and compilerFence() to std.atomic
2021-05-31 11:11:30 -05:00
daurnimator
57cf9f7ea6 std: by default, disallow trailing data when parsing json 2021-05-31 14:09:59 +03:00
daurnimator
556d3e3d80 std: fix json.parse with 0 length arrays 2021-05-31 14:09:59 +03:00
Andrew Kelley
11ae6c42c1
Merge pull request #7918 from EthanGruffudd/json-ignore-fields
Add option to ignore unknown fields when parsing json
2021-05-30 14:59:02 -04:00
Andrew Kelley
32815914a4 std.json: update to new testing API 2021-05-30 11:57:44 -07:00
Ethan Gruffudd
781a21af2f std.json: option to ignore unknown fields
Closes #7906
2021-05-30 11:36:10 -07:00
Takeshi Yoneda
0ad1c04dd9 build: rename ast_render in build.zig.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-05-30 13:31:12 -04:00
Andrew Kelley
322215bf0a
Merge pull request #8933 from ziglang/zig-ar
stage2: add `zig ar` subcommand
2021-05-29 19:31:30 -04:00
Andrew Kelley
e078b4f20e zig ar: workaround for LLVM bug
In this file is copy+pasted WindowsSupport.h from LLVM 12.0.1-rc1.
This is so that we can patch it. The upstream sources are incorrectly
including "llvm/Config/config.h" which is a private header and thus not
available in the include files distributed with LLVM.
The patch here changes it to include "llvm/Config/config.h" instead.
Patch submitted upstream: https://reviews.llvm.org/D103370
2021-05-29 13:54:31 -07:00
Andrew Kelley
0afb5b2ec6 stage2: add zig ar subcommand
The same entrypoint supports the following commands:

 * ar
 * ranlib
 * dlltool
 * lib

For now, our strategy is to bundle the (renamed) `main()` function of
llvm-ar, same as our strategy for `zig clang`. However, as Zig matures,
a goal will be to replace the dependency on LLVM  with our own
implementation of this tool, so that it is available in builds of zig
that do not have LLVM extensions enabled.

This commit also categorizes the subcommands into categories in the
--help menu.
2021-05-28 20:54:11 -07:00
Andrew Kelley
e248de93a0 add llvm-ar.cpp from llvm 12.0.1-rc1 2021-05-28 20:12:28 -07:00
Andrew Kelley
c12704a339
Merge pull request #8918 from ziglang/stage1-tokenizer
stage1: rework tokenizer to match stage2
2021-05-28 21:54:01 -04:00
Andrew Kelley
3f5ca3920a AstGen: properly restore previous state after temporary changes
Before this, if a compile error occurred, it would cause the previous
value for e.g. the function scope to not get reset. If the AstGen
process continued, it would result in a violation of the data
guarantees that it relies on.

This commit takes advantage of defer to ensure the previous value is
always reset, even in the case of an error.

Closes #8920
2021-05-28 17:29:56 -07:00
Matthew Borkowski
54f774f796 make writeIntSlice functions work for signed integers 2021-05-28 19:43:58 -04:00
Andrew Kelley
97a2f4e7ae tests: disable i386-linux-gnu -lc target due to CI failures
See #8930
2021-05-28 16:31:09 -07:00
LemonBoy
d3fb9f9532 stage1: Fix for atomicrmw xchg on fp types
Bitcast the pointer and operands to integer types having the same size,
working around LLVM inability to lower a LL/SC operation when the
operands have floating-point types (and are reasonably sized).

Closes #4457
2021-05-28 19:18:42 -04:00
Andrew Kelley
d888fa12a8 stage1 parser: fix the TODOs 2021-05-28 16:11:27 -07:00
Andrew Kelley
3483931d2a
Merge pull request #8923 from Luukdegram/wasm-errors
stage2: wasm backend - Error sets and error unions
2021-05-28 18:45:36 -04: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
33a779c7f6 start.zig: intentional silent failure when cannot increase stack size 2021-05-28 13:17:04 -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
Luuk de Gram
5cbe930e36
wasm: Add stage2 tests for error unions 2021-05-28 12:58:17 +02:00
Luuk de Gram
8a81dfc999
wasm: Reverse the order of error and payload
This will set us up to correctly retrieve the error local index and payload index
depending on that of the multi_value's index. As from now, the error will always use
the multi_value's index, and the payload will use the following locals.
2021-05-28 12:58:17 +02:00
Luuk de Gram
967a299c34
wasm: Add support for error union as return type
- This currently uses the multi-value feature to return both the possible error, and its payload.
- Also genAlloc and the logic to allocate the locals itself have been seperated, so we can create more locals
whenever needed, and not only when `genAlloc` is called.
2021-05-28 12:58:17 +02:00
Luuk de Gram
5481059232
wasm: Implement error unions and unwrapping
- Slightly refactored `Wvalue.multi_value` to also contain the amount of locals it contains,
this allows us to set all fields at once.
2021-05-28 12:58:17 +02:00
Luuk de Gram
a5b5a5532e
wasm: Support error sets 2021-05-28 12:58:17 +02: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