Commit Graph

15052 Commits

Author SHA1 Message Date
Andrew Kelley
111a2dcf3a update libunwind to llvm release/13.x
upstream commit 2aa67b31faf087cd5a6df8aa4262b17bdc41bba7
2021-09-13 15:59:24 -07:00
Andrew Kelley
303e1a062c re-enable mips behavior tests for vectors
closes #3317
2021-09-01 15:41:29 -07:00
Andrew Kelley
a338eaccc8 stage2: libcxx: logic for skipping OS-specific files 2021-09-01 15:34:39 -07:00
Andrew Kelley
173db6eea6 AstGen: fix "missing function name" error
scanDecls() made an incorrect assumption about all declarations having
function names. The compile error for "missing function name" needed to
go into scanDecls().
2021-09-01 11:29:14 -07:00
Andrew Kelley
77516af118 stage2: update LLVM backend to for LLVM 13
There was some new code in master branch enumerating all the targets and
a new target was added so we needed to add the glue code.

This commit also introduces some build options to support experimental
LLVM targets.
2021-08-31 23:36:25 -07:00
Andrew Kelley
7efca2e6f5 Merge remote-tracking branch 'origin/master' into llvm13 2021-08-31 18:44:15 -07:00
Andrew Kelley
75263e160e CI: update Linux and macOS tarballs to LLVM 12.0.1 2021-08-31 16:39:25 -07:00
Philipp Lühmann
76b85cd665 fix typo 2021-08-31 14:05:44 -04:00
joachimschmidt557
435d8ae536 stage2 ARM: add missing parameters for bic, bics 2021-08-31 14:05:20 -04:00
Meghan
50c6b6cc66
stage2: only initialize the llvm backend for the target we are building (#9659) 2021-08-31 13:50:09 -04:00
Andrew Kelley
d0f04824f1 re-enable all the MIPS tests
LLVM 12.0.1 fixed the regressions from LLVM 12.0.0.

Closes #8155
2021-08-31 10:36:33 -07:00
fn ⌃ ⌥
b25e58b0ac
std.hash_map: add getKey methods (#9607) 2021-08-31 00:32:34 -04:00
Lee Cannon
ede47d49eb
Print enum values for build options in help output (#9650) 2021-08-30 21:39:02 -04:00
Martin Wickham
cf75cad899 Add comptime memory tests 2021-08-30 18:50:07 -04:00
joachimschmidt557
4334dbb9a5 stage2 codegen: Remove use of usingnamespace 2021-08-30 13:40:03 -04:00
Boo
ef39725055
Fix float formatting for 0.0 when precision is 0 (#9642) 2021-08-30 13:39:05 -04:00
Andrew Kelley
861b784454 AstGen: fix incorrectly using decl_val/decl_ref
in identifiers rather than directly referencing the instructions.
2021-08-29 13:43:03 -07:00
Veikka Tuominen
be9b490f84 translate-c: remove now unnecessary mangling of primitive type shadowing
Closes #6382
2021-08-29 15:11:38 +03:00
jdmichaud
49c9975484
zig fmt: respect trailing commas in inline assembly 2021-08-29 11:57:32 +02:00
Isaac Freund
7b863aa8ac AstGen: short-circuit rvalue() if code is unreachable
This avoids generating instructions which will never be reached.
2021-08-29 08:59:27 +00:00
Andrew Kelley
4bb5d17edc AstGen: pre-scan all decls in a namespace
Also:
 * improve the "ambiguous reference" error by swapping the order of
   "declared here" and "also declared here" notes.
 * improve the "not accessible from inner function" error:
   - point out that it has to do with the thing being mutable
   - eliminate the incorrect association with it being a function
   - note where it crosses a namespace boundary
 * struct field types are evaluated in a context that has the struct
   namespace visible. Likewise with align expressions, linksection
   expressions, enum tag values, and union/enum tag argument
   expressions.

Closes #9194
Closes #9622
2021-08-28 16:04:38 -07:00
Andrew Kelley
db4fea6689 update libcxx, libcxxabi, and C headers to release/13.x branch
upstream commit 9c49fee5e7ac0ca8bc4ec1c3738ca0d83df65852
2021-08-28 13:11:47 -07:00
Andrew Kelley
6aeab0f323 Merge remote-tracking branch 'origin/master' into llvm13
Conflicts:
   lib/libcxx/include/__config

d57c0cc3bf added support for DragonFlyBSD
to libc++ by updating some ifdefs. This needed to be synced with llvm13.
2021-08-28 12:41:24 -07:00
Andrew Kelley
05cf44933d stage2: delete keywords true, false, undefined, null
The grammar does not need these as keywords; they are merely primitives
provided by the language the same as `void`, `u32`, etc.
2021-08-28 12:10:55 -07:00
Andrew Kelley
6a6e2cd64f AstGen: allow locals with same name as primitives with @"" syntax
This makes local names follow the same rule as declaration names.
2021-08-28 13:28:34 -04:00
Andrew Kelley
f30aa25cbf declarations may collide with primitives with @"" syntax
* stage2 AstGen: add missing compile error for declaring a local
   that shadows a primitive. Even with `@""` syntax, it may not have
   the same name as a primitive.
 * stage2 AstGen: add a compile error for a global declaration
   whose name matches a primitive. However it is allowed when using
   `@""` syntax.
 * stage1: delete all "declaration shadows primitive" compile errors
   because they are now handled by stage2 AstGen.
 * stage1/stage2 AstGen: notice when using `@""` syntax and:
   - treat `_` as a regular identifier
   - skip checking if an identifire is a primitive

Check the new test cases for clarifications on semantics.

closes #6062
2021-08-27 21:34:13 -07:00
Robin Voetter
cfae70ec8e Make slice always return a reference
Previously this returned an rvalue, which leads to unexpected behaviour
when writing expressions such as `x[1..][1..].`
2021-08-27 18:53:03 -04:00
Robin Voetter
3aa533519d Store to mutable pointer in analyzeRef
This function previously attempted to store a value to an immutable
pointer, after which storePtr would yield an error.
2021-08-27 18:53:03 -04:00
Robin Voetter
3a3704be05 Don't use .none_or_ref for for(expr)
We can already know whether the user want the expression to be a pointer or
ref based on whether the asterisk token is used, like with if and switch.
2021-08-27 18:53:03 -04:00
Lee Cannon
311797f686
Rework build system build_options API (#9623)
* rework `build_options` to integrate with the FileSource abstraction
* support mapping as an arbitrarily named package
* support mapping to multiple different artifacts
* use hash of contents for options filename
2021-08-26 19:53:23 -04:00
joachimschmidt557
04cafd8137 stage2 ARM: Add qadd, qsub, qdadd, qdsub instructions
These are integer saturating arithmetic instructions
2021-08-26 14:42:28 +02:00
Andrew Kelley
9c95f38a7c stage1: remove incorrect compile error for var redeclaration
Locals are not allowed to shadow declarations, but declarations are
allowed to shadow each other, as long as there are no ambiguous
references.

closes #678
2021-08-24 22:35:37 -07:00
Andrew Kelley
f1f28af188 fix stage2 test cases expecting wrong line numbers
Previous commit shifted everything down in the start.zig file, and
unfortunately our stage2 test harness depends on absolute line
numbers for a couple tests.
2021-08-24 13:42:31 -07:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Koakuma
dd75302563 Linux/SPARCv9: use C calling convention for restore_rt
This is needed to prevent infinite loop when calling rt_sigreturn.
2021-08-24 14:08:54 -04:00
Koakuma
e3840817d7 Linux/SPARCv9: account for branch delay in freeAndExit() 2021-08-24 14:08:54 -04:00
Takeshi Yoneda
5c79370e9c
wasm: pass --export-dynamic to wasm-ld for WASI reactors. (#9605)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-08-24 14:03:50 +02:00
Frank Denis
8a37fe2176
BoundedArray: a simple way to represent small data whose max size is known (#9134)
This is a simple structure containing an array and a length, that can be viewed as a slice.

It is useful to pass-by-copy small data whose exact size is known at runtime, but whose maximum size is known at comptime. This greatly simplifies code that otherwise would require an allocator, or reimplementing what this type does.
2021-08-24 13:59:28 +02:00
lucky
8c41a8e761
add scrypt kdf (#9577)
add phc encoding parser
add password hash functions to benchmark
change bcrypt to be consistent with scrypt

Co-authored-by: lucky <>
2021-08-24 13:58:09 +02:00
Andrew Kelley
a98fa56ae9 std: [breaking] move errno to become an nonexhaustive enum
The primary purpose of this change is to eliminate one usage of
`usingnamespace` in the standard library - specifically the usage for
errno values in `std.os.linux`.

This is accomplished by truncating the `E` prefix from error values, and
making errno a proper enum.

A similar strategy can be used to eliminate some other `usingnamespace`
sites in the std lib.
2021-08-24 01:23:28 -04:00
Frank Denis
9e3ec98937
Don't define valgrind_support on macOS (#9612)
Unfortunately, Valgrind for macOS has been broken for years,
and the Homebrew formula is only for Linux.
2021-08-23 20:06:02 -04:00
Andrew Kelley
bb38931c71 stage1: @intToEnum implicitly does an @intCast
This is a backwards-compatible language change.

Previously, `@intToEnum` coerced its integer operand to the integer tag
type of the destination enum type, often requiring the callsite to
additionally wrap the operand in an `@intCast`. Now, the `@intCast` is
implicit, and any integer operand can be passed to `@intToEnum`.

The same as before, it is illegal behavior to pass any integer which does
not have a corresponding enum tag.
2021-08-23 15:30:57 -07:00
Nguyễn Gia Phong
d5ef5da594
Update comment: s/var/anytype/ (#9611) 2021-08-23 16:22:27 +02:00
William Stein
c465b34d32
Trivial typo "for for" --> "for" (also a few nearby run-on sentence). (#9610) 2021-08-23 08:31:21 +02:00
daurnimator
72c4b80d31
std.os: (p)writev should perform partial writes if iov.len > IOV_MAX
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2021-08-22 22:22:53 +03:00
Richard Eklycke
62e3d67605 Fix typo introduced in 50a29f7
Now the last argument will be checked as well
2021-08-22 13:29:06 -04:00
Jacob G-W
4ac37eb484 stage2 Air: add struct_field_ptr_index_{0..3}
Since these are very common, it will save memory.
2021-08-21 23:52:55 -04:00
Andrew Kelley
f378b0adce stage2: comptime function with the same args is memoized
* Introduce `memoized_calls` to `Module` which stores all the comptime
   function calls that are cached. It is keyed on the `*Fn` and the
   comptime arguments, but it does not yet properly detect comptime function
   pointers and avoid memoizing in this case. So it will have false
   positives for when a comptime function call mutates data through a
   pointer parameter.
 * Sema: Add a new helper function: `resolveConstMaybeUndefVal`
 * Value: add `enumToInt` method and use it in `zirEnumToInt`. It is
   also used by the hashing function.
 * Value: fix representation of optionals to match error unions.
   Previously it would not handle nested optionals correctly. Now it
   matches the memory layout of error unions and supports nested
   optionals properly. This required changes in all the backends for
   generating optional constants.
 * TypedValue gains `eql` and `hash` methods.
 * Value: Implement hashing for floats, optionals, and enums.
   Additionally, the zig type tag is added to the hash, where it was not
   previously, so that values of differing types will get different
   hashes.
2021-08-21 20:47:42 -07:00
Andrew Kelley
2b40815a22 stage2: fix wrong value for Decl owns_tv
In the case of a comptime function call of a function that returns a
type, resulting in a compiler crash on deinit().
2021-08-21 20:47:42 -07:00
Jonathan Marler
f28868e8fd mingw.zig: fix logic to add crt sources
The current version of code uses isARM to check if we are compiling to any arm target then checks the target bit width to either add the 32-bit sources or 64-bit source.  However, isARM only returns true for 32-bit targets, and isAARCH64 is for the 64-bit targets.

I also replaced the unreachable with a @panic when we receive an unsupported arch because this code is reachable and should turn into an error.
2021-08-21 20:40:07 +03:00