13687 Commits

Author SHA1 Message Date
Andrew Kelley
a7221ef4e9 Sema: implement @typeInfo for functions
The goal is to get start code to be able to inspect the calling
convention of `main` in order to determine whether to export a main for
libc to call, or to allow the root source file to do it.
2021-05-06 22:30:44 -07:00
Andrew Kelley
3acd98fa34 stage2: CBE tests pub export instead of export main
This is needed so that start code can avoid redundantly trying to export
a main function for libc to call.
2021-05-06 17:51:09 -07:00
Andrew Kelley
7dd33d4316 stage2: fix compile errors in test harness 2021-05-06 17:48:38 -07:00
Andrew Kelley
9b9ea405ef CLI: add an update-and-run cmd and make enter re-run last cmd 2021-05-06 17:35:21 -07:00
Andrew Kelley
cdea22f5d7 stage2: wire up outdated/deleted decl detection
we're back to incremental compilation working smoothly
2021-05-06 17:20:45 -07:00
Andrew Kelley
3791cd6781 CLI: add 'run' command to the repl 2021-05-06 12:51:51 -07:00
Andrew Kelley
426e4c784c std.ArrayHashMap: ensureUnusedCapacity and ensureTotalCapacity
Same as 22015c1b3bfcf816faf10ea0fc152c4686efb363, but for ArrayHashMap.
2021-05-06 12:50:53 -07:00
Andrew Kelley
17067e0e6b stage2: fix contents hash computation
during an incremental update change detection,
the function call to get the old contents hash took place
after mangling the old ZIR index, making it access the wrong
array index.
2021-05-05 17:00:10 -07:00
Andrew Kelley
9b1aac8a65 stage2: mapping old to new ZIR recursively
now it walks into functions and blocks to find decls.
2021-05-05 16:56:24 -07:00
Andrew Kelley
c714a3250f std.ArrayList: add clearRetainingCapacity and clearAndFree 2021-05-05 16:55:49 -07:00
Andrew Kelley
5d7f2697de stage2: add zig changelist debug command
and implement the first pass at mechanism to map old ZIR to new ZIR.
2021-05-05 13:16:14 -07:00
Andrew Kelley
6b5d0b3711 std: fix compile errors found by stage2
* redundant `comptime`
 * `try` outside function
 * `extern enum`
2021-05-05 11:03:54 -07:00
Andrew Kelley
fc40d23723 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * build.zig
 * lib/std/array_list.zig
 * lib/std/c/ast.zig
 * lib/std/c/parse.zig
 * lib/std/os/bits/linux.zig
2021-05-05 10:48:22 -07:00
LemonBoy
9d409233b2 std: Implement hex float printing
The results have been cross-checked with LLVM's APFloat implementation
by randomly sampling the f32/f64 space, while the f16 one was completely
checked given the small size.
2021-05-05 12:37:40 -04:00
LemonBoy
18b46485bc stage2: Fix UAF in ErrorMsg destructor
After calling gpa.destroy the object is gone for good, setting the
contents to undefined is a bug and may crash the compiler.
2021-05-05 12:37:04 -04:00
Michael Dusan
622a3ac876
Merge pull request #8691 from lithdew/master
x/net: fix tcp tests for openbsd and add missing `fmt` import
2021-05-05 05:54:47 -04:00
Andrew Kelley
368e13a9a1
Merge pull request #8671 from LemonBoy/arm-host-det
ARM/AArch64 CPU host detection
2021-05-05 03:17:32 -04:00
LemonBoy
e863204c47 zig fmt: Fix edge case in inline asm parsing
The presence of a trailing comma in the single and only input/output
declaration confused the parser and made zig fmt discard any element
placed after the comma.
2021-05-05 03:16:07 -04:00
Jay Petacat
70a9a3a562 stage1: Fix other OS target
PR #7827 added some new `std.Target.Os.Tag` before `other`.
The corresponding enum in stage1.h was not updated, which caused a
mismatch in the underlying integer values. While attempting to target
`other`, I encountered crashes.

This PR updates the stage1.h enum to include the added OS tags.
The new tags also had to be added to various switch cases to fix
compiler warnings, but have not been tested in any way.
2021-05-05 03:15:44 -04:00
lithdew
c75ae8b66d x/net: fix tcp tests for openbsd and add missing fmt import
On OpenBSD, connecting to a newly-allocated port on an unspecified IPv4
host address causes EINVAL. This was found by @mikdusan when running TCP
tests on OpenBSD.

This commit fixes TCP tests on OpenBSD by having all tests that allocate
a new host-port pair to have the host IPv4/IPv6 address point to the
host's loopback adapter (on localhost).
2021-05-05 16:09:08 +09:00
Andrew Kelley
7a27f0d80c Sema: restore the extern lib name functionality 2021-05-04 14:40:59 -07:00
Andrew Kelley
1f0fd64302 stage2: test coverage for inline asm return type not type 2021-05-04 14:23:53 -07:00
Andrew Kelley
edfbf85ecd Sema: implement error sets 2021-05-04 13:58:08 -07:00
Andrew Kelley
230ce72f16 stage2: fix "other symbol here" error note
It wasn't setting the source location properly.
2021-05-04 12:32:22 -07:00
Andrew Kelley
3dafec0acd stage2: fix structs and enums setting wrong owner_decl
No more memory leaks.
2021-05-04 11:08:40 -07:00
Andrew Kelley
785a6c1aa9 std: remove dead and rotting C parsing code 2021-05-04 10:26:44 -07:00
Jakub Konka
96556ce8b8 zld: port over a few more bits from ld64
* UTF16 gets its own section, `__TEXT,__ustring`
* TLV data and bss sections have to aligned to the same max alignment
  according to Apple rdar comment in the latest ld64
2021-05-04 13:09:32 +02:00
Jakub Konka
1867c3c34c zld: disable most logs 2021-05-04 13:09:32 +02:00
Jakub Konka
9e11f27c41 zld: build updated macho backend 2021-05-04 13:09:32 +02:00
Jakub Konka
00c3d57a51 zld: rewrite symbol allocations 2021-05-04 13:09:32 +02:00
Jakub Konka
fcd57f0857 zld: resolve GOT loads and stubs 2021-05-04 13:09:32 +02:00
Jakub Konka
68ebc7cba0 zld: rewrite symbol resolution 2021-05-04 13:09:32 +02:00
Jakub Konka
86ab6ca56c zld: rewrite Object to include pointers to Symbols 2021-05-04 13:09:32 +02:00
LemonBoy
b6be28ddcc std: Accept unaligned slice in several ArrayListAligned ops
Do not impose the internal alignment requirements to the user-supplied
parameters.

Closes #8647
2021-05-04 14:08:19 +03:00
Andrew Kelley
2910b10033 build.zig: add -Dmem-leak-frames option
to configure how many stack frames to save with every allocation, in
case it leaks and needs to get printed on process termination.
2021-05-03 20:42:36 -07:00
Andrew Kelley
2ae72c6f09 Sema: implement ExportOptions support in @export
Also fix switch blocks not emitting their AIR code.
2021-05-03 20:05:29 -07:00
Andrew Kelley
69d18ad7f0 ZIR: typeof uses the un_node field not un_tok 2021-05-03 18:47:53 -07:00
Andrew Kelley
95b014caea Sema: implement struct_decl instruction 2021-05-03 18:35:37 -07:00
Andrew Kelley
0e3930bb5a
Merge pull request #8649 from lithdew/master
x/os, x/net: layout tcp, ipv4/ipv6, and socket abstractions
2021-05-03 17:38:10 -04:00
Andrew Kelley
5622f9382c
Merge pull request #8657 from jedisct1/ci-split
Azure CI: Test std.* and the rest separately
2021-05-03 17:36:51 -04:00
Andrew Kelley
aa4e9399db ZIR: implement debug text printing for struct_init and friends 2021-05-03 12:25:20 -07:00
Andrew Kelley
773902e9de stage2: hook up semantic analysis of struct fields
Now that they are lazy, they need to get analyzed in the correct
context, when requested.

This commit also hooks up std.builtin type values being resolved
properly. This is needed, for example, with the `@export` builtin
function, which occurs in start.zig, for `std.builtin.ExportOptions`.
The ZIR code uses the special `Ref.export_options` value, and semantic
analysis has to map this to the corresponding type from `std.builtin`.
2021-05-03 11:46:02 -07:00
LemonBoy
3eed613407 std: Add two more ARM CPUs to the known CPU list
Modeled after GCC's description.
2021-05-03 12:32:13 +02:00
LemonBoy
e2d2295382 std: Add many more vendors and cpus to the ARM detection list
Hand-picked from GCC and LLVM lists.
2021-05-03 12:32:13 +02:00
LemonBoy
a7f3e12d23 std: Add fallback on pre-v6 ARM targets
Thanks xackus for noticing the missing else branch.
2021-05-03 12:32:13 +02:00
LemonBoy
792cf925ec std: Fix missing CPU feature check
We need both the v6k and the v6m checks.
2021-05-03 12:32:13 +02:00
LemonBoy
b10d40b89b stage2: Implement CPU host detection for ARM/AArch64 targets 2021-05-03 12:32:13 +02:00
Frank Denis
97779442d0
Prepare std/crypto/pcurves for ecdsa and other curves (#8670)
Functions generated by Fiat-crypto are not prefixed by their description any more. This matches an upstream change.

We can now use a single type for different curves and implementations.

The field type is now generic, so we can properly handle the base field and scalars without code duplication.
2021-05-03 09:57:45 +02:00
lithdew
96fe49ef62 std/os/bits/windows: add timeval extern struct 2021-05-03 14:49:10 +09:00
lithdew
16fc1b904c std/os/linux/bits: correct socket option codes for ppc/ppc64 2021-05-03 14:49:10 +09:00