Commit Graph

5614 Commits

Author SHA1 Message Date
Andrew Kelley ecdd4a9fe8 build system: add flag for -fstack-protector 2022-08-22 15:11:34 -07:00
Veikka Tuominen 8667d6d61e Merge pull request #12563 from Vexu/stage2-fixes
Stage2 fixes
2022-08-22 14:32:31 +03:00
InKryption f1999712b0 std.io.Reader: bounded array functions
* Add readIntoBoundedBytes
 * Add readBoundedBytes
2022-08-22 14:07:22 +03:00
Justas Zabulionis 24d718e7eb std.valgrind.callgrind: fix string type
Fixes the error when using std.vallgrind.callgrind:
error: expected type '[2]u8', found '*const [2:0]u8'
2022-08-22 13:55:00 +03:00
Veikka Tuominen b55a5007fa Sema: fix parameter of type 'T' must be comptime error
Closes #12519
Closes #12505
2022-08-22 11:16:36 +03:00
Jakub Konka 6c020cdb76 Merge pull request #12557 from Luukdegram/wasm-archive
wasm-linker: Improve archive linking
2022-08-22 08:38:41 +02:00
John Schmidt 9cf667a21b Enable unexpectedErrno error tracing for stage2 LLVM
Stage2 seems to be able to handle this now.
2022-08-21 23:41:01 +03:00
Luuk de Gram d4c56804df std: fix EmulatableRunStep
Fixes a compilation error when using the `EmulatableRunStep`
that is being generated from a step directly using `runEmulatable`.
2022-08-21 16:42:11 +02:00
Luuk de Gram 7fe2a3d104 test/link: add wasm linker-test for archives
Adds a test case that will pull-in compiler-rt symbols,
and therefore link with the compiler-rt archive file.
2022-08-20 15:46:39 +02:00
Andrew Kelley 4a27d2aac6 std.os.linux.bpf: fix compile error 2022-08-19 16:45:16 -07:00
Jakub Konka 10b95d89f8 coff: change improperly used packed struct into extern struct 2022-08-19 16:45:16 -07:00
Andrew Kelley 445b33cfc0 fix std.os.windows.PathSpace.span
it was returning a pointer to a parameter.
2022-08-19 16:45:16 -07:00
Andrew Kelley 507aae4a1a make self-hosted the default compiler
stage1 is available behind the -fstage1 flag.

closes #89
2022-08-19 16:45:15 -07:00
Andrew Kelley cee82c7ce4 improved ABI alignment/size for >= 128-bit integers
* riscv64: adjust alignment and size of 128-bit integers.
 * take ofmt=c into account for ABI alignment of 128-bit integers and
   structs.
 * Type: make packed struct support intInfo
 * fix f80 alignment for i386-windows-msvc
2022-08-18 20:34:36 -07:00
Andrew Kelley b975f7a56f std.Target gains ObjectFormat field 2022-08-18 18:58:28 -07:00
Andrew Kelley 6e313eb110 stage2: agree with LLVM that @alignOf(u128) is 8
on x86_64 and similar targets.
2022-08-18 17:11:32 -07:00
Ben Fiedler 7d674d5fb6 build: Allow comptime_int in OptionsStep.addOption 2022-08-18 23:00:44 +02:00
Sage Hane f6459721e5 std.build: Fix typo in LibExeObjStep.runEmulatable's assertion 2022-08-18 20:08:25 +03:00
Eric Joldasov b97ae88898 std.zig.system.NativeTargetInfo: look for a shebang line in /usr/bin/env, if any 2022-08-18 19:57:50 +03:00
zooster 4055e6055b AstGen: disallow leading zeroes in int literals and int types
This makes `0123` and `u0123` etc. illegal.

I'm now confident that this is a good change because
I actually caught two C header translation mistakes in `haiku.zig` with this.
Clearly, `0123` being octal in C (TIL) can cause confusion, and we make this easier to read by
requiring `0o` as the prefix and now also disallowing leading zeroes in integers.

For consistency and because it looks weird, we disallow it for integer types too (e.g. `u0123`).

Fixes #11963
Fixes #12417
2022-08-18 19:54:51 +03:00
Andrew Kelley df507edffe Merge pull request #12461 from ziglang/fix-12421
Fixes link-tests and `atomicSymLink` on Windows
2022-08-18 00:50:14 -04:00
Techatrix 79757f233d fix memory leak in NativePaths.zig 2022-08-17 19:05:39 -04:00
Jakub Konka 515ee5b2fa libstd: do not follow symlinks in renameatW
This correctly mimicks POSIX behavior.
2022-08-17 23:13:58 +02:00
Jakub Konka 070282a96e libstd: fix off-by-one error in def of ProcSym in pdb
Make sure `ProcSym` includes a single element byte-array which delimits
the start of the symbol's name as part of its definition. This makes
the code more elegant in that accessing the name is equivalent to taking
the address of this one element array.
2022-08-17 16:36:02 -04:00
Andrew Kelley a12abc6d6c Merge pull request #12456 from Vexu/stage2
Stage2 namespacing fixes
2022-08-16 19:57:22 -04:00
Andrew Kelley 9d85335de9 Merge pull request #12427 from r00ster91/nicelexer
tokenizer: cleanups
2022-08-16 14:08:31 -04:00
Veikka Tuominen 9d4561ef00 AstGen: detect declarations shadowing locals
Closes #9355
2022-08-16 20:35:03 +03:00
r00ster91 83909651ea test: simplify testTokenize
What this does is already done by `expectEqual`.
Now the trace seems to be shorter and more concise so the errors should be easier to read now.
2022-08-16 00:20:19 +02:00
r00ster91 5490688d65 refactor: use std.ascii functions 2022-08-16 00:20:19 +02:00
r00ster91 e3b3eab840 test(names): some renamings 2022-08-16 00:20:19 +02:00
r00ster91 f07cba10a3 test(names): remove unnecessary "tokenizer - " prefix 2022-08-16 00:20:19 +02:00
Ryan Liptak 764cf4e53f std.fs: Fix WalkerEntry.dir not always being the containing dir
Before this commit, the modified test would fail with `FileNotFound` because the `entry.dir` would be for the entry itself rather than the containing dir of the entry. That is, if you were walking a tree of `a/b`, then (previously) the entry for `b` would incorrectly have an `entry.dir` for `b` rather than `a`.
2022-08-15 11:25:51 +03:00
Yujiri 2279f27e0f Fix #12423: auto_hash not hashing arrays of slices uniquely 2022-08-14 23:12:48 +03:00
Andrew Kelley e67a43a673 Merge pull request #12410 from ifreund/sig-err-dfl-ign-fix
std: fix definition of SIG_IGN, SIG_DFL, etc.
2022-08-11 15:05:07 -04:00
LordMZTE bbcc26a9b6 fix error message when providing slice to std.hash.autoHash 2022-08-11 21:44:33 +03:00
Andrew Kelley a82d7c2063 std: add missing error to windows.WriteFile
I encountered this error today when testing the self-hosted compiler on
Windows.
2022-08-11 06:22:05 -04:00
Isaac Freund b78f3bf1f1 std: fix definition of SIG_IGN, SIG_DFL, etc.
POSIX specifies that the sa_handler field of the sigaction struct may
be set to SIG_IGN or SIG_DFL. However, the current constants in the
standard library use the function pointer signature corresponding to
the sa_sigaction field instead.

This may not cause issues in practice because the fields usually occupy
the same memory in a union, but this isn't required by POSIX and there
may be systems we do not yet support that do this differently.

Fixing this also makes the Zig interface less confusing to use after
reading the man page.
2022-08-11 12:09:34 +02:00
Isaac Freund 7d6a7f513b std: Don't pass undefined memory to the kernel in os.abort() 2022-08-11 11:05:53 +02:00
Andrew Kelley fa620ef710 link.MachO: use accurate alignment attribute on pointers
Also adds a new method to ArrayList: appendUnalignedSlice
2022-08-10 22:28:05 -07:00
Andrew Kelley e0178890ba Merge pull request #12379 from ifreund/packed-struct-explicit-backing-int
stage2: Implement explicit backing integers for packed structs
2022-08-10 19:13:29 -04:00
zooster 8fd20a5eb0 fix: disallow newline in char literal 2022-08-10 16:13:56 -04:00
Isaac Freund 0d32b73078 stage2: Implement explicit backing integers for packed structs
Now the backing integer of a packed struct type may be explicitly
specified with e.g. `packed struct(u32) { ... }`.
2022-08-10 19:54:45 +02:00
Veikka Tuominen 19af4b5cad std: add workaround for stage2 bug 2022-08-09 16:19:55 +03:00
Andrew Kelley 1a500b9699 Sema: avoid error return traces when possible
stage2 was adding bogus error return trace frames when an error was not
being returned. This commit makes several improvements:

 * Make a runtime check if necessary to only emit a frame into the error
   return trace when an actual error is returned.
 * Use the `analyzeIsNonErrComptimeOnly` machinery to avoid runtime
   checks when it is compile-time-known that the value is an error, or a
   non-error.
 * Make std.builtin.returnError take a non-optional stack trace pointer.

closes #12174
2022-08-08 19:16:21 -07:00
Ryotaro "Justin" Kimura 50b36e84fa std: fix BoundedArray test checking wrong condition (#12372) 2022-08-08 18:13:35 -04:00
Meghan Denny 0879cbeed2 remove 'builtin.stage2_arch', Sema is smart enough now 2022-08-07 16:07:08 -07:00
Jakub Konka ae16c1d083 std: use std.macho.LoadCommandIterator for MachO parsing in std.debug 2022-08-06 23:14:54 -07:00
Veikka Tuominen bd21f499dc Type: adjust C type sizes 2022-08-06 14:42:05 -07:00
N00byEdge 18440cb239 std.mem.zeroes: Zero sized structs with uninitialized members (#12246)
`std.mem.zeroes(struct{handle: void})` Failed with the following error before:
```
/nix/store/l6v4359wc9xrxxmvvp3rynsb5s3d78xf-zig-0.9.1/lib/zig/std/mem.zig:270:42: error: missing field: 'handle'
            if (@sizeOf(T) == 0) return T{};
                                         ^
```
2022-08-05 15:47:52 +03:00
Allan Regush 44c321c05e std.enums: make directEnumArrayLen public 2022-08-05 15:41:03 +03:00