28690 Commits

Author SHA1 Message Date
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
Jakub Konka
897a554109 macho: populate output archive symtab 2024-02-07 19:27:26 +01:00
Jakub Konka
80cafad9d3 macho: read-in committed ZigObject to memory from file 2024-02-07 19:27:26 +01:00
Jakub Konka
7f01b61679 macho: move static lib emitting logic to relocatable.zig 2024-02-07 19:27:25 +01:00
Jakub Konka
bdbb1dbe15 macho: refactor markExports, markImportsExports and claimUnresolved 2024-02-07 19:27:25 +01:00
Jakub Konka
352e27c55c macho: move static lib flushing logic into Archive 2024-02-07 19:27:25 +01:00
Ian Kerins
ee36131e6a doc: fix typo in getEnvMap 2024-02-07 12:41:40 +02:00
Jacob Young
b3aed4e2c8 link: report function failures in FuncAnalysis
This unblocks backend errors after #18814.
2024-02-07 07:12:32 +00:00
Jacob Young
9211938e6e Elf: fix memory leaks 2024-02-07 00:17:23 -05:00
Andrew Kelley
a60f219660 std.c.MAP: use a packed struct
Same as previous commit, but for the libc interface.
2024-02-06 22:06:01 -07:00
Andrew Kelley
9f3165540e std.os.linux.MAP: use a packed struct
Introduces type safety to this constant. Eliminates one use of
`usingnamespace`.
2024-02-06 21:12:11 -07:00
Jacob Young
38c2a25735 Builder: fix memory leaks 2024-02-06 22:31:13 -05:00
Manlio Perillo
3da6043e2c compiler: remove unnecessary pub declarations in main.zig
Some declarations, like zig subcommands and usage strings, are
unnecessary marked as public, even thought they are only referenced by
main.zig.
2024-02-06 16:09:55 -08:00
Pyry Kovanen
476ba04753
x86: remove final vestiges of mir_to_air (#18836) 2024-02-06 14:13:31 -05:00
David Rubin
24fb6d1f30
Make @intFromEnum an error for empty enums 2024-02-06 21:04:09 +02:00
Jakub Konka
52066bf8e4 x86_64+macho: pass more behavior tests 2024-02-06 19:01:17 +01:00
Jakub Konka
db6addf31a macho: store open file descriptors in a global array 2024-02-06 17:38:50 +01:00
iwVerve
7bd8b35a3d langref: fix missing word typo 2024-02-06 17:22:59 +02:00
David Rubin
3069669bc1 add the clflush mnem 2024-02-06 07:08:16 -05:00
Matthew Lugg
0c80725068
Merge pull request #18814 from mlugg/incremental-dependencies
Begin re-implementing incremental compilation
2024-02-06 11:33:07 +00:00
Andrew Kelley
648b492ef1
Merge pull request #18831 from ziglang/flatten-value
flatten value.zig into Value.zig (refactor only)
2024-02-05 23:32:22 -08:00
Andrew Kelley
5cf138e512 delete bad behavior test
As pointed out in the issue this behavior test branches on an undefined
value. That's not valid Zig code.

Also behavior tests should not depend on the standard library in this
manner. They need to minimally isolate the specific language thing that
is being tested.

Closes #12681
2024-02-05 23:47:05 -07:00
Andrew Kelley
dd54804d86 compiler: make Value's self reference non pub
Done in this separate commit to make rebasing on this branch work
better.
2024-02-05 18:14:19 -07:00
Andrew Kelley
78f15bc714 compiler: rename value.zig to Value.zig
This commit only does the file rename to be friendlier to version
control conflicts.
2024-02-05 18:13:07 -07:00
Andrew Kelley
2de5e31721 compiler: flatten Value struct
This commit is almost entirely whitespace.
2024-02-05 18:07:56 -07:00
Andrew Kelley
39ec3d3116
Merge pull request #18822 from alichraghi/shader
spirv: basic shader support
2024-02-05 13:30:52 -08:00
Samuel Fiedler
0266017b59 Make EfiPhysicalAddress in std/os/uefi/tables.zig public 2024-02-05 15:31:33 +00:00
Ali Chraghi
be32ae0534 std: add gpu namespace 2024-02-05 11:55:14 +03:30
Ali Chraghi
739108c9f0 spirv: support enum integer values in Assembler 2024-02-05 11:55:14 +03:30
Ali Chraghi
b41aad0193 spirv: emit vectors whenever we can 2024-02-05 11:55:14 +03:30
Ali Chraghi
afa7793351 spirv: basic shader support 2024-02-05 11:55:14 +03:30
Robin Voetter
7634a115c5
Merge pull request #18580 from Snektron/spirv-more-vectors
spirv: more vector operations
2024-02-05 09:24:49 +01:00
Jacob Young
aebf20cc9a compiler_rt: avoid referencing symbol on versions where it doesn't exist
This change causes `__isPlatformVersionAtLeast` to no longer exist in
compiler_rt when targetting a min os version earlier than 10.15, which
is earlier than the default os version and so only affects builds that
explicitly target an older version than Zig officially supports.
2024-02-05 03:17:57 -05:00
Jacob Young
941d3a2bb1 x86_64: fix miscompilations on baseline 2024-02-05 02:16:56 -05:00
Jacob Young
eaa6218f09 x86_64: fix errors compiling the compiler
This fixes issues targetting both `x86_64-linux` and `x86_64-macos` with
the self-hosted backend.
2024-02-04 22:58:38 -05:00
Jakub Konka
f5dbcd1cb4 macho: add <cpu_arch>-macosx to target strings as a fallback target
Turns out that around 10.13/10.14 macOS release version, Apple changed the target tags in
tbd files from `macosx` to `macos`. In order to be compliant and therefore actually support
linking on older platforms against `libSystem.tbd`, we add `<cpu_arch>-macosx` to target strings.
2024-02-05 00:09:26 +01:00
mlugg
0784d38984
compiler: lock incremental dependency tracking behind --debug-incremental
This logic (currently) has a non-trivial cost (particularly in terms of
peak RSS) for tracking dependencies. Until incremental compilation is in
use in the wild, it doesn't make sense for users to pay that cost.
2024-02-04 19:17:20 +00:00
mlugg
0d8207c292
Zcu: refactor Decl.analysis field
* Functions failing codegen now set this failure on the function
  analysis state. Decl analysis `codegen_failure` is reserved for
  failures generating constant values.

* `liveness_failure` is consolidated into `codegen_failure`, as we do
  not need to distinguish these, and Liveness.Verify is just a debugging
  feature anyway.

* `sema_failure_retryable` and `codegen_failure_retryable` are removed.
  Instead, retryable failures are recorded in the new
  `Zcu.retryable_failures` list. On an incremental update, this list is
  flushed, and all elements are marked as outdated so that we re-attempt
  analysis and code generation.

Also remove the `generation` fields from `Zcu` and `Decl` as these are
not needed by our new strategy for incremental updates.
2024-02-04 18:38:40 +00:00