12124 Commits

Author SHA1 Message Date
g-w1
a1a1929cf4 Fix #7296:
* makes '$build_root/{install,debug}/' the default prefix. This makes it not '$pwd/zig-cache/'.
2020-12-31 20:02:07 -05:00
Andrew Kelley
93bb1d93cd
Merge pull request #7616 from ziglang/stage2-inferred-vars
stage2: inferred local variables
2020-12-31 16:28:08 -08:00
Andrew Kelley
982acc22fd stage2: compile error for invalid var type 2020-12-31 17:25:42 -07:00
Andrew Kelley
79a9391414 stage2: no Payload for Type.Tag.inferred_alloc
Simpler, less memory usage. The Value has all the info needed.
2020-12-31 16:51:40 -07:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
Andrew Kelley
69da6ba14d Merge branch 'revert-semver'
Updating the download page is stuck because in all cases
`zig version` is outputting 0.8.0 rather than e.g.
0.8.0-dev.716+fbf269cc4.

See #6466
2020-12-31 16:41:54 -07:00
Andrew Kelley
d96d8639e5 Revert "Comply with semantic versioning pre-release format"
This reverts commit bbe2cca1ae32af322abcf4cc4a6d6bee671bf5b8.
2020-12-31 16:41:42 -07:00
Andrew Kelley
e8810f5794 Revert "stage2: SemVer compliance for development builds"
This reverts commit 4af763d401b48f7186650335c8e42e8fe29751bf.
2020-12-31 16:41:35 -07:00
Andrew Kelley
9afe5859a3 Revert "Remove 'g' prefix from commit hash in Zig semver"
This reverts commit 02438aabe3a04ac8ca2a2e0b2501ba18885652e3.
2020-12-31 16:41:24 -07:00
Jakub Konka
fbf269cc47 More MachO.zig fixes ensuring 32bit compat
Partial resolution to #7614.
2020-12-31 14:57:08 +01:00
LemonBoy
102e45e04f stage1: Remove stray brace in rarely-tested code path
This should fix #7614 or part of it.
2020-12-31 14:35:19 +01:00
Jakub Konka
707b81ec37 Make sure MachO.zig compiles on 32bit hosts
This should fix #7614 or part of it.
2020-12-31 14:30:53 +01:00
Jakub Konka
46ea7a704c
Merge pull request #7608 from kubkon/macho-dsym
macho: add preliminary support for DWARF debugging symbols
2020-12-31 11:38:13 +01:00
Andrew Kelley
7deb1f4f6c stage2: type inference for local var 2020-12-31 02:42:48 -07:00
Jakub Konka
0fd3015e55 macho: sentinel can be 4 byte long 2020-12-31 10:19:04 +01:00
Jakub Konka
9369176332 macho: advance VM address of DWARF sections when relocating 2020-12-31 10:19:04 +01:00
Jakub Konka
ea4ff34e13 macho: put all DWARF-related logic into DebugSymbols 2020-12-31 10:19:04 +01:00
Jakub Konka
d189614647 macho: move updateDeclLineNumber logic to DebugSymbols 2020-12-31 10:19:04 +01:00
Jakub Konka
60b3c4ae3c macho: refactor and fix stage2 tests 2020-12-31 10:19:04 +01:00
Jakub Konka
364691fa1f macho: add decl line and file info to subprogram 2020-12-31 10:19:04 +01:00
Jakub Konka
fa28f7006d macho: fix bundle name to .dSYM 2020-12-31 10:19:04 +01:00
Jakub Konka
9318656ce2 macho: use 32bit DWARF format 2020-12-31 10:19:04 +01:00
Jakub Konka
2875a7335a macho: add Elf dwarf sections 2020-12-31 10:19:04 +01:00
Jakub Konka
d4725cb40b macho: prealloc space for debug sections in dSym 2020-12-31 10:19:04 +01:00
Jakub Konka
3174508903 macho: write symbol and string tables to dSym 2020-12-31 10:19:04 +01:00
Jakub Konka
d9ce7a021b macho: copy snapshots of segment commands 2020-12-31 10:19:04 +01:00
Jakub Konka
a7bae1b857 macho: write matching UUID to dSym bundle 2020-12-31 10:19:04 +01:00
Jakub Konka
cf94341910 macho: write Mach-O dSym header 2020-12-31 10:19:04 +01:00
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
Andrew Kelley
a46d24af1c stage2: inferred local variables
This patch introduces the following new things:

Types:
 - inferred_alloc
   - This is a special value that tracks a set of types that have been stored
     to an inferred allocation. It does not support most of the normal type queries.
     However it does respond to `isConstPtr`, `ptrSize`, `zigTypeTag`, etc.
   - The payload for this type simply points to the corresponding Value
     payload.

Values:
 - inferred_alloc
   - This is a special value that tracks a set of types that have been stored
     to an inferred allocation. It does not support any of the normal value queries.

ZIR instructions:
 - store_to_inferred_ptr,
   - Same as `store` but the type of the value being stored will be used to infer
     the pointer type.
 - resolve_inferred_alloc
   - Each `store_to_inferred_ptr` puts the type of the stored value into a set,
     and then `resolve_inferred_alloc` triggers peer type resolution on the set.
     The operand is a `alloc_inferred` or `alloc_inferred_mut` instruction, which
     is the allocation that needs to have its type inferred.

Changes to the C backend:
 * Implements the bitcast instruction. If the source and dest types
   are both pointers, uses a cast, otherwise uses memcpy.
 * Tests are run with -Wno-declaration-after-statement. Someday we can
   conform to this but not today.

In ZIR form it looks like this:

```zir
fn_body main { // unanalyzed
  %0 = dbg_stmt()
=>%1 = alloc_inferred()
  %2 = declval_in_module(Decl(add))
  %3 = deref(%2)
  %4 = param_type(%3, 0)
  %5 = const(TypedValue{ .ty = comptime_int, .val = 1})
  %6 = as(%4, %5)
  %7 = param_type(%3, 1)
  %8 = const(TypedValue{ .ty = comptime_int, .val = 2})
  %9 = as(%7, %8)
  %10 = call(%3, [%6, %9], modifier=auto)
=>%11 = store_to_inferred_ptr(%1, %10)
=>%12 = resolve_inferred_alloc(%1)
  %13 = dbg_stmt()
  %14 = ret_type()
  %15 = const(TypedValue{ .ty = comptime_int, .val = 3})
  %16 = sub(%10, %15)
  %17 = as(%14, %16)
  %18 = return(%17)
} // fn_body main
```

I have not played around with very many test cases yet. Some interesting
ones that I want to look at before merging:

```zig
var x = blk: {
  var y = foo();
  y.a = 1;
  break :blk y;
};
```

In the above test case, x and y are supposed to alias.

```zig
var x = if (bar()) blk: {
  var y = foo();
  y.a = 1;
  break :blk y;
} else blk: {
  var z = baz();
  z.b = 1;
  break :blk z;
};
```

In the above test case, x, y, and z are supposed to alias.

I also haven't tested with `var` instead of `const` yet.
2020-12-31 01:54:02 -07: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