28041 Commits

Author SHA1 Message Date
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
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
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