12963 Commits

Author SHA1 Message Date
Jacob Young
1eb023908d x86_64: implement float round builtins 2023-10-01 15:09:52 -04:00
Jacob Young
c3042cbe12 x86_64: add missing caller preserved regs
All allocatable registers have to be either callee preserved or caller
preserved.
2023-10-01 15:09:52 -04:00
Jacob Young
8470652f10 x86_64: implement float compare and cast builtins 2023-10-01 15:09:52 -04:00
Jacob Young
6d5cbdb863 behavior: cleanup floatop tests 2023-10-01 15:09:52 -04:00
Jacob Young
3bd1b9e15f x86_64: implement and test unary float builtins 2023-10-01 15:09:52 -04:00
Jakub Konka
af40bce08a x86_64: emit R_X86_64_GOT32 for non-PIC GOT references 2023-10-01 21:09:35 +02:00
Veikka Tuominen
63bd2bff12 Sema: add @errorCast which works for both error sets and error unions
Closes #17343
2023-10-01 17:00:01 +03:00
Ian Johnson
9a001e1f7c Support fetching dependencies over git+http(s)
Closes #14298

This commit adds support for fetching dependencies over git+http(s)
using a minimal implementation of the Git protocols and formats relevant
to fetching repository data.

Git URLs can be specified in `build.zig.zon` as follows:

```zig
.xml = .{
    .url = "git+https://github.com/ianprime0509/zig-xml#7380d59d50f1cd8460fd748b5f6f179306679e2f",
    .hash = "122085c1e4045fa9cb69632ff771c56acdb6760f34ca5177e80f70b0b92cd80da3e9",
},
```

The fragment part of the URL may specify a commit ID (SHA1 hash), branch
name, or tag. It is an error to omit the fragment: if this happens, the
compiler will prompt the user to add it, using the commit ID of the HEAD
commit of the repository (that is, the latest commit of the default
branch):

```
Fetch Packages... xml... /var/home/ian/src/zig-gobject/build.zig.zon:6:20: error: url field is missing an explicit ref
            .url = "git+https://github.com/ianprime0509/zig-xml",
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: try .url = "git+https://github.com/ianprime0509/zig-xml#dfdc044f3271641c7d428dc8ec8cd46423d8b8b6",
```

This implementation currently supports only version 2 of Git's wire
protocol (documented in
[protocol-v2](https://git-scm.com/docs/protocol-v2)), which was first
introduced in Git 2.19 (2018) and made the default in 2.26 (2020).

The wire protocol behaves similarly when used over other transports,
such as SSH and the "Git protocol" (git:// URLs), so it should be
reasonably straightforward to support fetching dependencies from such
URLs if the necessary transports are implemented (e.g. #14295).
2023-09-30 18:30:43 -07:00
Andrew Kelley
937e8cb705
Merge pull request #17328 from ziglang/simplify-cbe-deps
C backend: remove unneeded ordering mechanism
2023-09-30 01:26:00 -07:00
Jakub Konka
873c695c41
Merge pull request #17319 from ziglang/elf-tls
elf: add basic TLS segment handling
2023-09-30 08:43:33 +02:00
Andrew Kelley
864bb5dc07 C backend: iterate decl_table via slice 2023-09-29 19:14:17 -07:00
Andrew Kelley
7c605ba62c C backend: remove ?*Decl from DeclGen
Another simplification. DeclGen already has `decl_index` which can be
used to retrieve the `*Decl` if needed.
2023-09-29 19:14:17 -07:00
Andrew Kelley
0d841e827a C backend: remove unneeded ordering mechanism
This logic to lower snippets of C code in a dependency order is no
longer needed. Simplify the logic by deleting the mechanism.
2023-09-29 19:14:17 -07:00
Jakub Konka
e72fd185e0 elf: skip writing out zerofill atoms to file 2023-09-30 00:52:10 +02:00
Jakub Konka
6c50ad6e9f elf: set sh_size to 0 for nobit sections in collision detection
`SHT_NOBITS` sections take no file space after all.
2023-09-29 22:37:59 +02:00
Jakub Konka
e5e6984652 elf: dump state for debugging after writing it all out 2023-09-29 22:29:06 +02:00
Jakub Konka
5381bfd348 elf: fix setting st_value of _end synthetic symbol 2023-09-29 22:18:38 +02:00
Jakub Konka
8e90b41ae0 elf: set shdr/phdr file size before growing in VM 2023-09-29 21:43:01 +02:00
Jakub Konka
304d38e844 elf: simplify logic for growing non-alloc sections 2023-09-29 20:35:28 +02:00
Jakub Konka
0524a3c83d elf: fix calculating current allocated section size when growing alloc sections 2023-09-29 19:06:02 +02:00
Adam Goertz
e07e182fc1 Extract logic for directory packages
In addition to improving readability, this also fixes a subtle bug
where the Progress node could display the wrong total number of packages to fetch.
2023-09-29 00:32:43 -07:00
AdamGoertz
4594206e72 Fix diamond dependencies with directory packages 2023-09-29 00:32:43 -07:00
AdamGoertz
c6b9205005 Purge absolute paths and remove unneeded path processing
No need to create paths with windows-specific path separators
2023-09-29 00:32:43 -07:00
Adam Goertz
2f0e5b00b0 Allow only relative paths.
This commit makes the following changes:
* Disallow file:/// URIs
* Allow only relative paths in the .path field of build.zig.zon
* Remote now-unneeded shlwapi dependency
2023-09-29 00:32:43 -07:00
Adam Goertz
b3cad98534 Support file:/// URIs and relative paths 2023-09-29 00:32:43 -07:00
Andrew Kelley
8f2f12f940 Compilation: introduce saveState()
This commit introduces `--debug-incremental` so that we can start
playing around with incremental compilation while it is still being
developed, and before it is enabled by default.

Currently it saves InternPool data, and has TODO comments for the
remaining things. Deserialization is not implemented yet, which will
require some post-processing such as to build a string map out of
null-terminated string table bytes.

The saved compiler state is stored in a file called <root-name>.zcs
alongside <root-name>.o, <root-name>.pdb, <root-name>.exe, etc. In case
of using the zig build system, these files are all in a zig-cache
directory.

For the self-hosted compiler, here is one data point on the performance
penalty of saving this data:

```
Benchmark 1 (3 runs): zig build-exe ...
  measurement          mean ± σ            min … max           outliers         delta
  wall_time          51.1s  ±  354ms    50.7s  … 51.4s           0 ( 0%)        0%
  peak_rss           3.91GB ±  354KB    3.91GB … 3.91GB          0 ( 0%)        0%
  cpu_cycles          212G  ± 3.17G      210G  …  216G           0 ( 0%)        0%
  instructions        274G  ± 57.5M      274G  …  275G           0 ( 0%)        0%
  cache_references   13.1G  ± 97.6M     13.0G  … 13.2G           0 ( 0%)        0%
  cache_misses       1.12G  ± 24.6M     1.10G  … 1.15G           0 ( 0%)        0%
  branch_misses      1.53G  ± 1.46M     1.53G  … 1.53G           0 ( 0%)        0%
Benchmark 2 (3 runs): zig build-exe ... --debug-incremental
  measurement          mean ± σ            min … max           outliers         delta
  wall_time          51.8s  ±  271ms    51.5s  … 52.1s           0 ( 0%)          +  1.3% ±  1.4%
  peak_rss           3.91GB ±  317KB    3.91GB … 3.91GB          0 ( 0%)          -  0.0% ±  0.0%
  cpu_cycles          213G  ±  398M      212G  …  213G           0 ( 0%)          +  0.3% ±  2.4%
  instructions        275G  ± 79.1M      275G  …  275G           0 ( 0%)          +  0.1% ±  0.1%
  cache_references   13.1G  ± 26.9M     13.0G  … 13.1G           0 ( 0%)          -  0.1% ±  1.2%
  cache_misses       1.12G  ± 5.66M     1.11G  … 1.12G           0 ( 0%)          -  0.6% ±  3.6%
  branch_misses      1.53G  ± 1.75M     1.53G  … 1.54G           0 ( 0%)          +  0.2% ±  0.2%
```

At the end of each compilation with `--debug-incremental`, we end up
with a 43 MiB `zig.zcs` file that contains all of the InternPool data
serialized.

Of course, it will necessarily be more expensive to save the state than
to not save the state. However, this data point shows just how cheap the
save state operation is, with all of the groundwork laid for using a
serialization-friendly in-memory data layout.
2023-09-28 16:28:41 -07:00
Jakub Konka
04a7051c4b elf: fix 32bit build 2023-09-28 21:42:09 +02:00
Jakub Konka
89c2151a97 elf: move logic for extracing atom's code into input files 2023-09-28 18:35:26 +02:00
Jakub Konka
785bd270ed elf: correctly allocate TLS segment 2023-09-28 14:59:09 +02:00
Jakub Konka
1063035be6
Merge pull request #17304 from ziglang/elf-grow-vm-2
elf: grow segments in virtual memory if they exceed allocated capacity
2023-09-28 14:29:35 +02:00
Jakub Konka
af00ac53b5 elf: report fatal linker error for unhandled relocation types 2023-09-28 14:06:12 +02:00
Jakub Konka
a63ce5a37c elf: allocate .tdata and .tbss sections 2023-09-28 13:29:04 +02:00
Emil Lerch
fcca3cd1a3
std.http: introduce options to http client to allow for raw uris
Addresses #17015 by introducing a new startWithOptions. The only option is currently is a flag
to use the provided URI as is, without modification when passed to the server. Normally, this
is not needed nor desired. However, some REST APIs may have requirements that cannot be satisfied
with the default handling.
2023-09-28 14:16:39 +03:00
Jakub Konka
22127a8792 elf: pre-allocate TLS load segment and PT_TLS phdr 2023-09-28 12:06:21 +02:00
Jakub Konka
42011a8249 elf: remove explicit load segment alloc - we can replicate programmatically now 2023-09-28 11:46:40 +02:00
Ryan Liptak
a362d3963c resinator: Update to latest, fix for big endian arch 2023-09-28 02:25:52 -07:00
Jakub Konka
df285949f7 elf: do not assume segments laid out in increasing order in VM space 2023-09-28 08:47:58 +02:00
Andrew Kelley
937138cb90
Merge pull request #17248 from antlilja/abs
Replace @fabs builtin with new @abs builtin
2023-09-27 17:25:19 -07:00
Veikka Tuominen
ab3ac1e670 Value: fix assertion failure when mutating extern union
Closes #17292
2023-09-27 11:47:24 -07:00
Andrew Kelley
1c02e58fc0 Revert "compiler: don't use @abs builtin yet"
This reverts commit 21780899eb17a0cb795ff40e5fae6556c38ea13e.

After this commit, a version of the compiler which supports the new
`@abs` builtin is required.
2023-09-27 11:23:28 -07:00
Andrew Kelley
21780899eb compiler: don't use @abs builtin yet
This commit can be used to rebuild zig1.wasm
2023-09-27 11:21:59 -07:00
antlilja
6a29646a55 Rename @fabs to @abs and accept integers
Replaces the @fabs builtin with a new @abs builtins which accepts
floats, signed integers and vectors of said types.
2023-09-27 11:15:53 -07:00
Jakub Konka
8f90dbba55 elf: fix typo in selecting larger addrspace for load segments 2023-09-27 20:05:46 +02:00
Jakub Konka
8b7255c22a elf: hint allocateSegment where to put the segment at 2023-09-27 19:41:59 +02:00
Jakub Konka
111349f83c elf: do not update globals not defined by the object 2023-09-27 19:22:57 +02:00
Jakub Konka
85132965f4 elf: use new error reporting API 2023-09-27 16:40:51 +02:00
Jakub Konka
09863fc970 elf: emit fatal linker error if we run out of VM space with self-hosted backends 2023-09-27 15:07:05 +02:00
Andrew Kelley
1606717b5f C backend: flatten out some of the long-lived state
When the compiler's state lives through multiple Compilation.update()
calls, the C backend stores the rendered C source code for each
decl code body and forward declarations.

With this commit, the state is still stored, but it is managed in one
big array list in link/C.zig rather than many array lists, one for each
decl. This means simpler serialization and deserialization.
2023-09-27 04:09:22 -07:00
kcbanner
70563aeac3 windows: fix not finding system libs when compiling for *-windows-msvc
When compiling for *-windows-msvc, find the native libc_installation and
add the lib dirs to lib_dirs, so that system libs can be found.

Previously, `version` and `ole32` were detected via the mingw.libExists logic,
even on .msvc, which was a false positive. This detection logic for mingw doesn't
find uuid.lib, which was the failure that triggered this bugfix.

Only build the issue_5825 test if the native target is x86_64-windows-msvc,
since it requires the .msvc abi.
2023-09-27 04:07:12 -07:00
Jakub Konka
e178580d86 elf: pre-allocate large VM capacity per segment 2023-09-27 10:00:20 +02:00