23474 Commits

Author SHA1 Message Date
Michael Dusan
490a411fd4 openbsd: fix thread name buffer size
OpenBSD 7.3 changed its implementation of
pthread_get_name_np/pthread_set_name_np to wrap new libc functions
getthrname/setthrname and lowered the max buffer size from 32 to 24.

This is not a backwards-compatible change because if we were to put in
comptime version logic to use size 32 when target < 7.3 the binaries
would be undefined when running on >= 7.3. It also could simply be that
OpenBSD has a policy to not support older binaries running on newer
releases? Regardless, the safest course is to simply use the smallest
known buffer size.

As an aside, this bug manifested as a "hung" std.Thread test because 7.3
pthread API never checks for error result when wrapping getthrname/setthrname.
This is not a problem in std.Thread when we use the correct max buffer
size because ERANGE/EINVAL become unreachable.
2023-04-12 15:36:03 -04:00
mlugg
ccf670c2b0 Zir: implement explicit block_comptime instruction
Resolves: #7056
2023-04-12 12:06:19 -04:00
Loris Cro
602029bb2f
Autodoc usingnamespace (#15216)
* autodoc: init support for usingnamespace decls

* autodoc: don't build autodoc when building zig2.c

* autodoc: usingnamespace decls support in frontend (#15203)

* autodoc: init support for usingnamespace decls

* autodoc: usingnamespace decls support in frontend

---------

Co-authored-by: Krzysztof Wolicki <46651553+der-teufel-programming@users.noreply.github.com>
2023-04-12 01:14:02 +00:00
Krzysztof Wolicki
52d552f118
Add omit_pkg_fetching_code option to test_cases (#15244)
* Add `omit_pkg_fetching_code` option to test_cases

* Change `omit_pkg_fetching_code` to always `true` for test_cases

Co-authored-by: Andrew Kelley <andrew@ziglang.org>

---------

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2023-04-11 19:47:53 +02:00
Andrew Kelley
d3a237a98c
Merge pull request #15234 from ziglang/remove-legacy-build-api
remove --enable-cache option; std.Build.CompileStep: remove output_dir
2023-04-11 11:54:43 -04:00
Andrew Kelley
3c3cee2cfa fix build logic due to state mutations and break the API accordingly
* remove setName, setFilter, and setTestRunner. Please set these
   options directly when creating the CompileStep.
 * removed unused field
 * remove computeOutFileNames and inline the logic, making clear the
   goal of avoiding state mutations after the build step is created.
2023-04-11 08:42:14 -07:00
Andrew Kelley
d5eab33fd2 docgen: avoid use of --enable-cache 2023-04-11 08:41:52 -07:00
Andrew Kelley
5a8b1bde5b std.Build.CompileStep: remove output_dir
Build scripts must instead use the FileSource abstraction rather than
telling the compiler directly where to output files.

closes #14951
2023-04-11 08:41:51 -07:00
Andrew Kelley
c96cb98ad1 CLI: remove --enable-cache option
This use case is now handled instead by the --listen option.

closes #15025
closes #15072
2023-04-11 08:41:24 -07:00
Andrew Kelley
1728d92f60
Merge pull request #15245 from ziglang/zig-build-install-artifact
fix broken and confusing artifact installation logic
2023-04-11 11:40:53 -04:00
Andrew Kelley
406706fe6b init-exe/init-lib template: fix use of install() and run()
And while we're at it, make the unit tests be actually executed.
2023-04-10 18:35:14 -07:00
Andrew Kelley
7221e9560e std.Build.RunStep: don't close stdin
Instead, ignore stdin. Otherwise this interfers with a sub-process which
expects to have a stdin file descriptor open.
2023-04-10 18:35:14 -07:00
Andrew Kelley
60eabc0eca std.Build.CompileStep: remove run() and install()
These functions are problematic in light of dependencies because they
run and install, respectively, for the *owner* package rather than for
the *user* package. By removing these functions, the build script is
forced to provide the *Build object to associate the new step with,
making everything less surprising.

Unfortunately, this is a widely breaking change.

see #15079
2023-04-10 18:35:14 -07:00
Andrew Kelley
38698f4f6a std.Build.CompileStep: delete install_step field
This was used to ensure that an artifact would only be installed once,
but this is not only unnecessary, but actively harmful, in the face of
dependencies.

see #15079
2023-04-10 18:35:14 -07:00
Andrew Kelley
d2ad3f5074 std.Build.CompileStep: remove redundant dest_builder field
The destination *Build object is already known to be step.owner, while
the source object is artifact.step.owner.
2023-04-10 18:35:14 -07:00
Jacob Young
23d7921758 Sema: avoid emitting loops that can't loop
If a `loop` ends with a `noreturn` instruction, then it cannot loop and
will be emitted as a `block` instead.
2023-04-10 20:57:49 -04:00
Piotr Sikora
cb54e9a3c2 glibc: allow linking against external libcrypt.
Support for the built-in libcrypt was removed in commit 6b7ddfba,
but the -lcrypt flag remained ignored, preventing linking against
external libcrypt.

Fixes #5990.

Signed-off-by: Piotr Sikora <piotr@aviatrix.com>
2023-04-10 20:04:29 -04:00
Andrew Kelley
311d50f9dc
Merge pull request #14827 from adriandelgado/log10-int
std.math: port `int_log10` from Rust
2023-04-10 13:01:28 -04:00
Andrew Kelley
a2793f8ab8
Merge pull request #14853 from schmee/vector-peer-type-resolution
Vector type resolution/coercion fixes
2023-04-10 12:21:55 -04:00
GethDW
2c639d6570 std.MultiArrayList: add support for tagged unions. 2023-04-10 12:15:05 -04:00
Andrew Kelley
88dfb13818
Merge pull request #14882 from xxxbxxx/master
objcopy: add some support for --strip-debug and --strip-all
2023-04-10 12:06:13 -04:00
Andrew Kelley
aeae71f462
Merge pull request #15068 from Snektron/spirv-test-runner-support
spirv: test runner support
2023-04-10 10:44:35 -04:00
Andrew Kelley
dfe3440540 std.os.sendto: use ws2_32 on Windows
closes #9971
2023-04-09 20:08:18 -04:00
Andrew Kelley
95ac94b7ac std.debug: fix segfault/panic race condition
closes #7859
closes #12207
2023-04-09 14:09:52 -04:00
Andrew Kelley
2ee328995a
Merge pull request #15123 from truemedian/http-server
std.http: add http server
2023-04-09 10:44:52 -04:00
Robin Voetter
d1484bf4b9
spirv: emit nonsemantic info with zig errors
In order to be able to report nice errors in the test runner, and in order
to check SkipZigTest errors, we need to pass the error names to the consumer.
This kind of information can be passed via nonsemantic instructions - using
OpSourceExtension here.

All errors are concatenated into a single string, starting with 'zig_errors:'
for identification, separated by a colon (:). To ensure that we can represent
all error codes, even those which contain a colon, the error names are URI-
escaped. URI-escaping, rather than base64, allows us to see the error names
when viewing disassembled SPIR-V code.
2023-04-09 01:51:55 +02:00
Robin Voetter
979b410258
spirv: Do not generate the Alignment attribute on pointers for now
It seems that some implementations may have problems with these right now,
like Intel and Rusticl. In theory, these attributes should be superficial
on the pointer type, as alignment guarantees are also added via the
alignment option of the OpLoad and OpStore instructions. Therefore, get rid
of them for now.
2023-04-09 01:51:55 +02:00
Robin Voetter
a7563e453d
spirv: minimal start code
For SPIR-V, only export the main function if it is actually declared. Kernel
entry points will often have parameters and more than one kernel declared.

In general, SPIR-V binaries should mostly be compiled as libraries and not as
executables. However, this start code is required so that we can build test
executables.

Note that a call to isSpirV() would emit the code for that function, even though
the call is at comptime. To save that function from being emitted the checks
are just inlined manually.
2023-04-09 01:51:55 +02:00
Robin Voetter
45b5f46770
spirv: allow global, constant address spaces
These should actually just work fine in SPIR-V. They are mapped to CrossWorkgroup
and UniformConstant respectively.
2023-04-09 01:51:54 +02:00
Robin Voetter
fe0fb93fa0
spirv: deny global OpVariable in inline asm
This feature requires to be integrated with the mechanism that orders the
global variables, and that is not yet in place.
2023-04-09 01:51:54 +02:00
Robin Voetter
1de2d2ee1c
spirv: deny OpEntryPoint in asm
Kernels should be exported by marking the kernel using callconv(.Kernel) and
exporting it as a regular function.
2023-04-09 01:51:54 +02:00
Robin Voetter
e389f524c9
spirv: export functions with .Kernel callconv as entry point
Exported functions which have the .Kernel calling convention are now exported
as entry point. This also works with @export.
2023-04-09 01:51:54 +02:00
Robin Voetter
f12beb857a
amdgpu,nvptx: unify kernel calling conventions
AmdgpuKernel and NvptxKernel are unified into a Kernel calling convention.
There is really no reason for these to be separate; no backend is allowed to
emit the calling convention of the other. This is in the same spirit as the
.Interrupt calling convention lowering to different LLVM calling conventions,
and opens the way for SPIR-V kernels to be exported using the Kernel calling
convention.
2023-04-09 01:51:54 +02:00
Robin Voetter
3f2025f59e
spirv: emit interface variables for entry points
Also actually implement generating the OpEntryPoint instructions.
2023-04-09 01:51:54 +02:00
Robin Voetter
405f7298ac
spirv: add decl dependencies for functions also
Entry points need to be attributed with a complete list of
global variables that they use. To that end, the global dependencies
mechanism is extended to also allow functions - when flushing the
module, the list of dependencies is examined to generate this
list of global variable result-ids.
2023-04-09 01:51:53 +02:00
Robin Voetter
efe7fae6af
spirv: temporarily emit test kernels
SPIR-V cannot represent function pointers without extensions
that no vendor implements. For the time being, generate a test
kernel for each error, so that we can at least run SOME tests.

In the future we may be able to emulate function pointers in some
way, but that is not today.
2023-04-09 01:51:53 +02:00
Robin Voetter
719d47d823
spirv: implement error set and error unions
Implements lowering types and constants for error sets and error unions.
2023-04-09 01:51:53 +02:00
Robin Voetter
8bbfbfc956
spirv: improve linking globals
SPIR-V globals must be emitted in order, so that any
declaration precedes usage. Zig, however, generates globals in
random order. To this end we keep for each global a list of
dependencies and perform a topological sort when flushing the
module.
2023-04-09 01:51:53 +02:00
Robin Voetter
80b8435569
spirv: overhaul constant lowering
Lowering constants is currently not really compatible with unions. In
this commit, constant lowering is drastically overhauled: instead of
playing nice and generating SPIR-V constant representations for everything
directly, we're just going to treat globals as an untyped bag of bytes (
or rather, SPIR-V 32-bit words), which we cast to the desired type at
usage. This is similar to how Rust generates constants in its LLVm backend.
2023-04-09 01:51:53 +02:00
Robin Voetter
764f19034d
spirv: union types/constants
Implements lowering union types and constants in the SPIR-V backend.
2023-04-09 01:51:53 +02:00
Robin Voetter
75abe3b43b
spirv: optional constants
Implements lowering optional constants in the SPIR-V backend.
2023-04-09 01:51:53 +02:00
Robin Voetter
0c53fea42c
spirv: improve genConstant usage
This little wrapper function allocates a result-id for us,
so that we don't have to do that.
2023-04-09 01:51:52 +02:00
Robin Voetter
12a3a8b100
spirv: slice constants
Implements lowering slice constants in the SPIR-V backend
2023-04-09 01:51:52 +02:00
Robin Voetter
e788dfa142
spirv: string literals
Implements lowering string literal constants in the SPIR-V backend
2023-04-09 01:51:52 +02:00
Robin Voetter
27833004db
spirv: optional types
Implements lowering optional types in the SPIR-V backend.
2023-04-09 01:51:52 +02:00
Robin Voetter
3c7f93aa69
spirv: generic global pointers
Similar to function locals, taking the address of a global that does
not have an explicit address space assigned to it should result
in a generic pointer, not a global pointer. Also similar to function
locals, they cannot be generated into the generic storage class, and
so are generated into the global storage class and then cast to a
generic pointer, using OpSpecConstantOp. Note that using
OpSpecConstantOp results is only allowed by a hand full of other
OpSpecConstant instructions - which is why we generate constant
structs using OpSpecConstantComposite: These may use OpVariable
and OpSpecConstantOp results, while OpConstantComposite may not.
2023-04-09 01:51:52 +02:00
Robin Voetter
fbe5f0c345
spirv: initial decl_ref pointer generation
Starts lowering decl_ref Pointer constants.
2023-04-09 01:51:52 +02:00
Robin Voetter
c9db6e43af
spirv: generate code directly in updateFunc/updateDecl
This cloneAir/cloneLiveness idea used to ignore Zig's internals
has proven buggy. Instead, just generate the code directly from
updateFunc and updateDecl as the other backends do, but pretend
that Zig is not an incremental compiler. The SPIR-V backend will
for the time being not support this.
2023-04-09 01:51:51 +02:00
Robin Voetter
34b98ee372
spirv: start lowering non-function decls
Start to lower decls which are not functions. These generate
an OpVariable instruction by which they can be used later on.
2023-04-09 01:51:51 +02:00
Robin Voetter
f1229e0f00
spirv: convert bools on load/store
Bools have a different immediate representation and memory
representation - which means that they must be converted every time
a bool is loaded from or stored into memory.
2023-04-09 01:51:51 +02:00