6467 Commits

Author SHA1 Message Date
Andrew Kelley
dad6039092 std.Build: support running build artifacts from packages
Deprecate CompileStep.run. The problem with this function is that it
does the RunStep with the same build.zig context as the CompileStep, but
this is not desirable when running an executable that is provided by a
dependency package. Instead, users should use `b.addRunArtifact`.
This has the additional benefit of conforming to the existing naming
conventions.

Additionally, support enum literals in config header options values.
2023-02-13 06:42:25 -07:00
Andrew Kelley
27317eaff0 std.Build.ConfigHeaderStep: support sentinel-terminated strings 2023-02-13 06:42:25 -07:00
Frank Denis
f62e3b8c0d std.crypto: add the Ascon permutation
Ascon has been selected as new standard for lightweight cryptography
in the NIST Lightweight Cryptography competition.

Ascon won over Gimli and Xoodoo.

The permutation is unlikely to change. However, NIST may tweak
the constructions (XOF, hash, authenticated encryption) before
standardizing them. For that reason, implementations of those
are better maintained outside the standard library for now.

In fact, we already had an Ascon implementation in Zig:
`std.crypto.aead.isap` is based on it. While the implementation was
here, there was no public API to access it directly.

So:

- The Ascon permutation is now available as `std.crypto.core.Ascon`,
with everything needed to use it in AEADs and other Ascon-based
constructions
- The ISAP implementation now uses std.crypto.core.Ascon instead of
keeping a private copy
- The default CSPRNG replaces Xoodoo with Ascon. And instead of an
ad-hoc construction, it's using the XOFa mode of the NIST submission.
2023-02-13 02:22:24 -05:00
Andrew Kelley
d4bd1b1a60
Merge pull request #14618 from Vexu/fixes
small misc fixes
2023-02-13 01:58:01 -05:00
Andrew Kelley
3c2a43fdcc Revert "std: check types of pointers passed to allocator functions"
This reverts commit abc9530a88d24350481d9264edcde300f293929a.

This patch implies that the idiomatic Zig way of handling anytype
parameter is to write a bunch of boilerplate instead of directly
accessing type information and relying on the compiler to be useful.

I don't want it to be this way.

It is the compiler's job to make useful error messages when the wrong
field of a type info result is accessed, and it is the zig programmer's
job to understand what it means when a compile error points at the field
access of `@typeInfo` (along with the relevant callsites).

One thing that might be useful would be having the compiler be aware of
module boundaries and highlighting the boundaries of them. The first
reference note after crossing a module boundary is likely the most
interesting one.
2023-02-12 05:59:28 -07:00
Leo Constantinides
abc9530a88
std: check types of pointers passed to allocator functions 2023-02-12 00:04:27 +00:00
Veikka Tuominen
8127a27eb1 zig fmt: do not consider tuples blocks
Closes #14056
2023-02-11 14:36:54 +02:00
Techatrix
c63be507cf don't tokenize an invalid string literal 2023-02-11 14:25:25 +02:00
Asherah Connor
c6344866f9 std.Build.addAssembly: add missing .kind 2023-02-11 14:24:13 +02:00
fn ⌃ ⌥
43c76e0c8e
Update block.zig 2023-02-05 09:18:07 -08:00
fn ⌃ ⌥
622a364715 Implement std.io.Reader for LZMA1 2023-02-05 08:23:51 -08:00
fn ⌃ ⌥
e03d6c42ea Delete redundant lzma/lzma2 prefix in function/struct names 2023-02-05 06:52:28 -08:00
Ryan Liptak
d57813e3e9 std.compress.xz: Avoid possible integer overflow in a few places 2023-02-05 06:08:35 -08:00
fn ⌃ ⌥
baa877fd12 Merge branch 'master' into lzma 2023-02-05 05:57:58 -08:00
Andrew Kelley
b29e3fa2cd std.Build: enhancements to ConfigHeaderStep
Breaking API change to std.Build.addConfigHeader. It now uses an options
struct.

Introduce std.Build.CompileStep.installConfigHeader which also accepts
an options struct. This is used to add a generated config file into the
set of installed header files for a particular compilation artifact.

std.Build.ConfigHeaderStep now additionally supports a "blank" style
where a header is generated from scratch. It no longer exposes
`output_dir`. Instead it exposes a FileSource via `output_file`.
It now additionally accepts an `include_path` option which affects the
include path of CompileStep when using the `#include` directive, as well
as affecting the default installation subdirectory for header
installation purposes.

The hash used for the directory to store the generated config file now
includes the contents of the generated file. This fixes possible race
conditions when generating multiple header files simultaneously.

The values hash table is now an array hash map, to preserve order for
the "blank" use case.

I also took the opportunity to remove output_dir from TranslateCStep and
WriteFileStep. This is technically a breaking change, but it was always
naughty to access these fields.
2023-02-05 06:26:30 -07:00
David Vanderson
b04e48566c std.build: support for generated c headers
Add ability to generate a c header file from scratch, and then both
compile with it and install it if needed.

Example:
```zig
    const avconfig_h = b.addConfigHeader(.{ .path = "libavutil/avconfig.h" }, .generated, .{
        .AV_HAVE_BIGENDIAN = 0, // TODO: detect based on target
        .AV_HAVE_FAST_UNALIGNED = 1, // TODO: detect based on target
    });

    lib.addConfigHeader(avconfig_h);

    lib.installConfigHeader(avconfig_h);
```
2023-02-05 06:26:30 -07:00
Stephen Gregoratto
d4ce0fe7fe Update Linux syscall list for 6.1, support Mips64
Follow up for #14541.
2023-02-05 03:25:21 -05:00
Jonathan Marler
1876eaec51 mark deprecated assumeSentinel as pub
assumeSentinel was removed and replaced with a compileError, but it's
not pub, so the error message indicates it's private rather than
providing the compileError message.
2023-02-04 23:19:00 +02:00
Nicolas Goy
b7c96c3bbd Allow const for ArrayList.getLast, fix #14522 2023-02-04 15:24:45 -05:00
Suirad
7f24993772 Add support for mips64/mips64el 2023-02-04 15:19:53 -05:00
Andrew Kelley
693b12f8e1 std.Build: support exposing and depending on zig modules
New API introduced: std.Build.addModule

This function exposes a zig module with the given name, which can be
used by packages that depend on this one via std.Build.Dependency.module.

std.Build.Pkg and related functionality is deleted. Every use case has a
straightforward upgrade path using the new Module struct.

std.Build.OptionsStep.getPackage is replaced by
std.Build.OptionsStep.createModule.

std.Build.CompileStep.addPackagePath is replaced by
std.Build.CompileStep.addAnonymousModule.

This partially addresses #14307 by renaming some of the instances of
"package" to "module".

Closes #14278
2023-02-04 01:55:39 -05:00
Marc Tiehuis
4009e0d2b1 remove stage1 workaround for big int set
Underlying fix should have been d7b029995c.

u128 limb sizes are still not fully tested as we are missing compiler-rt
support (__divei4, __modei4 on x86_64). Should be no zig blockers so the
assertion has been removed.
2023-02-04 00:29:04 -05:00
Andrew Kelley
81c27c74bc use build.zig.zon instead of build.zig.ini for the manifest file
* improve error message when build manifest file is missing
 * update std.zig.Ast to support ZON
 * Compilation.AllErrors.Message: make the notes field a const slice
 * move build manifest parsing logic into src/Manifest.zig and add more
   checks, and make the checks integrate into the standard error
   reporting code so that reported errors look sexy

closes #14290
2023-02-03 00:06:11 -07:00
Andrew Kelley
873bb29c98 introduce ZON: Zig Object Notation
* std.zig.parse is moved to std.zig.Ast.parse
 * the new function has an additional parameter that requires passing
   Mode.zig or Mode.zon
 * moved parser.zig code to Parse.zig
 * added parseZon function next to parseRoot function
2023-02-03 00:06:11 -07:00
fn ⌃ ⌥
8e2af21cd9 Add LZMA decoder 2023-02-02 11:59:56 -08:00
Andrew Kelley
7505d19e93
Merge pull request #14511 from ziglang/zig-build-hashes
two package hash breaking enhancements
2023-02-02 14:03:41 -05:00
Andrew Kelley
6b7ad22981
Merge pull request #14477 from Vexu/fixes
Improve `@ptrCast` errors, fix some bugs
2023-02-01 23:31:52 -05:00
Kirk Scheibelhut
e712d5f03e remove reference to removed addTestExe 2023-02-01 22:52:32 -05:00
Andrew Kelley
ea6e0e33a7 zig build: add executable bit and file path to package hash
Unfortunately, due to the Windows equivalent of executable permissions
being a bit tricky, there is follow-up work to be done.

What is done in this commit is the hash modifications. At the fetch
layer, executable bits inside packages are ignored. In the hash
computation layer, executable bit is implemented for POSIX but not yet
for Windows. This means that the hash will not break again in the future
for packages that do not have any executable files, but it will break
for packages that do.

This is a hash-breaking change.

Closes #14308
2023-02-01 18:42:29 -07:00
ominitay
3c8d968194 fmt: Make default_max_depth configurable 2023-02-01 21:43:36 +02:00
Andrew Kelley
8d37c6f71c std.Build.CompileStep: fix API usage in unit test 2023-01-31 15:34:08 -07:00
Andrew Kelley
3c1fc3f566 std.Build.ConfigHeaderStep: support more types 2023-01-31 15:09:35 -07:00
Andrew Kelley
2f5892671e move compiler's CType logic to std.Target
This API only depends on std.Target and is extremely useful in build
scripts when populating configure files.
2023-01-31 15:09:35 -07:00
Andrew Kelley
90e48d4b34 std.Build: avoid use of catch unreachable
Usage of `catch unreachable` in build scripts is completely harmless
because build scripts are always run in Debug mode, however, it sets a
poor example for beginners to learn from.
2023-01-31 15:09:35 -07:00
Andrew Kelley
13a9616540 std.Build: add deprecated declarations
These declarations are now aliases of their new APIs and marked as
deprecated via doc comments:
 * std.build.Builder
 * std.build
 * std.Build.LibExeObjStep
2023-01-31 15:09:35 -07:00
Andrew Kelley
16cdd1297e rename std.Build.LibExeObjStep to std.Build.CompileStep
This matches the nomenclature internally: a Compilation is the main type
that represents a single invokation of the compiler.
2023-01-31 15:09:35 -07:00
Andrew Kelley
5129fae4e8 std.Build: accept host Target in create()
And only detect native target in LibExeObjStep once, in create().
2023-01-31 15:09:35 -07:00
Andrew Kelley
36e2d992dd combine std.build and std.build.Builder into std.Build
I've been wanting to do this for along time.
2023-01-31 15:09:35 -07:00
Andrew Kelley
73cf7b6429 update build.zig API usage 2023-01-31 15:09:35 -07:00
Andrew Kelley
71ff60f126 std.build: eliminate setTarget and setBuildMode
This is a breaking change that makes the API for creating build
artifacts no longer have any period of time where the target and
optimization mode are not set.
2023-01-31 15:09:35 -07:00
Andrew Kelley
063888afff std.build: implement passing options to dependency packages
* introduce the concept of maps to user input options, but don't
   implement it for command line arg parsing yet.
 * remove setPreferredReleaseMode and standardReleaseOptions in favor of
   standardOptimizeOption which has a future-proof options parameter.
2023-01-31 15:09:35 -07:00
leap123
ef8f694d77
std.os.uefi: fix shift in pool allocator (again) (#14497) 2023-01-31 13:08:30 -05:00
Andrew Kelley
d6b430b520 std.Target: remove workaround
This was working around a stage1 compiler bug.
2023-01-31 02:28:16 -05:00
Veikka Tuominen
f16c10a86b implement @qualCast 2023-01-30 18:55:57 +02:00
Techatrix
885d696895 zig fmt: fix file ending in a multi line comment 2023-01-30 00:42:05 +02:00
Jiacai Liu
d8c3c11c6c
std: add expectEqualDeep (#13995) 2023-01-29 22:00:14 +00:00
Isaac Freund
23b7d28896 std: restrict mem.span() and mem.len() to sentinel terminated pointers
These functions are currently footgunny when working with pointers to
arrays and slices. They just return the stated length of the array/slice
without iterating and looking for the first sentinel, even if the
array/slice is a sentinel terminated type.

From looking at the quite small list of places in the standard
library/compiler that this change breaks existing code, the new code
looks to be more readable in all cases.

The usage of std.mem.span/len was totally unneeded in most of the cases
affected by this breaking change.

We could remove these functions entirely in favor of other existing
functions in std.mem such as std.mem.sliceTo(), but that would be a
somewhat nasty breaking change as std.mem.span() is very widely used for
converting sentinel terminated pointers to slices. It is however not at
all widely used for anything else.

Therefore I think it is better to break these few non-standard and
potentially incorrect usages of these functions now and at some later
time, if deemed worthwhile, finally remove these functions.

If we wait for at least a full release cycle so that everyone adapts to
this change first, updating for the removal could be a simple find and
replace without needing to worry about the semantics.
2023-01-29 15:07:06 -05:00
kcbanner
7c2ba950a7 build: .c ofmt does not produce a pdb 2023-01-29 15:04:51 -05:00
kcbanner
a9b68308b9 cbe: fixes for tls, support for not linking libc, and enabling tests
- cbe: Implement linksection support, to support TLS when not linking libc
- cbe: Support under-aligned variables / struct fields
- cbe: Support packed structs (in the C definition of packed)
- windows: Fix regression with x86 _tls_array
- compiler_rt: Add 128-bit atomics to compiler_rt
- tests: Re-enable threadlocal tests on cbe+windows, and llvm+x86
- tests: Re-enable f80 tests that now pass
- ci: change windows ci to run the CBE behaviour tests with -lc, to match how the compiler is bootstrapped
- update zig1.wasm
2023-01-29 15:04:13 -05:00
Yusuf Bham
9177e0da4f std.os.uefi: fix shift in pool allocator 2023-01-29 15:02:22 -05:00