12095 Commits

Author SHA1 Message Date
Jakub Konka
bd99a87dc2 macho: create dSym bundle next to final artefact
macOS requires the debug symbols to either be part of the intermediate
object file `whatever.o` or a companion `whatever.dSym` bundle. The
former case seems ill-suited for our needs since it subscribes to
the old-fashioned compilation strategy using intermediate compilation
units; the latter is what we need however on macOS the debug symbols
unlike in Elf are not part of the final artefact; rather they sit
next to it in its own Mach-O file.
2020-12-31 10:19:04 +01:00
Jakub Konka
0ff56e8bb1 macho: add and populate UUID load command 2020-12-31 10:19:04 +01:00
Jakub Konka
e1451f92f8 macho: move findFreeSpace into SegmentCommand
One exception will be treatment of the __LINKEDIT segment which
will be handled separately inside MachO directly since it doesn't
include any sections.
2020-12-31 10:19:04 +01:00
Andrew Kelley
595397dbeb
Merge pull request #7601 from jayschwa/stage2-semver
stage2: SemVer compliance for development builds
2020-12-31 01:15:18 -08:00
Luna
7550af0d4c ci: freebsd: use py37-s3cmd 2020-12-31 08:18:06 +01:00
Andrew Kelley
3f7d9b5fc1 stage2: rework Value Payload layout
This is the same as the previous commit but for Value instead of Type.

Add `Value.castTag` and note that it is preferable to call than
`Value.cast`. This matches other abstractions in the codebase.

Added a convenience function `Value.Tag.create` which really cleans up
the callsites of creating `Value` objects.

`Value` tags can now share payload types. This is in preparation for
another improvement that I want to do.
2020-12-30 21:41:02 -08:00
Andrew Kelley
133da8692e stage2: rework Type Payload layout
Add `Type.castTag` and note that it is preferable to call than
`Type.cast`. This matches other abstractions in the codebase.

Added a convenience function `Type.Tag.create` which really cleans up
the callsites of creating `Type` objects.

`Type` payloads can now share types. This is in preparation for another
improvement that I want to do.
2020-12-30 21:41:02 -08:00
Jay Petacat
02438aabe3 Remove 'g' prefix from commit hash in Zig semver 2020-12-30 20:57:50 -06:00
LemonBoy
2622575fde std: Remove duplicated code
Make osRequiresLibC call Os.requiresLibC, let's keep a single list of OS
that require the libc to be linked in.
2020-12-30 14:45:39 -08:00
LemonBoy
daed2ba2a0 std: Add more standard type definitions for FreeBSD
Closes #7550
2020-12-30 10:25:43 -08:00
Jay Petacat
4af763d401 stage2: SemVer compliance for development builds
This matches the behavior of CMake builds. These changes should have
been in PR #6509, but were missed.
2020-12-29 23:25:58 -06:00
Isaac Freund
3634d44d08 std: fix Reader.readUntilDelimiterOrEofAlloc() API
The current API does not allow the user to distinguish between EOF and
an empty line. Reader.readUntilDelimiterOrEof() gets this API right so
update readUntilDelimiterOrEofAlloc() to match it. Returning an optional
here additionally makes calling this in a loop much cleaner.

Remove readUntilDelimiterOrEofArrayList() as it no longer needed to
implement readUntilDelimiterOrEof() and has the same API issues
described without a clear way to fix them.
2020-12-29 19:09:36 -08:00
Andrew Kelley
3d79ae2be3 stage2 tests: improve C backend testing
Add -Werror -pedantic -std=c89 to make sure our outputted C code is
squeaky clean.

Allow garbage to be printed to stderr for Execution tests because
wasmtime is printing a bogus warning, causing the CI to fail.
2020-12-29 20:01:18 -07:00
Andrew Kelley
d18b6785bb stage2: C backend improvements
* Module: improve doc comments
 * C backend: improve const-correctness
 * C backend: introduce renderTypeAndName
 * C backend: put `static` on functions when appropriate
 * C backend: fix not handling errors in genBinOp
 * C backend: handle more IR instructions
   - alloc, store, boolean comparisons, ret_ptr
 * C backend: call instruction properly stores its result
 * test harness: ensure execution tests have empty stderr
2020-12-29 17:56:30 -07:00
Jay Petacat
bbe2cca1ae Comply with semantic versioning pre-release format
Example version: 0.8.0-dev.460+g81b343a16

From a semantic versioning perspective, development builds will now be
considered distinct from a tagged release. The number of commits added
since the last tag is included in the pre-release component.

Updates #6466
2020-12-29 13:17:08 -08:00
Andrew Kelley
8078d8cd3f std.ChildProcess: fix max_output_bytes handling
The previous logic had a false positive of returning an error when in
fact the maximum number of output bytes had not been exceeded.
2020-12-29 14:02:12 -07:00
Andrew Kelley
0b46c27333 zig test: release Compilation Cache locks
before executing child process. This fixes a deadlock when the test
wanted to obtain the same lock on compiler_rt.o that was held by the
process building the test binary itself.
2020-12-29 11:47:29 -07:00
Andrew Kelley
e54fd25781 Merge branch 'LemonBoy-cprocess'
This is a partial merge of #6750. I took the Posix code paths and
dropped the Windows code paths, and then did the improvements noted in
the comments.

The Windows implementation is still TODO.
2020-12-29 11:16:28 -07:00
Andrew Kelley
717cf00fe0 std.ChildProcess: improvements to collectOutputPosix
* read directly into the ArrayList buffers.
 * respect max_output_bytes

 * std.ArrayList:
   - make `allocatedSlice` public.
   - add `unusedCapacitySlice`.

I removed the Windows implementation of this stuff; I am doing a partial
merge of LemonBoy's patch with the understanding that a later patch can
add the Windows implementation after it is vetted.
2020-12-29 11:13:00 -07:00
LemonBoy
892b37cdae std: Use WINAPI instead of .Stdcall 2020-12-29 10:40:28 -07:00
LemonBoy
b297c2eae9 std: Fix compilation on FreeBSD/Darwin 2020-12-29 10:40:26 -07:00
LemonBoy
1667c937a0 std: Uniform polling logic for Windows and Unix
Keep polling until there are enough open handles, if the child process
terminates closing the handles or explicitly closes them we just quit
polling and wait for the process handle to signal the termination
condition.
2020-12-29 10:40:00 -07:00
LemonBoy
2c16a96686 std: Fix poll definitions for FreeBSD/Darwin 2020-12-29 10:40:00 -07:00
LemonBoy
dc810eb73b std: Avoid deadlocking in ChildProcess.exec
Reading stdin&stderr at different times may lead to nasty deadlocks (eg.
when stdout is read before stderr and the child process doesn't write
anything onto stdout).

Implement a polling mechanism to make sure this won't happen: we read
data from stderr/stdout as it becomes ready and then it's copied into an
ArrayList provided by the user, avoiding any kind of blocking read.
2020-12-29 10:40:00 -07:00
Andrew Kelley
1590ed9d6a stage2 tests: pass cwd to child process to fix exe path
Previous commit broke the tests for non-Windows because we were
intending to change the cwd when running the child process. However, for
Windows we don't support passing a directory handle for cwd when
spawning child processes yet. However on Linux we do. This commit
reverts the previous one but then fixes things for all systems by
passing both cwd_dir and cwd to the child process.
2020-12-29 00:33:08 -07:00
Andrew Kelley
7e1e771f02 stage2 tests: fix incorrect path used for execution binary 2020-12-28 23:06:47 -08:00
Andrew Kelley
79a5151155 Revert "stage2: fix compilation of self-hosted compiler with -Denable-llvm"
This broke compiling with -Dstage1 on Windows, because it added the
cpp_source_files to the compilation multiple times.

This reverts commit c81ae52ee0b2e952f8ed9c5c6517af8182bb09c1.
2020-12-28 22:41:29 -08:00
Frank Denis
8ab870cf56 std/crypto: increment the correct words for vectorized salsa20
Add a test for this by the way.

Fixes #7579
2020-12-28 21:28:39 -08:00
Andrew Kelley
1dd5c032bf stage2 tests: better failure reporting for failed execution 2020-12-28 22:21:25 -07:00
Andrew Kelley
a62353fb4b fix zig test with regards to passing parameters 2020-12-28 22:15:07 -07:00
Andrew Kelley
e0a78d10cc stage2: better error message for root zig source file not found
closes #6777
closes #6893
2020-12-28 21:49:40 -07:00
Andrew Kelley
78dcd1b23e std.process: update arg iterator tests
These tests asserted there were no args passed to the test binary, but
now there is an arg intentionally passed to the test binary, so the test
case needed to be updated.
2020-12-28 21:09:47 -07:00
Andrew Kelley
3b5dd48f99 Merge branch 'hello-c-backend' into master
This branch introduces a new kind of test into the stage2 test harness:
Zig code that compiles into C code with the C backend, and then the
resulting C code gets run and output compared against the expected
result.

This branch also implements extern functions in the frontend so that we
can have a "hello world" C backend test that passes.
2020-12-28 20:32:53 -07:00
Andrew Kelley
813d3308cc stage2: update C backend test cases for new output 2020-12-28 20:32:13 -07:00
Andrew Kelley
bbe66572e1 stage2: C backend: handle string literals more gracefully 2020-12-28 20:15:17 -07:00
Andrew Kelley
7561fca435 stage2: improve test harness to support executing generated C code 2020-12-28 20:01:17 -07:00
Andrew Kelley
7ca9f3bc7b zig test: std.testing.zig_exe_path is now available
it will be set to the path of the zig executable which is running
`zig test`.
2020-12-28 20:00:34 -07:00
Andrew Kelley
a54ccd8537 stage2: C backend: implement @breakpoint and clean up test harness 2020-12-28 18:43:01 -07:00
Andrew Kelley
37f04d66be stage2: C backend: properly render type of array decls 2020-12-28 18:24:55 -07:00
Andrew Kelley
52056b156b stage2: C backend: pointer cast decl refs if necessary 2020-12-28 17:46:50 -07:00
Andrew Kelley
87c6341b61 stage2: add extern functions
and improve the C backend enough to support Hello World (almost)
2020-12-28 17:15:29 -07:00
Andrew Kelley
2df2f0020f
Merge pull request #7498 from FireFox317/stage2-llvm
stage2: add initial impl of LLVM backend in self-hosted compiler
2020-12-28 15:07:21 -08:00
Timon Kruiper
ec3aedffb1 stage2: add initial implementation of func arguments in LLVM backend
The following works:
```
export fn _start() noreturn {
    assert(true);
    exit();
}

fn assert(cond: bool) void {}

fn exit() noreturn {
    unreachable;
}
```
2020-12-28 21:20:49 +01:00
Timon Kruiper
4a32d4f288 stage2: refactor (simplify) code structure of llvm_backend.zig 2020-12-28 21:20:49 +01:00
Timon Kruiper
09cf043efd stage2: add missing asserts and early returns for LLVM backend 2020-12-28 21:20:49 +01:00
Timon Kruiper
6b8d28312c stage2: fix building self-hosted without llvm-backend enabled. 2020-12-28 21:20:49 +01:00
Timon Kruiper
b059bb84b8 stage2: add LLVM codegen windows support to the self-hosted compiler
The following example generates a valid `main.exe`:
`zig build-exe main.zig -fLLVM -target x86_64-windows-gnu --subsystem console`

```
export fn wWinMainCRTStartup() noreturn {
    foo();
    exit();
}

fn foo() void {}

fn exit() noreturn {
    unreachable;
}
```
2020-12-28 21:20:46 +01:00
Timon Kruiper
071417161d stage2: add initial impl of LLVM backend in self-hosted compiler 2020-12-28 21:19:40 +01:00
Timon Kruiper
4a0d64300b stage2: rename llvm.zig to llvm_bindings.zig
Putting functions in this file will create functions like
`llvm.function`, and the compiler thinks these are llvm intrinsics.
2020-12-28 21:15:13 +01:00
Timon Kruiper
c81ae52ee0 stage2: fix compilation of self-hosted compiler with -Denable-llvm 2020-12-28 21:15:13 +01:00