26078 Commits

Author SHA1 Message Date
Veikka Tuominen
47050fbb7d aro translate-c: update to cast builtin changes 2023-10-01 23:51:54 +03:00
Veikka Tuominen
7ec729b3ae aro-translate-c: move shared types to a common namespace 2023-10-01 23:51:54 +03:00
Veikka Tuominen
31ecf75311 aro-translate-c: translate enums 2023-10-01 23:51:54 +03:00
Veikka Tuominen
fef94da958 add compiler flag for selecting C frontend 2023-10-01 23:51:54 +03:00
Jakub Konka
af40bce08a x86_64: emit R_X86_64_GOT32 for non-PIC GOT references 2023-10-01 21:09:35 +02:00
Andrew Kelley
8e1421f19e
Merge pull request #17346 from Vexu/errSetCast
Sema: implement `@errSetCast` for error unions
2023-10-01 12:00:17 -07:00
Veikka Tuominen
0b1ba6eb52
update zig1.wasm 2023-10-01 17:16:34 +03: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
Jay Petacat
d8bfbbbf25 std.mem.zeroes: Zero out entire extern union, including padding
Fixes #17258
2023-10-01 02:39:05 -07:00
Andrew Kelley
376242e586
Merge pull request #17161 from tiehuis/vectorize-index-of-scalar
std.mem: add vectorized indexOfScalarPos and indexOfSentinel
2023-10-01 00:07:57 -07: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
Lucas Santos
303181901b Improve (Unmanaged)ArrayList.insert
(Unmanaged)ArrayList.insert has the same inefficiency as the old insertSlice. With the new addManyAt, the solution is trivial.
Also improves the test "growing memory preserves contents". In the previous implementation, if any changes were made to the ArrayList memory growth policy (function growMemory), the list could end up with enough capacity to not trigger a memory growth, defeating the purpose of the test. The new implementation more robustly triggers a memory growth.
2023-09-30 16:17:22 -07:00
Marc Tiehuis
08635f08a9 fix indexOfSentinel alignment for types larger than 1 byte 2023-09-30 22:15:47 +13: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
Marc Tiehuis
5b5da0ef8c std.mem: check backend vector support for indexOfSentinel/indexOfScalarPos 2023-09-30 21:22:12 +13:00
Marc Tiehuis
cd766513fe std.mem: add vectorized indexOfScalarPos and indexOfSentinel
These are an order of magnitude quicker than the previous
implementations:

A relative comparison of each, measuring scanning a 1G file.

    Reading 1G (1.0000000009313226GiB)

             std.mem.sliceTo: 281.232ms
          vectorized.sliceTo: 24.769ms
                      strlen: 24.291ms

           std.indexOfScalar: 229.016ms
    vectorized.indexOfScalar: 24.685ms
                      memchr: 24.958ms
2023-09-30 21:19:43 +13: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
Andrew Kelley
101df768a0
Merge pull request #17312 from LucasSantos91/master
Fix inefficiency with ArrayList.insertSlice
2023-09-29 18:15:24 -07:00
Jakub Konka
e72fd185e0 elf: skip writing out zerofill atoms to file 2023-09-30 00:52:10 +02:00
Krzysztof Wolicki
19a82ffdba
Add include_extensions to InstallDir Options (#17300)
closes #16687
2023-09-29 18:50:37 -04:00
Andrew Kelley
9013970861 std.ArrayList: fixups for the previous commit
* Move `computeBetterCapacity` to the bottom so that `pub` stuff shows
   up first.
 * Rename `computeBetterCapacity` to `growCapacity`. Every function
   implicitly computes something; that word is always redundant in a
   function name. "better" is vague. Better in what way? Instead we
   describe what is actually happening. "grow".
 * Improve doc comments to be very explicit about when element pointers
   are invalidated or not.
 * Rename `addManyAtIndex` to `addManyAt`. The parameter is named
   `index`; that is enough.
 * Extract some duplicated code into `addManyAtAssumeCapacity` and make
   it `pub`.
 * Since I audited every line of code for correctness, I changed the
   style to my personal preference.
 * Avoid a redundant `@memset` to `undefined` - memory allocation does
   that already.
 * Fixed comment giving the wrong reason for not calling
   `ensureTotalCapacity`.
2023-09-29 13:42:38 -07: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
Lucas Santos
9d765b5ab5 std.ArrayList: insertSlice avoids extra memcpy
Includes a more robust implementation of replaceRange, which updates the
ArrayListUnmanaged if state changes in the managed part of the code
before returning an error.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2023-09-29 12:52:40 -07: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
Krzysztof Wolicki
e919fbea9f
Step.Run: fix assert of the wrong value (#17303)
closes #16866
2023-09-29 14:14:42 -04:00
Jakub Konka
0524a3c83d elf: fix calculating current allocated section size when growing alloc sections 2023-09-29 19:06:02 +02:00
Andrew Kelley
c07d6e4c17
Merge pull request #14603 from AdamGoertz/file-uris
Support relative paths in package manager
2023-09-29 00:34:07 -07: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
Philipp Lühmann
ed19ebc360
std.math.big.int.Const.order 0 == -0 (#17299) 2023-09-29 18:09:47 +13:00
Luis Cáceres
acac685621
std.Build.ConfigHeader: override include guard option for blank style (#17310)
This commit adds an option to allow for overriding the default header guard that is generated from the output
file path.
2023-09-28 19:30:42 -04: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
Andrew Kelley
077994abb6
Merge pull request #17318 from gh-fork-dump/linux-5.6-cachestat
Update Linux syscalls for 5.5 and add a wrapper for `cachestat`
2023-09-28 16:27:28 -07:00
Christofer Nolander
c4ad6be002
Allow empty enum to be used in EnumSet/EnumMap
Moves the check for empty fields before any access to those fields.
2023-09-28 21:48:39 +00:00
Jakub Konka
04a7051c4b elf: fix 32bit build 2023-09-28 21:42:09 +02:00
Jakub Konka
cdd4dbfe32 test: add x86_64-linux-musl-no-lld as a test target 2023-09-28 19:28:06 +02:00
Jakub Konka
89c2151a97 elf: move logic for extracing atom's code into input files 2023-09-28 18:35:26 +02:00
Karl Seguin
599641357c
std.mem: use for loop instead of while in indexOf* to reduce bound checking 2023-09-28 15:40:08 +00:00
Jakub Konka
91f2e66bf9 elf: test TLS in static programs 2023-09-28 15:13:35 +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