1287 Commits

Author SHA1 Message Date
Andrew Kelley
9a1094c00f fix compilation regression 2023-11-03 20:05:32 -07:00
Andrew Kelley
1396479656 zig reduce: redesign
Now it works like this:
1. Walk the AST of the source file looking for independent
   reductions and collecting them all into an array list.
2. Randomize the list of transformations. A future enhancement will add
   priority weights to the sorting but for now they are completely
   shuffled.
3. Apply a subset consisting of 1/2 of the transformations and check for
   interestingness.
4. If not interesting, half the subset size again and check again.
5. Repeat until the subset size is 1, then march the transformation
   index forward by 1 with each non-interesting attempt.

At any point if a subset of transformations succeeds in producing an interesting
result, restart the whole process, reparsing the AST and re-generating the list
of all possible transformations and shuffling it again.

As for std.zig.render, the fixups operate based on AST Node Index rather
than Nth index of the function occurence. This allows precise control
over how to mutate the input.
2023-11-03 20:05:32 -07:00
Andrew Kelley
b1aaf42134 std.zig.render: fix iteration over parameters
use the handy iteration API to be correct
2023-11-03 20:05:32 -07:00
Andrew Kelley
5f1f145199 add a transformation for gutting the body of a function 2023-11-03 20:05:32 -07:00
Andrew Kelley
3263d6e6ab std.zig: move render state to struct; add fixups 2023-11-03 20:05:32 -07:00
xdBronch
5bd27a2cb6 dont assume apple chips are macos exclusive 2023-11-03 14:46:53 -04:00
Andrew Kelley
3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
Jacob Young
d890e81761 mem: fix ub in writeInt
Use inline to vastly simplify the exposed API.  This allows a
comptime-known endian parameter to be propogated, making extra functions
for a specific endianness completely unnecessary.
2023-10-31 21:37:35 -04:00
frmdstryr
a4cffd80bd Update slice_sentinel comment
Slice end can be omitted
2023-10-27 18:45:59 +03:00
frmdstryr
8dccd77277 Update comment on while
The @"while" is still used if cont expr is missing.
2023-10-27 18:45:24 +03:00
Jacob Young
b0cf620fe3 x86_64: fix cond_br 2023-10-27 03:33:49 -04:00
Jacob Young
42bca3e2ee x86_64: fix @memset 2023-10-27 01:40:27 -04:00
Jacob Young
434a7db986 x86_64: add missing spill 2023-10-27 01:40:27 -04:00
Jacob Young
98cd378208 x86_64: fix behavior of getValue
Old behavior renamed to `getValueIfFree`.
2023-10-26 21:45:58 -04:00
Jakub Konka
cc394431ae
Merge pull request #17699 from ziglang/elf-better-alloc
elf: allocated PHDR table always immediately succeeding the EHDR
2023-10-25 23:25:56 +02:00
frmdstryr
5c5d1f93c4 Update comment on for_range in Ast
The rhs can be omitted eg `0..`
2023-10-25 14:09:34 -04:00
Jacob Young
b55377a5ab x86_64: pass more tests
* 128-bit integer multiplication with overflow
 * more instruction encodings used by std inline asm
 * implement the `try_ptr` air instruction
 * follow correct stack frame abi
 * enable full panic handler
 * enable stack traces
2023-10-25 04:28:30 -04:00
frmdstryr
f30ab46306 Update comment on Tag value assign_mod in Ast.zig 2023-10-25 09:31:27 +03:00
Jacob Young
fe93332ba2 x86_64: implement enough to pass unicode tests
* implement vector comparison
 * implement reduce for bool vectors
 * fix `@memcpy` bug
 * enable passing std tests
2023-10-23 22:42:18 -04:00
Eric Joldasov
6bf554f9a7 std.zig.system.NativeTargetInfo: fix glibc version parsing
In most cases "GLIBC_2.X" strings and `/lib/libc-2.x.so` files do not contain third (`patch`) field,
which causes std.SemanticVersion.parse function to return error. To fix this, we
reuse [now-public] std.zig.CrossTarget.parseVersion function,
which accounts for this third field and makes it 0 in case it was not found.
This new behaviour is similar to std.builtin.Version.parse, which was removed in
6e84f46990

Fixes regression from 6e84f46990
and https://github.com/ziglang/zig/pull/13998 .

Related: https://github.com/ziglang/zig/issues/17626 . Results with `zig end`:

Before: `"target": "x86_64-linux.6.5.7...6.5.7-gnu.2.19",`
After: `"target": "x86_64-linux.6.5.7...6.5.7-gnu.2.36",`

Also, while we are here, write explicit error sets and remove duplicate
logic from std.zig.system.darwin.macos.parseSystemVersion .

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-10-23 06:00:53 -04:00
Jacob Young
27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadbe29294f2bf3153a27beebd64377566.
2023-10-22 15:46:43 -04:00
Andrew Kelley
6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab63865592bb084feb271cd4e4b0357e, reversing
changes made to 5f92b070bf284f1493b1b5d433dd3adde2f46727.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Jan Philipp Hafer
fd2239bde9 child_process + Build: rename exec to run + all related code
Justification: exec, execv etc are unix concepts and portable version
should be called differently.

Do no touch non-Zig code. Adjust error names as well, if associated.
Closes #5853.
2023-10-22 14:47:20 -04:00
Jacob Young
32e85d44eb x86_64: disable failing tests, enable test-std testing 2023-10-21 10:55:41 -04:00
Jacob Young
2e6e39a700 x86_64: fix bugs and disable erroring tests 2023-10-21 10:55:41 -04:00
Andrew Kelley
ae2cd5fe26 Revert "Never implicitly add rpaths for each lib dir, add NixOS libdir to rpath"
This reverts commit d7b73af8f65bb891c8700ed47777144bb6f35fe1.

I did not look at this closely enough. This is incorrect; it should not
implicitly add rpaths for every library, and it should not disable the
nice default of each_lib_path when compiling for the native OS.

See #16062 where we are working on a follow-up improvement to this.
2023-10-18 23:37:47 -07:00
Tobias Simetsreiter
7a9500fd80
Fix rendering ast in zon mode (#17547)
Co-authored-by: Tobias Simetsreiter <tobias.simetsreiter@wabtec.com>
2023-10-17 19:04:01 -04:00
Andrew Kelley
027aabf497 drop for loop syntax upgrade mechanisms 2023-10-13 03:43:54 -07:00
Eric Joldasov
1f6d82ec01 std.cstr: remove deprecated namespace
Followup to 0a868dacdd31b7d5c529a332da718683477a2505 .

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-10-10 02:08:03 +03:00
Jonathan Marler
3a47bc7154 Grammar: Use ContainerDeclaration* instead of ContainerDeclarations
`ContainerDeclarations` is an abstraction of `ContainerDeclaration*`.
Removing this abstraction allows the `ContainerMembers` rule to contain
more concrete information without having to look at the definition
of `ContainerDeclarations`.
2023-10-10 00:51:58 +03:00
Andrew Kelley
9eb21541ec make Package.Path support string escape formatting 2023-10-08 16:54:31 -07:00
Andrew Kelley
24c8adc6ac std.zig.ErrorBundle: add some explicit error sets 2023-10-08 16:54:30 -07:00
Jakub Konka
df9462690f std: fix memory bug in getExternalExecutor
Until now, we would pass `candidate: NativeTargetInfo` which creates
a copy of the `NativeTargetInfo.DynamicLinker` buffer. We would then
return this buffer in `bad_dl: []const u8` which would goes out-of-scope
the moment we leave this function frame yielding garbage. To fix this,
we just need to remember to pass by const-pointer
`candidate: *const NativeTargetInfo`.
2023-10-06 12:43:00 +02:00
Andrew Kelley
7733894761
Merge pull request #17341 from rzezeski/illumos-updates
Illumos/Solaris updates
2023-10-03 11:04:41 -07:00
Andrew Kelley
df4853a627
Merge pull request #17363 from ziglang/tar-symlinks
introduce the `zig fetch` subcommand and symlink support in zig packages
2023-10-03 03:33:26 -07:00
xdBronch
c9c3ee704c correctly detect apple a15 and a16 chips 2023-10-03 00:36:59 -07:00
Andrew Kelley
21181181bf zig fetch: enhanced error reporting
* Package: use std.tar diagnostics to give detailed error messages
* std.tar: add diagnostic for unsupported file type
2023-10-02 17:02:25 -07:00
Stephen Gregoratto
285970982a Add illumos OS tag
- Adds `illumos` to the `Target.Os.Tag` enum. A new function,
  `isSolarish` has been added that returns true if the tag is either
  Solaris or Illumos. This matches the naming convention found in Rust's
  `libc` crate[1].
- Add the tag wherever `.solaris` is being checked against.
- Check for the C pre-processor macro `__illumos__` in CMake to set the
  proper target tuple. Illumos distros patch their compilers to have
  this in the "built-in" set (verified with `echo | cc -dM -E -`).

  Alternatively you could check the output of `uname -o`.

Right now, both Solaris and Illumos import from `c/solaris.zig`. In the
future it may be worth putting the shared ABI bits in a base file, and
mixing that in with specific `c/solaris.zig`/`c/illumos.zig` files.

[1]: 6e02a329a2/src/unix/solarish
2023-10-02 15:31:49 -06: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
Ryan Zezeski
54ad5f31c6 solaris: hard-code ABI and dynamic linker
Solaris/illumos is multi-lib, so you can't rely on an arbitrary
executable to give you the correct dynamic linker. Besides, it's
always the same path.
2023-09-30 11:38:56 -06:00
Jonathan Marler
e0ef61d46d simplify ContainerDeclarations grammar rule
Noticed this grammar rule could be simplified using a repeating sequence
rather than recursion.
2023-09-28 14:18:54 +03:00
Jonathan Marler
18f1db134c docs: remove unnecessary nesting in grammar
noticed this extra level of nesting in the Decl grammar that looks
unnecssary.
2023-09-28 13:58:14 +03:00
antlilja
8191199951 fmt: add rewrite from @fabs to @abs 2023-09-27 11:24:45 -07:00
antlilja
bcf4a13913 Remove @fabs, fabs and absCast/Int from std lib
Replaces occurences of @fabs absCast and absInt with new @abs builtin.
Also removes the std.math.fabs alias from math.zig.
2023-09-27 11:24:28 -07:00
Andrew Kelley
3fc7413574
Merge pull request #17069 from squeek502/resinator
Add a `.rc` -> `.res` compiler to the Zig compiler
2023-09-22 12:18:50 -07:00
Andrew Kelley
62a12e0631 LLVM 17 std lib updates and fixes
* some manual fixes to generated CPU features code. in the future it
   would be nice to make the script do those automatically. I suspect
   the sm_90a thing is a bug in LLVM.
 * add liteos to various target OS switches. I know nothing about this
   OS; someone will need to work specifically on support for this OS
   when the time comes to support it properly in zig.
 * while waiting for the compiler, I went ahead and made more
   conservative choices about when to use `inline` in std/Target.zig
2023-09-19 09:37:31 -07:00
r00ster91
ee4ced9683 write function types consistently with a space before fn keyword
Currently, the compiler (like @typeName) writes it `fn(...) Type` but
zig fmt writes it `fn (...) Type` (notice the space after `fn`).
This inconsistency is now resolved and function types are consistently
written the zig fmt way. Before this there were more `fn (...) Type`
occurrences than `fn(...) Type` already.
2023-09-19 15:15:05 +03:00
Banacial
d2a937838e
std.zig.c_translation.zig: fix L suffix with sized ints
Closes #15066
2023-09-18 13:27:32 +03:00
Ryan Liptak
8e35be0640 ErrorBundle: rename addBundle to addBundleAsNotes, add addBundleAsRoots 2023-09-15 23:36:44 -07:00
Ryan Liptak
fc69529dab ErrorBundle.addOtherSourceLocation: Fix source_line ending up as garbage when source_line is 0
The zero value needs special handling since it means 'no source line' and should be preserved through the copy.
2023-09-15 23:36:44 -07:00