23107 Commits

Author SHA1 Message Date
Veikka Tuominen
82133cd992 Sema: improve error message of field access of wrapped type
Closes #15027
2023-03-21 00:34:12 +02:00
Veikka Tuominen
9d9815fb9c Value: handle comparisons of runtime_values
Closes #15004
2023-03-21 00:34:12 +02:00
Veikka Tuominen
773b1c4c5c llvm: fix lowering packed union initiated to zero-bit value
Closes #14980
2023-03-21 00:34:12 +02:00
Veikka Tuominen
0c16912733 std: improve error for formatting a function body type
Closes #14915
2023-03-20 17:29:43 +02:00
Reuben Dunnington
30427ff794
Fix GetFileInformationByHandle compile error (#14829)
* Fix GetFileInformationByHandle compile error

The wrapper function was mistakenly referencing ntdll.zig when the actual function is declared in kernel32.zig.

* delete GetFileInformationByHandle since it's not used by the stdlib
2023-03-19 23:23:05 +00:00
Jakub Konka
9a203fa789
Merge pull request #14986 from ziglang/macos-hcs
Upstream macOS hot-code swapping PoC
2023-03-19 21:22:40 +01:00
Ganesan Rajagopal
30aeb41a19 Fix linker segfault adding rpath to sharedlib
If the shared library is a relative path, dirname will return null causing a segfault. In the case I debugged, the current directory was already in RPATH so just ignoring this case seems a reasonable fix. After this fix "make" and "make test" pass for mimalloc.

Closes #13766
2023-03-19 17:42:27 +01:00
Ryan Liptak
2fce991d2a Remove std.os.windows.QueryInformationFile (a wrapper of NtQueryInformationFile)
This function is unused, and the current implementation contains a few footguns:

- The current wrapper treats all possible errors as unexpected, even likely ones like BUFFER_OVERFLOW (which is returned if the size of the out_buffer is too small to contain all the variable-length members of the requested info, which the user may not actually care about)
- Each caller may need to handle errors differently, different errors might be possible depending on the FILE_INFORMATION_CLASS, etc, and making a wrapper that handles all of those different use-cases nicely seems like it'd be more trouble than it's worth (FILE_INFORMATION_CLASS has 76 different possible values)

If a wrapper for NtQueryInformationFile is wanted, then it should probably have wrapper functions per-use-case, like how QueryObjectName wraps NtQueryObject for the `ObjectNameInformation` class
2023-03-19 17:33:25 +01:00
Jakub Konka
6874b29308 macho: fix 32bit build 2023-03-19 17:13:38 +01:00
Luuk de Gram
c26cbd561c
Merge pull request #14998 from Luukdegram/shared-mem
wasm-linker: Implement shared-memory
2023-03-19 15:43:06 +01:00
Luuk de Gram
322ace70f9
Merge pull request #14838 from Luukdegram/bss-fix
wasm-linker: fix storing atoms in the correct segment
2023-03-19 15:42:39 +01:00
Jakub Konka
f026939a40 macho: enable hot update state only when on compatible host 2023-03-19 09:45:05 +01:00
Andrew Kelley
8f481dfc3c fix std.Build.OptionsStep
* use the same hash function as the rest of the steps
 * fix race condition due to a macOS oddity.
 * fix race condition due to file truncation (rename into place instead)
 * integrate with marking Step.result_cached. check if the file already
   exists with fs.access before doing anything else.
 * use a directory so that the file basename can be "options.zig"
   instead of a hash digest.
 * better error reporting in case of file system failures.
2023-03-19 00:39:29 -04:00
Jakub Konka
6f15eedff1 darwin: put posix spawn constants in POSIX_SPAWN struct 2023-03-18 21:54:05 +01:00
Jakub Konka
0aab3bda12 macho: add wrappers for attaching/detaching from HCS process 2023-03-18 21:53:46 +01:00
Jakub Konka
37192bcdcb macos: HCS PoC working 2023-03-18 21:53:36 +01:00
Jakub Konka
f1e25cf43e macho: add hot-code swapping poc 2023-03-18 21:53:26 +01:00
Jakub Konka
266c81322e darwin: resurrect posix_spawn wrappers 2023-03-18 21:53:15 +01:00
Jakub Konka
e35c8a2fd6 link: use std.os.ptrace wrapper on linux 2023-03-18 21:52:52 +01:00
Jakub Konka
a23ef3783b os.zig: expose ptrace wrapper for darwin and linux 2023-03-18 21:52:40 +01:00
Jakub Konka
2ac8d90df0
Merge pull request #14935 from ziglang/fix-macos-build2
link: move macOS kernel inode cache invalidation to MachO linker
2023-03-18 21:45:21 +01:00
Luuk de Gram
4e0d7154b1
wasm-linker: implement __wasm_init_memory & flag
Implements the __wasm_init_memory and __wasm_init_memory_flag synthetic
function and symbol.

The former will initialize all passive segments during runtime. For the
bss section we will fill it with zeroes, whereas the other segments
will simply be initialized only.

The latter stores the offset into the linear data section, after all
heap memory that is part of the Wasm module. Any memory initialized
at runtime starts from this offset.
2023-03-18 20:13:30 +01:00
Luuk de Gram
09d6938df9
wasm: add atomics opcodes and refactoring
This adds the atomic opcodes for the Threads proposal to the
WebAssembly specification: https://github.com/WebAssembly/threads

PrefixedOpcode has been renamed to MiscOpcode as there's multiple
types of prefixed opcodes. This naming is similar to other tools
such as LLVM. As we now use the 0xFE prefix, we moved the
function_index MIR instruction as it was occupying the same value.
This commit includes renaming all related opcodes.
2023-03-18 20:13:30 +01:00
Luuk de Gram
9fce1df4cd
wasm-linker: implement runtime TLS relocations 2023-03-18 20:13:30 +01:00
Luuk de Gram
9d13c2257d
wasm-linker: implement TLS initialization function
Implements the TLS initialization function. This is a synthetic function
created by the linker. This will only be created when shared-memory is
enabled. This function will be called during thread creation, if there's
any TLS symbols, which will initialize the TLS segment using the
bulk-memory feature.
2023-03-18 20:13:30 +01:00
Luuk de Gram
ff28c8b600
wasm-linker: create TLS symbols
Initialize TLS symbols when shared-memory is enabled. Those symbols
will be called by synthetic functions created by the linker. (TODO).
2023-03-18 20:13:30 +01:00
Luuk de Gram
00af3a79ae
wasm-linker: emit 'data count' & segment flags
When linking with shared-memory enabled, we must ensure to emit
the "data count" section as well as emit the correct segment flags
to tell the runtime/loader that each segment is passive. This is
required as we don't emit the offsets for such segments but instead
initialize each segment (for each thread) during runtime.
2023-03-18 20:13:29 +01:00
Luuk de Gram
fb9d3cd50e
wasm-linker: feature verifiction for shared-mem
When the user enables shared-memory, we must ensure the linked objects
have the 'atomics' and 'bulk-memory' features allowed.
2023-03-18 20:13:29 +01:00
Luuk de Gram
09abd53da7
wasm-linker: refactor Limits and add flags
Rather than adding the flags "on-demand" during limits writing,
we now properly parse them and store the flags within the limits
itself. This also allows us to store whether we're using shared-
memory or not. Only when the correct flag is set will we set the
max within `Limits` or else we will leave it `undefined`.
2023-03-18 20:13:29 +01:00
Luuk de Gram
b0024c4884
wasm-linker: basic TLS support
Linker now parses segments with regards to TLS segments. If the name
represents a TLS segment but does not contain the TLS flag, we set it
manually as the object file is created using an older compiler (LLVM).

For now we panic when we find a TLS relocation and implement those
later.
2023-03-18 20:13:25 +01:00
Nicolas Sterchele
49d37e2d17 build-step: remove latest LogStep ref
LogStep was removed during the build parallel enhancement made in this
commit 58edefc6d1716c0731ee2fe672ec8d073651aafb
2023-03-18 15:08:53 -04:00
square
887abd0f33 delete --prominent-compile-errors from help 2023-03-18 20:13:52 +02:00
Jakub Konka
46171bf6c8 macho+zld: clean up how to interface with link.zig and openPath() 2023-03-18 19:05:06 +01:00
Luuk de Gram
d0fb1ef962
wasm-link: update bss linker test
Updates the linker test to verify the various cases where we must
store the data in the bss segment.
2023-03-18 16:47:12 +01:00
Luuk de Gram
bddf138e72
wasm-link: fix storing decls in the right segment
When a decl is `undefined` is must be stored in the data segment when
the build mode is safe. For unsafe optimize modes, it must be stored
in the bss segment instead.

For mutable decls where the atom contains all zeroes, it must always
be stored in the bss segment. All other values will result in the
atom being stored in the data segment.
2023-03-18 16:12:42 +01:00
Jakub Konka
ee705e3ac7 macho+zld: clean up opening and closing of file descriptors 2023-03-18 09:32:29 +01:00
Motiejus Jakštys
c31007bb47 fix copy-paste errors
--sysroot was copy-pasted instead of --maxrss from above. Also, make it less likely in other places for this to be repeated.

I found this by accident when reviewing f51413d2cf0bd87079dace7f6481d2a361a19ea6
2023-03-17 19:42:46 -04:00
hequn
f56f3c5824
Enable IPv4 mapped address conversion in linux version getAddressList (#14916)
It seems like the original code of setsockopt is not effective because
i catch the EINVAL branch when uncomment this code, it should call
setsockopt before the bind call.

This should fix issue #14900.

Co-authored-by: Qun He <hawkbee@qq.com>
2023-03-17 15:58:02 -04:00
mlugg
71e873703f Sema: make @returnAddress return 0 at comptime
See also #14938.

Resolves: #14931
2023-03-17 15:55:02 -04:00
Motiejus Jakštys
9f2aa3fbee Build.zig_exe: make it sentinel-aware
This is useful for tests that want to `execve` zig directly. The string
is already null-terminated, so this will just expose it as such,
removing an extra allocation from the test.

Will be used in #14462
2023-03-17 15:54:09 -04:00
Bas Westerbaan
2089b3f193
tls: use post-quantum secure key exchange (#14920) 2023-03-17 17:51:24 +01:00
Motiejus Jakštys
e0dd20b02e
add BoundedArrayAligned (#14580)
This is useful for creating byte buffers of actually-different-things.
Copied the argument order from `Allocator.alignedAlloc`

I noted that `ArrayListAligned` is going out of it's way to not set the
alignment at comptime when it is not specified. However, I was not able
to do that the same way here, and good people on IRC, @ifreund in
particular (thanks!) assured me that

    [N]T align(@alignOf(T))

is equivalent to

    [N]T
2023-03-17 17:50:25 +01:00
Jacob Young
cfcd6698cd main: add debug option to dump unoptimized llvm ir 2023-03-17 01:57:14 -04:00
mlugg
4ec299007a Sema: allow dereferencing ill-defined pointers to zero-bit types at comptime
It doesn't matter if a pointer to a zero-bit (i.e. OPV) type is
undefined or runtime-known; we still know the result of the dereference
at comptime. Code may use this, for instance, when allocating zero-bit
types: `@as(*void, undefined)` is entirely reasonable to use at runtime,
since we know the pointer will never be accessed, thus it should be
valid at comptime too.
2023-03-17 01:56:36 -04:00
Andrew Kelley
68c7261e1d disable bad std lib tests
see tracking issue #14968
2023-03-16 18:25:59 -07:00
Andrew Kelley
b4d58e93ea make docgen accept --zig-lib-dir 2023-03-16 15:43:51 -07:00
Evin Yulo
b3af5d076c Fix #14901: parseFloat parsing 0x successfully 2023-03-16 19:36:06 +02:00
Jakub Konka
76afdd0586 link: move macOS kernel inode cache invalidation to MachO linker 2023-03-16 17:30:25 +01:00
mllken
da0509750a std.os: handle EPERM errno for bind 2023-03-16 17:41:58 +02:00
InKryption
9964f1c160 Add error for bad cast from *T to *[n]T
Casting `*T` to `*[1]T` should still work, but every other length
will now be a compiler error instead of a potential OOB access.
2023-03-16 13:00:36 +02:00