Commit graph

28077 commits

Author SHA1 Message Date
Andrew Kelley
d40b71a39f CI: update wasmtime to v10.0.2
The newest release changes the CLI; let's wait until that breaking
change finds its way into system package managers before updating to it.
2024-02-11 13:38:56 -07:00
Andrew Kelley
eda58a2f46 TypedValue: fix printing some nested things 2024-02-11 13:38:56 -07:00
Andrew Kelley
7680c5330c some API work on std.c, std.os, std.os.wasi
* std.c: consolidate some definitions, making them share code. For
  example, freebsd, dragonfly, and openbsd can all share the same
  `pthread_mutex_t` definition.
* add type safety to std.c.O
  - this caught a bug where mode flags were incorrectly passed as the
    open flags.
* 3 fewer uses of usingnamespace keyword
* as per convention, remove purposeless field prefixes from struct field
  names even if they have those prefixes in the corresponding C code.
* fix incorrect wasi libc Stat definition
* remove C definitions from incorrectly being in std.os.wasi
* make std.os.wasi definitions type safe
* go through wasi native APIs even when linking libc because the libc
  APIs are problematic and wasteful
* don't expose WASI definitions in std.posix
* remove std.os.wasi.rights_t.ALL: this is a footgun. should it be all
  future rights too? or only all current rights known? both are
  the wrong answer.
2024-02-11 13:38:55 -07:00
Luuk de Gram
320c4d68f5 wasm: correctly lower packed structs in arguments
When an argument is a 'local', which is the case when it's a parameter,
we should not attempt to load it from memory. Instead, we directly emit
it to the stack. Only when the `WValue` is ensure to live in the linear
data section do we load it from memory onto the stack.

closes #18894
2024-02-11 17:09:18 +01:00
Andrew Kelley
e56fe06d30
Merge pull request #18878 from alichraghi/vector
spirv: emit vectorized operations
2024-02-10 22:36:50 -08:00
Jakub Konka
d18f52197d macho: include compiler-rt in static lib if requested 2024-02-10 08:12:06 +01:00
Ali Chraghi
72bd1cd378 spirv: remove now-redundant isUnused calls from AIR handler functions 2024-02-10 09:50:02 +03:30
Jakub Konka
d12c8db642
Merge pull request #18875 from ziglang/macho-zo-dwarf
macho: emit DWARF for ZigObject relocatable
2024-02-09 23:12:04 +01:00
Prokop Randacek
6fb23542fe Buffer the logging function
The default logging function used to have no buffer. So a single log
statement could result in many individual write syscalls each writing
only a couple of bytes.

After this change the logging function now has a 4kb buffer. Only log
statements longer than 4kb now do multiple write syscalls.

4kb is the default bufferedWriter size and was choosen arbitrarily.

The downside of this is that the log function now allocates 4kb more
stack space but I think that is an acceptable trade-off.
2024-02-09 14:02:57 -08:00
Veikka Tuominen
731ff120d0 Sema: catch runtime stores to comptime variables through calls 2024-02-09 13:51:51 -08:00
Andrew Kelley
32f30399e5
Merge pull request #18867 from e4m2/random
std.rand: Move to std.Random
2024-02-09 13:42:04 -08:00
Andrew Kelley
54bbc73f85
Merge pull request #18712 from Vexu/std.options
std: make options a struct instance instead of a namespace
2024-02-09 13:38:42 -08:00
cdrmack
d3cf911a80 remove unused local variables 2024-02-09 23:11:46 +02:00
Ryan Liptak
0aff1f9ce5 Mark .zon as eol=lf
Fixes git autocrlf issues with .zon files on Windows
2024-02-09 18:49:54 +02:00
Tristan Ross
2a3e601f77 test.link.macho: fix for non-x86 and arm architectures
This fix is requires to make the build runner even compile when building
Zig on architectures like RISC-V.
2024-02-09 17:49:53 +02:00
Ali Chraghi
5ee96688a7 spirv: emit vectorized operations 2024-02-09 16:40:34 +03:30
Jakub Konka
83bbc39c15 ci: enable testing of non-llvm bootstrapping on x86_64-macos 2024-02-09 13:17:35 +01:00
Veikka Tuominen
ddcea2cad4
Merge pull request #18857 from alichraghi/shader
spirv: make rusticl the primary testing implementation
2024-02-09 14:11:31 +02:00
Jakub Konka
b5d2be1082 macho: undo invalid fix for allocating sections for relocatable
This is way too buggy for my taste. I will need to revisit
segment/section alloc logic.
2024-02-09 12:48:25 +01:00
Ali Chraghi
37b0aa600a spirv: make rusticl the primary testing implementation 2024-02-09 09:27:08 +03:30
Ali Chraghi
eb2d61d02e spirv: merge construct(Struct/Vector/Array) into constructComposite 2024-02-09 09:27:05 +03:30
Jakub Konka
925273bcc8 macho: align memory size with file size when emitting relocatable 2024-02-09 00:20:11 +01:00
Jakub Konka
7388534590 test/link/macho: more self-hosted tests 2024-02-08 23:51:30 +01:00
Jakub Konka
3bfda3d791 macho: fix alignment of objects in archive 2024-02-08 23:51:30 +01:00
Jakub Konka
8c0e5435b3 macho: do not close file on error - it will happen automatically anyhow 2024-02-08 23:51:30 +01:00
Jakub Konka
32386a06ca builtin: enable panic handler on self-hosted macho
comp: toggle compiler-rt and zig-libc caps for macho
2024-02-08 23:51:21 +01:00
Jakub Konka
7fb9df3fab test/link/macho: -fstrip is no longer needed for self-hosted 2024-02-08 22:15:00 +01:00
Jakub Konka
5da9d250ff macho: fix incorrect skip conditions for zig and dwarf sections 2024-02-08 22:08:51 +01:00
e4m2
60639ec83d Fixup filename casing 2024-02-08 15:39:28 +01:00
e4m2
a9a5833f23 Update rand.zig source file name for CMake 2024-02-08 15:35:33 +01:00
e4m2
8d56e472c9 Replace std.rand references with std.Random 2024-02-08 15:21:35 +01:00
e4m2
9af077d71e std.rand: Move to std.Random 2024-02-08 14:43:20 +01:00
Jakub Konka
dcb7f5791a macho: alloc improvement for relocatable 2024-02-08 13:22:48 +01:00
Jakub Konka
102846315c macho: couple small fixes 2024-02-08 13:12:06 +01:00
Jakub Konka
ce207caa24 macho: in relocatable mode, macho emit __DWARF directly 2024-02-08 12:15:46 +01:00
Jakub Konka
37033a96ac macho: move Dwarf handle to ZigObject from DebugSymbols 2024-02-08 11:13:52 +01:00
Jacob Young
919a3bae1c http: protect against zero-length chunks
A zero-length chunk marks the end of the body, so prevent any from
possibly occurring in the middle of the body.
2024-02-08 01:29:49 -08:00
Andrew Kelley
3122fd0ba0
Merge pull request #17634 from ianprime0509/type-erased-writer
Add type-erased writer and GenericWriter
2024-02-07 23:52:53 -08:00
Jakub Konka
9ca6cc1e2f
Merge pull request #18853 from ziglang/macho-static-lib
macho: implement our own archiver
2024-02-08 07:22:34 +01:00
Andrew Kelley
ba8375328c
Merge pull request #18718 from schmee/bounds
Add upperBound, lowerBound, and equalRange
2024-02-07 18:48:41 -08:00
Jakub Konka
272fc2df2e macho: use preadAll to read in object files when emitting archive 2024-02-07 23:25:15 +01:00
Andrew Kelley
42fcca49c5
Merge pull request #18846 from ziglang/std.os.linux.MAP
std.os.MAP: use a packed struct
2024-02-07 13:55:03 -08:00
Jakub Konka
114518c6b0 macho: fix 32bit builds 2024-02-07 21:28:20 +01:00
John Schmidt
e487b576fa Changes to lowerBound/upperBound/equalRange
The old definitions had some problems:

- In `lowerBound`, the `lhs` (left hand side) argument was passed on the
  right hand side.
- In `upperBound`, the `greaterThan` function needed to return
  `greaterThanOrEqual` for the function work, so either the name or the
  implementation is incorrect.

To fix both problems, define the functions in terms of a `lessThan` function that returns `lhs < rhs`.
The is more consistent with the rest of `sort.zig` and it's also how C++ implements lower/upperBound (1)(2).

(1) https://en.cppreference.com/w/cpp/algorithm/lower_bound
(2) https://en.cppreference.com/w/cpp/algorithm/upper_bound

- Rewrite doc comments.
- Add a couple of more test cases.
- Add docstring for std.sort.binarySearch
2024-02-07 21:00:24 +01:00
Craig O'Connor
664c18544c Add lowerBound/upperBound/equalRange
Authored by https://github.com/CraigglesO

Original Discussion: #9890

I already had to create these functions and test cases for my own
project so I decided to contribute to the main code base in hopes it
would simplify my own.

I realize this is still under discussion but this was a trivial amount
of work so I thought I could help nudge the discussion towards a
decision.

Why add these to the standard library

To better illustrate and solidify their value, the standard library's
"sort" module already contains several binary search queries on arrays
such as binarySearch and internal functions binaryFirst & binaryLast. A
final example of its use: the Zig code itself created and used a
bounding search in the linker.

There still lacks the ability to allow the programmer themselves to
search the array for a rough position and find an index to read &/
update.

Adding these functions would also help to complement dynamic structures
like ArrayList with it's insert function.

Example Case

I'm building a library in Zig for GIS geometry. To store points, lines,
and polygons each 3D point is first translated into what's called an
S2CellId. This is a fancy way of saying I reduce the Earth's spherical
data into a 1D Hilbert Curve with cm precision. This gives me 2
convenient truths:

    Hilbert Curves have locality of reference.
    All points can be stored inside a 1D array

Since lowerBound and upperBound to find data inside a radius for
instance. If I'm interested in a specific cell at a specific "level" and
want to iterate all duplicates, equalRange is a best fit.
2024-02-07 21:00:24 +01:00
Jakub Konka
e3b6d347b2 macho: remove fallback to llvm-ar 2024-02-07 19:27:26 +01:00
Jakub Konka
f9eb14ddcf macho: parse input object files specifically for incl in archive 2024-02-07 19:27:26 +01:00
Jakub Konka
82144a9073 macho: fix invalid ZigObject size calculation 2024-02-07 19:27:26 +01:00
Jakub Konka
35ac066f1d macho: fix writing SYMDEF symtab size 2024-02-07 19:27:26 +01:00
Jakub Konka
efa1c6124d macho: emit an archive 2024-02-07 19:27:26 +01:00