13588 Commits

Author SHA1 Message Date
LemonBoy
28a9e4c4aa libc: Add workaround for #4926
This change was cherry-picked from an updated version of the sysdep
folder contents, we're still shipping an outdated and incomplete set of
files.
2021-05-11 12:33:47 +02:00
LemonBoy
ac546f56eb stage2: Allow building musl/glibc in thumb mode 2021-05-11 12:27:24 +02:00
LemonBoy
b288f8c9a6 stage2: Always link -lpthread when using system libc
This is required when cross-compiling glibc targets.
2021-05-11 12:27:24 +02:00
LemonBoy
65ee7909b9 stage2: Pass -mthumb when compiling C/C++ code
Apparently the Clang driver requires this flag and ignores the target
triple.
2021-05-11 12:27:24 +02:00
Andrew Kelley
55d235dc38
Merge pull request #8711 from lithdew/master
std/os, x/os/socket: windows support, socket helpers, getpeername()
2021-05-10 19:00:53 -04:00
Andrew Kelley
2e4a48ef29
Merge pull request #8736 from ziglang/macos-zig-bootstrap
Use zig-bootstrap to build macOS binaries
2021-05-10 18:41:29 -04:00
jacob gw
24dfa61236 stage1: remove outdated error message regarding #447 2021-05-10 21:00:10 +02:00
xackus
8f8efcdd6e translate-c: fix typedefs with multiple names 2021-05-10 21:59:42 +03:00
Jakub Konka
b7a6a251a0 Tweak macos_arm64_script to use bootstrapped zig 2021-05-10 18:42:01 +02:00
Jakub Konka
603242fa86 Use zig-bootstrapped x86_64 macos compiler in CI 2021-05-10 13:55:48 +02:00
lithdew
0d0edd23a8 std/os: add missing sockaddr_storage defs 2021-05-10 19:22:31 +09:00
lithdew
e652595f2a std/os: fix sockaddr_storage padding size 2021-05-10 19:22:31 +09:00
lithdew
6d41e08664 x/os, os: fix setsockopt on windows, simplify Socket.setOption error set 2021-05-10 19:22:31 +09:00
lithdew
6cb6edb6f6 std/os/windows/ws2_32: add missing FIONBIO constant 2021-05-10 19:22:31 +09:00
lithdew
77f8a9ae22 x/os/socket, std/os/windows: implement loading winsock extensions
Implement loading Winsock extensions.

Add missing Winsock extension GUID's.

Implement readVectorized() for POSIX sockets and
readVectorized() / writeVectorized() for Windows
sockets.

Inverse how mixins are used to implement platform-independent syscalls
for the std.x.os.Socket abstraction. This cleans up the API as suggested
by @komuw.
2021-05-10 19:22:31 +09:00
lithdew
3d946ef5eb x/os, x/net, os:, fix typos/errors, add missing constants/docs
Add missing constants to ws2_32 such as SIO_BASE_HANDLE.

Made all declared constants in ws2_32 comptime_int, and fixed a few
broken constants (i.e. GUID's).

Fixed a few syscalls not having callconv(WINAPI) in ws2_32.

Fixed a typo in std.x.net.tcp.Client.

Removed unnecessary @alignCast's for socket addresses in
std.x.net.Socket.

Added a warning on using timeout methods for std.x.net.Socket.

Fixed compilation error spotted by CI in std.os that references
std.os.windows.ws2_32.SD_RECEIVE.

Renamed std.x.os.Socket.setOption()'s parameter `name: u32` to `code:
u32`.
2021-05-10 19:22:31 +09:00
Kenta Iwasaki
a24101be5b x/os/socket_posix.zig: make linger struct extern
Co-authored-by: LemonBoy <LemonBoy@users.noreply.github.com>
2021-05-10 19:22:31 +09:00
lithdew
e739b2b7d6 x/os/socket: use sockaddr_storage for accept() 2021-05-10 19:22:31 +09:00
lithdew
d3871af724 x/net/tcp, x/os/socket: tcp.Client.{Reader, Writer}
Only allow SOCK_STREAM (std.x.net.tcp.Client) sockets to have wrappers
for std.io.Reader and std.io.Writer provided, instead of Socket's in
general.
2021-05-10 19:22:31 +09:00
lithdew
d7b601b35e std/os, x/os/socket: windows support, socket helpers, getpeername()
Socket I/O methods such as read, readv, write, writev, send, recv,
sendmsg, recvmsg have been generalized to read(buf, flags), write(buf,
flags), readVectorized(vectors, flags), and writeVectorized(vectors,
flags). There is still some work left to be done abstracting both
readVectorized and writeVectorized properly across platforms, which is
work to be done in a future PR.

Support for setting the linger timeout of a socket, querying the remote
address of a socket, setting whether or not keep-alive messages are to
be sent through a connection-oriented socket periodically depending on
host operating system settings has been added.

`std.io.Reader` and `std.io.Writer` wrappers around `Socket` has been
implemented, which wrap around Socket.read(buf, flags) and
Socket.write(buf, flags). Both wrappers may be provided flags which are
passed to Socket.read / Socket.write accordingly.

Cross-platform support for `getpeername()` has been implemented.

Windows support for the new `std.x.os.Socket` has been implemented. To
accomplish this, a full refactor of `std.os.windows.ws2_32` has been
done to supply any missing definitions and constants based on
auto-generated Windows syscall bindings by @marler8997.

`std.x.net.TCP.Listener.setQuickACK` has been moved to
`std.x.net.TCP.Client.setQuickACK`.

Windows support for resolving the scope ID of an interface name
specified in an IPv6 address has been provided.

`sockaddr_storage` definitions have been provided for Windows, Linux,
and Darwin. `sockaddr_storage` is used to allocate space before any
socket addresses are queried via. calls such as accept(), getsockname(),
and getpeername().

Zig-friendly wrappers for GetQueuedCompletionStatusEx(), getpeername(),
SetConsoleCtrlHandler(), SetFileCompletionNotificationModes() syscalls
on Windows have been provided.

Socket.setOption() was provided to set the value of a socket option in
place of os.setsockopt. Socket.getOption() will be provided in a future
PR.

There is still further work to be done regarding querying socket option
values on Windows, which is to be done in a subsequent PR.
2021-05-10 19:22:31 +09:00
Jakub Konka
9c03b39d1e
Merge pull request #8723 from jedisct1/init-stat
Initialize the Stat structure
2021-05-10 09:42:37 +02:00
Frank Denis
2d11967734
p256: properly handle neutral element & add AffineCoordinates struct (#8718)
Instead of multiple references to an anonymous structure to represent affine coordinates, add an actual `AffineCoordinates` structure.

Also properly handle the neutral element during coordinate conversion and fix mixed addition.

And comptime the small precomputation table for basepoint multiplication.
2021-05-09 18:20:43 +02:00
Frank Denis
c3675d9351 Shorten 2021-05-09 18:17:09 +02:00
Frank Denis
4e399ef62c Initialize the Stat structure
The system `stat` structure includes padding, and, on some
operating systems such as all BSDs, "spare" bytes at the end.

We can't reliably compare two `Stat` values if these are
uninitialized, while being later compared.

This is what was causing the `fstatat` test to fail on FreeBSD
since the update to LLVM 12. It was previously only passing by
accident.
2021-05-09 18:15:42 +02:00
Jakub Konka
f67e756211 zld: adjust signed displacement source target addr
Previously, I mistakenly assumed that offset of the relocation
is enough when calculating relative offset of the target from the
source target section base address in case of section-based relocs
on x86_64. While this is true for `__TEXT,__text` section which
always starts at 0x0 in object files, this is absolutely not true
for `__TEXT,__StaticInit` section which will have nonzero base
address hence resulting in incorrect displacement calculations for
SIGNED relocs.
2021-05-09 16:24:53 +02:00
Jakub Konka
15d6efecfb
Merge pull request #8709 from joachimschmidt557/stage2-arm
stage2 ARM: Generate correct code when spilling registers
2021-05-09 14:16:40 +02:00
joachimschmidt557
f2a3368891 stage2 ARM: Add spill registers test 2021-05-09 08:48:58 +02:00
joachimschmidt557
d211dc37c8 stage2 ARM: Overhaul of genArmBinOp 2021-05-09 08:48:58 +02:00
Andrew Kelley
2299e5ff1d fix merge conflicts from previous commit
Any PRs merged after the one that made testing functions return errors
needs to get rebased!
2021-05-08 23:12:34 -07:00
Andrew Kelley
b88d381dec
Merge pull request #8474 from gracefuu/grace/encode-instruction
stage2 x86_64: encoding helpers, fix bugs
2021-05-09 01:36:51 -04:00
Andrew Kelley
67154d233e
Merge pull request #8686 from Vexu/try
Allow tests to fail
2021-05-08 17:29:44 -04:00
Andrew Kelley
fed1c9c3ec link/MachO: fix --verbose-link ensureCapacity bug 2021-05-08 11:24:07 -07:00
Veikka Tuominen
7437c47d55 tests: work around miscompilation 2021-05-08 15:18:13 +03:00
Veikka Tuominen
08b6baca12 update usage of std.testing in langref.html 2021-05-08 15:16:05 +03:00
Veikka Tuominen
7fe39c4e96 update usage of std.testing in compiler_rt 2021-05-08 15:15:30 +03:00
Veikka Tuominen
42a95197f3 update usage of std.testing in stage2 2021-05-08 15:15:30 +03:00
Veikka Tuominen
0a38f61d58 update usage of std.testing in behavior and standalone tests 2021-05-08 15:15:30 +03:00
Veikka Tuominen
fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
Veikka Tuominen
59f9253d94 allow tests to fail 2021-05-08 15:15:23 +03:00
Michael Dusan
84d5cc31c5 fix test to restore cwd after chdir
- `../zig-cache/tmp` is no longer created by subsequent test(s)
2021-05-07 01:04:38 -04:00
Andrew Kelley
530e67cb86
Merge pull request #8683 from LemonBoy/thumblinux
Initial bringup for Linux/Thumb2
2021-05-06 12:50:34 -04:00
lars
96e593145d stage1: improve message for missing fn return type
Coming from other languages it might be tempting for programmers to
accidentally leave out the return type instead of returning 'void'.

The error for this used to be

    error: invalid token: '{'
    pub fn main() {
                  ^

which is misleading. The '{' is expected but only after a return type.

The new message is

    error: expected return type (use 'void' to return nothing), found: '{'
    pub fn main() {
                  ^

which not only points out the real error but also hints at a (probably)
very common case where someone coming from e.g. Go is used to not
specifying a return type if a function returns nothing and thus forgets
to put 'void' there.

It might seem overkill to hint at the 'void' option but then the
compiler error messages are our user interface to the programmer. We
can be better than other languages in our error messages and leaving
out the return type seems to be a rather clear indication of the above
mentioned issue. Adding this will help more than distract.
2021-05-06 18:44:10 +02:00
Jakub Konka
88d40fc005 zld: sort tlv offsets by source address 2021-05-06 17:10:05 +02:00
Jakub Konka
ef8a666797 zld: cleanup relocs and flag errors on unhandled symbol types 2021-05-06 17:09:58 +02:00
Jakub Konka
ad33e34836 tests: re-enable reduce behavior tests for wasm32 2021-05-05 21:26:50 +02:00
LemonBoy
9d409233b2 std: Implement hex float printing
The results have been cross-checked with LLVM's APFloat implementation
by randomly sampling the f32/f64 space, while the f16 one was completely
checked given the small size.
2021-05-05 12:37:40 -04:00
LemonBoy
18b46485bc stage2: Fix UAF in ErrorMsg destructor
After calling gpa.destroy the object is gone for good, setting the
contents to undefined is a bug and may crash the compiler.
2021-05-05 12:37:04 -04:00
Michael Dusan
622a3ac876
Merge pull request #8691 from lithdew/master
x/net: fix tcp tests for openbsd and add missing `fmt` import
2021-05-05 05:54:47 -04:00
Andrew Kelley
368e13a9a1
Merge pull request #8671 from LemonBoy/arm-host-det
ARM/AArch64 CPU host detection
2021-05-05 03:17:32 -04:00
LemonBoy
e863204c47 zig fmt: Fix edge case in inline asm parsing
The presence of a trailing comma in the single and only input/output
declaration confused the parser and made zig fmt discard any element
placed after the comma.
2021-05-05 03:16:07 -04:00