Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
244 commits
Select commit Hold shift + click to select a range
21b7316
introduce std.Io interface
andrewrk Mar 25, 2025
cb9f9bf
make thread pool satisfy async/await interface
andrewrk Mar 25, 2025
4d56267
demo: single-threaded green threads implementation
andrewrk Mar 27, 2025
fe6f1ef
EventLoop: prepare for threading
jacobly0 Mar 27, 2025
629a204
EventLoop: rewrite context switching
jacobly0 Mar 27, 2025
9d0f44f
EventLoop: add threads
jacobly0 Mar 27, 2025
f1dd06b
EventLoop: implement main idle fiber
jacobly0 Mar 27, 2025
31ed2d6
fix context passing in threaded Io impl
andrewrk Mar 28, 2025
4c7c0c4
update threaded fibers impl to actually storing args
andrewrk Mar 28, 2025
29355ff
EventLoop: fix incorrect alignment panic
jacobly0 Mar 28, 2025
1493c3b
EventLoop: move context after the async closure
jacobly0 Mar 28, 2025
08bb7c6
free freeing wrong amount in thread pool impl
andrewrk Mar 29, 2025
66b0f7e
start adding fs functions to std.Io
andrewrk Mar 29, 2025
238de05
WIP
andrewrk Mar 29, 2025
db0dd3a
EventLoop: get file operations working
jacobly0 Mar 29, 2025
d958077
EventLoop: fix futex usage
jacobly0 Mar 29, 2025
a29b212
better API for Io.async
andrewrk Mar 29, 2025
e7caf3a
std.Io: introduce cancellation
andrewrk Mar 30, 2025
5041c9a
EventLoop: implement thread-local queues and cancellation
jacobly0 Mar 30, 2025
08b609a
Io: implement sleep and fix cancel bugs
jacobly0 Mar 30, 2025
0d4b358
implement Mutex, Condition, and Queue
andrewrk Mar 31, 2025
a1c1d06
std.Io: add detached async
andrewrk Mar 31, 2025
f84aca3
Io: implement faster mutex
jacobly0 Mar 31, 2025
266bcfb
EventLoop: implement detached async
andrewrk Mar 31, 2025
8773b63
EventLoop: take DetachedClosure into account when allocating
andrewrk Mar 31, 2025
929b616
std.Io.Condition: change primitive to support only one
andrewrk Mar 31, 2025
4063205
EventLoop: remove broken mechanism for making deinit block on detached
andrewrk Apr 1, 2025
e366b13
EventLoop: revert incorrect optimization
jacobly0 Apr 1, 2025
08ce000
EventLoop: fix `std.Io.Condition` implementation
jacobly0 Apr 1, 2025
0f105a8
EventLoop: let the allocator do its job
andrewrk Apr 1, 2025
3eb7be5
EventLoop: implement detached fibers
jacobly0 Apr 1, 2025
c4fcf85
Io.Condition: implement full API
jacobly0 Apr 2, 2025
7aa4062
introduce Io.select and implement it in thread pool
andrewrk Apr 4, 2025
f158ec5
Io.EventLoop: select stub
andrewrk Apr 4, 2025
c88b8e3
std.Io.EventLoop: implement select
andrewrk Apr 4, 2025
4b657d2
std.Io: remove `@ptrCast` workarounds
andrewrk Apr 4, 2025
e1cbcec
Io: update for new linked list API
andrewrk Apr 4, 2025
fd4dd3b
update to sync with master
andrewrk Jul 10, 2025
14c3dc4
revert std.Thread.Pool for now
andrewrk Jul 10, 2025
f5d8492
std.Io: rename go to asyncDetached
andrewrk Jul 10, 2025
30be75c
std.Io.ThreadPool: fix asyncDetached
andrewrk Jul 10, 2025
ec3e4c0
std.Io.EventLoop: add aarch64 support
andrewrk Jul 12, 2025
f762597
std.Io: add asyncConcurrent and asyncParallel
andrewrk Jul 18, 2025
7ead86e
std.Io: fix error handling and asyncParallel docs
andrewrk Jul 18, 2025
84d6040
std.Io: delete asyncParallel
andrewrk Jul 18, 2025
d801a71
add std.testing.io
andrewrk Jul 20, 2025
668f905
add some networking
andrewrk Jul 20, 2025
bd3c65f
std.Io.net: partially implement HostName.lookup
andrewrk Sep 4, 2025
e7729a7
std: start moving fs.File to Io
andrewrk Sep 6, 2025
b4e5e9d
Io.net: implement sortLookupResults
andrewrk Sep 7, 2025
fc1e3d5
Io.net: partial implementation of dns lookup
andrewrk Sep 8, 2025
0e9280e
std.Io: extract Dir to separate file
andrewrk Sep 11, 2025
5089352
std.Io: rename ThreadPool to Threaded
andrewrk Sep 22, 2025
d776a6b
Io.net: rework IPv6 parsing and printing
andrewrk Sep 22, 2025
e7c9df9
Io.net: use resolve for IPv6
andrewrk Sep 22, 2025
885b3f8
Io.net: finish implementing IPv6 parsing
andrewrk Sep 23, 2025
5782158
std.net: fix parsing IPv6 addr "::"
andrewrk Sep 23, 2025
8771a9f
std.Io.net: progress towards DNS resolution
andrewrk Sep 23, 2025
60c4bdb
Io.net: implement more networking
andrewrk Sep 27, 2025
f9d976a
std.Io: rename asyncConcurrent to concurrent
andrewrk Sep 27, 2025
5469db6
std.Thread.ResetEvent: make it more reusable
andrewrk Sep 27, 2025
8e1da66
std.Io: implement Group API
andrewrk Sep 27, 2025
2e1ab5d
std.Io.Threaded: implement Group.cancel
andrewrk Sep 29, 2025
b224002
std.Io.net.HostName: finish implementing DNS lookup
andrewrk Sep 30, 2025
cde5a51
std.Io.net: make netSend support multiple messages
andrewrk Oct 1, 2025
3b80fde
std.os.linux: remove sendmmsg workaround
andrewrk Oct 1, 2025
bcb6760
std.os.linux: remove unnecessary warnings from sendmmsg
andrewrk Oct 1, 2025
95dee2a
std.Io: implement netSend
andrewrk Oct 1, 2025
961961c
std: fix msghdr and cmsghdr when using musl libc
andrewrk Oct 2, 2025
a6347a6
std.Io.net: implement receiving connectionless messages
andrewrk Oct 2, 2025
62d0dd0
std.Io.Threaded.netReceive: recvmsg first, then poll
andrewrk Oct 2, 2025
f1a590c
std.Io.net.HostName: implement DNS reply parsing
andrewrk Oct 3, 2025
85a6fea
std.Io.net.HostName: implement DNS name expansion
andrewrk Oct 3, 2025
00f26cb
WIP land the std.Io interface
andrewrk Oct 3, 2025
774df26
WIP: hack at std.Io on a plane
andrewrk Oct 3, 2025
b428612
WIP: hack away at std.Io return flight
andrewrk Oct 6, 2025
066864a
std.zig.system: upgrade to std.Io.Reader
andrewrk Oct 7, 2025
47aa5a7
std: updating to std.Io interface
andrewrk Oct 8, 2025
69b54b0
remove bad assert
andrewrk Oct 9, 2025
89412fd
std.Io: implement fileStat
andrewrk Oct 9, 2025
ebcc6f1
std.Io: bring back Timestamp but also keep Clock.Timestamp
andrewrk Oct 9, 2025
e85df85
std.mem: improve containsAtLeastScalar implementation and rename
andrewrk Oct 9, 2025
eadfefa
std.Io: implement dirMake
andrewrk Oct 9, 2025
750b143
std: fix some Io compilation errors
andrewrk Oct 9, 2025
8a1e6c8
std.Io: implement dirStatPath
andrewrk Oct 9, 2025
b1733b7
std.Io: implement dirOpenFile
andrewrk Oct 9, 2025
7d47811
fix compilation errors introduced by rebasing
andrewrk Oct 9, 2025
fcac861
Add missing clobbers to context switching
lalinsky Oct 9, 2025
63801c4
std.crypto.Certificate.Bundle: remove use of File.readAll
andrewrk Oct 9, 2025
9e681ca
std.Uri: fix compilation error
andrewrk Oct 9, 2025
3b34622
std.Io: add unix domain sockets API
andrewrk Oct 11, 2025
d408032
progress towards compiler building again
andrewrk Oct 11, 2025
71ff6e0
std: fix seekBy unit test
andrewrk Oct 13, 2025
be1ae43
std.Io.Threaded.netReadPosix: support cancelation
andrewrk Oct 13, 2025
4d62f08
add BRANCH_TODO file
andrewrk Oct 14, 2025
e0e463b
std.Io.net.Stream.Reader: fix not using buffer
andrewrk Oct 14, 2025
923a7bd
std.Io.net: fix parsing IPv4-mapped IPv6 addresses
andrewrk Oct 14, 2025
d3f0c46
std.Io.net.HostName: fix DNS resolution
andrewrk Oct 14, 2025
5398082
std.net: IPv6 parsing fixes
andrewrk Oct 14, 2025
d680b9e
std.Io.File: add WouldBlock to the error set
andrewrk Oct 14, 2025
e8cea8a
std.Io.Threaded: implement netListenUnix
andrewrk Oct 14, 2025
0732ff2
std.Io.Threaded: implement connecting to unix sockets
andrewrk Oct 14, 2025
79a59c5
coff linker: don't check the time
andrewrk Oct 14, 2025
c2d1a33
std.fs.File: begrudgingly add back deprecated APIs
andrewrk Oct 14, 2025
2bcdde2
compiler: update for introduction of std.Io
andrewrk Oct 14, 2025
1382e41
std.Io.Threaded: import std.Io.net
andrewrk Oct 14, 2025
35ce907
std.Io.net.HostName: move lookup to the interface
andrewrk Oct 15, 2025
d3c4158
std.Io: implement Select
andrewrk Oct 15, 2025
adaef43
std.net.HostName.connect: rework to avoid waiting for DNS
andrewrk Oct 15, 2025
80069c1
std.Io.Queue: add "uncancelable" variants to "get"
andrewrk Oct 15, 2025
426a377
std.Io.net.Stream: add "const" variant to "close"
andrewrk Oct 15, 2025
870a682
std.Io.net.HostName.connect: fix resource leaks
andrewrk Oct 15, 2025
10bfbd7
std.Io.Threaded: rename from "pool"
andrewrk Oct 15, 2025
060fd97
std.Io.Group: add cancellation support to "wait"
andrewrk Oct 15, 2025
81b1bfb
std.Io.Threaded: wrangle TODOs
andrewrk Oct 15, 2025
1e81c3a
std.Io: rename EventLoop to IoUring
andrewrk Oct 15, 2025
bb1bf5b
std.Io: stub file writing rather than incorrect impl
andrewrk Oct 15, 2025
f7d47ae
README: LLVM-less builds are more capable now
andrewrk Oct 16, 2025
031044b
std: fix macos compilation errors
andrewrk Oct 16, 2025
18ec968
std.Io.Threaded: add support for getaddrinfo
andrewrk Oct 16, 2025
bf841bb
std.Io.Threaded: implement futexes on darwin
andrewrk Oct 16, 2025
90fdd21
std: move DNS record enum to a better namespace
andrewrk Oct 16, 2025
22334f5
std: make IPv6 address parsing system-independent
andrewrk Oct 16, 2025
f7bbcb4
fix miscellaneous compilation failures
andrewrk Oct 16, 2025
6336d58
std.Io.Threaded: fix getaddrinfo usage
andrewrk Oct 16, 2025
f14c4c3
std.Io.net.HostName: fix connectMany not running DNS async
andrewrk Oct 16, 2025
7b1502f
std: fix compilation errors on macos
andrewrk Oct 16, 2025
3bf0ce6
fix miscellaneous compilation errors
andrewrk Oct 17, 2025
f8ea00b
std.Io: add dirAccess
andrewrk Oct 17, 2025
ec9dfc5
std.Io.Threaded: handle ECANCELED
andrewrk Oct 17, 2025
1431275
std.Io.Threaded: implement dirMake for WASI
andrewrk Oct 17, 2025
d4215ff
std.Io.Threaded: implement dirCreateFile for WASI
andrewrk Oct 17, 2025
cf6fa21
std.Io.Threaded: fix netWrite cancellation
andrewrk Oct 17, 2025
e87ceb7
std.Io.net.Server: refine AcceptError set
andrewrk Oct 17, 2025
da6b959
std.Io.Threaded: implement dirOpenFile for WASI
andrewrk Oct 17, 2025
81e7e9f
std.Io: add dirOpenDir and WASI impl
andrewrk Oct 17, 2025
752d386
std.Io.Threaded: fix -fsingle-threaded build
andrewrk Oct 17, 2025
43c2ba3
std: accessZ -> access
andrewrk Oct 17, 2025
97b9cc0
aro: avoid asking for the time
andrewrk Oct 18, 2025
2d7d98d
std.fs: use BadPathName rather than InvalidWtf8 on Windows
andrewrk Oct 18, 2025
21e195a
std: move some windows path checking logic
andrewrk Oct 18, 2025
83e4ff6
std.Io: add dirClose
andrewrk Oct 19, 2025
b215f86
std.Io.net.HostName.ResolvConf: ignore nameservers above max
andrewrk Oct 19, 2025
10b1eef
std: fix compilation errors on Windows
andrewrk Oct 19, 2025
ed7747e
std.Io.Threaded: add dirMake for Windows
andrewrk Oct 20, 2025
f98352e
std.debug.SelfInfo: add missing io parameter to getSymbol
andrewrk Oct 20, 2025
482343f
std.Io.Threaded: implement dirStatPath for Windows
andrewrk Oct 20, 2025
aa6e8ef
std.Io.Threaded: implement dirAccess for Windows
andrewrk Oct 20, 2025
b561d5f
std.Io.Threaded: implement dirCreateFile for Windows
andrewrk Oct 20, 2025
1c67607
std.Io.Threaded: implement dirOpenFile for Windows
andrewrk Oct 20, 2025
6d1b2c7
std.Io: introduce openSelfExe
andrewrk Oct 20, 2025
97bde94
compiler: upgrade unit tests to new API
andrewrk Oct 20, 2025
894cb5a
std.posix: untangle getRandomBytesDevURandom from Io.Reader
andrewrk Oct 20, 2025
71c86e1
std.posix: fix compilation on wasm32-freestanding
andrewrk Oct 20, 2025
dc6a4f3
std.Io: add dirMakePath and dirMakeOpenPath
andrewrk Oct 20, 2025
62c0496
std.Io.Threaded: implement dirOpenDir
andrewrk Oct 20, 2025
34891b5
std.Io.Threaded: implement netListen for Windows
andrewrk Oct 20, 2025
0b5179a
std.Io.Threaded: implement netAccept for Windows
andrewrk Oct 21, 2025
76107e9
std.Io.Threaded: implement netBindIp for Windows
andrewrk Oct 21, 2025
4174ac1
resinator: update for new Io APIs
andrewrk Oct 21, 2025
67df66c
update some tests and tools for new Io APIs
andrewrk Oct 21, 2025
4ed74a9
std.Io.Threaded: implement netConnectIp for Windows
andrewrk Oct 21, 2025
aadd8d4
std: back out the StackTrace byval changes
andrewrk Oct 21, 2025
d257b13
std.Io.Threaded: fix compilation failures on Windows
andrewrk Oct 21, 2025
0107e58
std.Io.Threaded: implement Windows futex functions
andrewrk Oct 21, 2025
dab8dd5
std.os.windows.ws2_32: remove 'A' variants
andrewrk Oct 21, 2025
ab003cd
std.Io.Threaded: implement netLookup for Windows
andrewrk Oct 21, 2025
00a3123
std.process.Child: update for std.Io changes
andrewrk Oct 21, 2025
2f26025
std: fix build failure on wasm32-freestanding
andrewrk Oct 21, 2025
a3ddca3
std.Io.Threaded: delete Windows implementation of if_nametoindex
andrewrk Oct 22, 2025
0321524
std.Io.Threaded: fix signature of dirMakeOpenPathWasi
andrewrk Oct 22, 2025
873bcb5
fix some std.Io compilation failures
andrewrk Oct 22, 2025
59ffa60
std.Io.Threaded: fix sending invalid pointer
andrewrk Oct 22, 2025
a5c309a
std.Io.net.Socket.send: fix compilation errors
andrewrk Oct 22, 2025
d6b0686
std.Io: add Kqueue implementation
andrewrk Oct 22, 2025
df84dc1
add bind
andrewrk Oct 22, 2025
4107093
revert adding asyncDetached
andrewrk Oct 22, 2025
dd945bf
one kqueue per thread
andrewrk Oct 23, 2025
92b8378
concurrent and await
andrewrk Oct 23, 2025
9d6750f
std.Io.Kqueue: implement netSend
andrewrk Oct 23, 2025
f17c6bb
std.Io.Kqueue: implement netConnect
andrewrk Oct 23, 2025
1b0dcd4
std.Io.Threaded: fix setting of O_NONBLOCK flag
andrewrk Oct 23, 2025
0497f88
std.Io.Kqueue: implement netRead
andrewrk Oct 23, 2025
cc11dd1
std.Io.Kqueue: implement EAGAIN logic for netRead
andrewrk Oct 23, 2025
6a64c9b
std.Io.Kqueue: add missing Thread deinit logic
andrewrk Oct 23, 2025
5578c76
std.Io.Kqueue: implement wait queue per fd
andrewrk Oct 23, 2025
a1f177d
std.Io.Threaded: stub netListenUnix for Windows
andrewrk Oct 23, 2025
89bb58e
incr-check: windows source files depend on ws2_32
andrewrk Oct 23, 2025
5d7672f
std.Io.Threaded: stub netConnectUnix for Windows
andrewrk Oct 23, 2025
5c527a1
std.Io.Threaded: implement fileStat for Windows
andrewrk Oct 23, 2025
701d4bc
objcopy: update for std.Io API
andrewrk Oct 23, 2025
46f7e3e
std.Io.Threaded: add ioBasic which disables networking
andrewrk Oct 23, 2025
c87fbd5
std.os.linux.IoUring: use linux msghdr
andrewrk Oct 23, 2025
ecdc004
std.Io.net: make it easier to use netReceiveMany correctly
andrewrk Oct 24, 2025
ae86c0f
std.Io: adjust concurrent error set
andrewrk Oct 24, 2025
e6b4e1a
disable self-hosted wasm test-cases
andrewrk Oct 24, 2025
ed7067a
std.Io: more convenient sleep
andrewrk Oct 24, 2025
85e159e
std.Io.Threaded: closures must always be run even when canceled
andrewrk Oct 24, 2025
a8f95e5
std.Io.Threaded: implement cancellation for pthreads
andrewrk Oct 24, 2025
6cff32c
std.Io.Threaded: implement netRead for Windows
andrewrk Oct 26, 2025
fd7475c
std.Io.Threaded: implement netWrite for Windows
andrewrk Oct 26, 2025
f6c5525
std.Io.Threaded: fix compilation on pthreads linux
andrewrk Oct 27, 2025
f9de83c
std.Io.net: skip testing netInterfaceNameResolve on Windows
andrewrk Oct 27, 2025
441d0c4
std.Io.net.HostName: fix missing group cancel
andrewrk Oct 27, 2025
6ccb53b
std.Io.Threaded: fix openSelfExe for Windows
andrewrk Oct 27, 2025
0211936
wasm linking: handle unreachable call_indirect
andrewrk Oct 27, 2025
df4c30c
link: move the windows kernel bug workaround to Io implementation
andrewrk Oct 27, 2025
0caf286
std.Io.Threaded: don't skip executing canceled group closures
andrewrk Oct 27, 2025
a87fd37
std.Io: make Evented equal void when unimplemented
andrewrk Oct 27, 2025
4e95c2e
std.Io.Threaded: implement futexes for freebsd
andrewrk Oct 27, 2025
bbc1c07
std.zig.system: fix error set of abiAndDynamicLinkerFromFile
andrewrk Oct 27, 2025
ef55dca
start: fix logic for signal hanlding when SIG.POLL does not exist
andrewrk Oct 27, 2025
cc751c0
std.Io.Threaded: correct clockToPosix for FreeBSD
andrewrk Oct 27, 2025
8b269f7
std: make signal numbers into an enum
andrewrk Oct 27, 2025
80a341b
std: remove awareness of POLL signal
andrewrk Oct 27, 2025
3de1b6c
std.Io.Threaded: better clock lowering for BSDs
andrewrk Oct 27, 2025
c8739d6
std.Io.Group: fix leak when wait is canceled
andrewrk Oct 27, 2025
cc4931b
std.Io.Threaded: fix 32-bit overflow in lookupDns
andrewrk Oct 28, 2025
6b8972d
resinator: update for Io API
andrewrk Oct 28, 2025
135ec79
std.Io.File: fix stat for Windows
andrewrk Oct 28, 2025
030ddc7
update standalone tests for ws2_32 dependency
andrewrk Oct 28, 2025
30448d9
std.Io.Threaded: fix netLookup for Windows
andrewrk Oct 28, 2025
a28d305
std.Io.Threaded: implement ResetEvent in terms of pthreads
andrewrk Oct 28, 2025
c0c2010
std.c: fix msghdr struct on big endian targets
andrewrk Oct 28, 2025
94b9874
std.Io.Threaded: stub out netbsd mutex and condition
andrewrk Oct 28, 2025
f5870b2
std.Io.Threaded: fix typo in panic message
andrewrk Oct 28, 2025
4114392
std: fix definition of ws2_32.GetAddrInfoExW
andrewrk Oct 28, 2025
b39f3d2
std.Io.Threaded: implement dirMakeOpenPath for WASI
andrewrk Oct 28, 2025
c4dc7d7
std.Io.Threaded: implement Unix sockets for Windows
andrewrk Oct 28, 2025
030b630
std.Io.Threaded: fix EBADF error code on wasm32-wasi -lc when reading
andrewrk Oct 28, 2025
1553c8e
std.os.linux.x86: fix signal restore function
andrewrk Oct 28, 2025
6f64c8b
std.debug.SelfInfo.Windows: less invasive change
andrewrk Oct 28, 2025
9f98641
CI: link ws2_32.lib on Windows
andrewrk Oct 28, 2025
6c794ce
std.Io.Threaded.dirOpenFileWtf16: SHARING_VIOLATION
andrewrk Oct 28, 2025
03fd132
std.Io: fix Group.wait unsoundness
andrewrk Oct 28, 2025
c40204a
std.Io: add unit tests for Group and concurrent
andrewrk Oct 29, 2025
a45cafb
std.Io: add unit test for select
andrewrk Oct 29, 2025
1c0a8b8
std.hash_map: tune slow unit tests
andrewrk Oct 29, 2025
b863f25
std.Io.Threaded: handle -fsingle-threaded in unit tests
andrewrk Oct 29, 2025
05b2840
std.Io.Threaded: install and cleanup signal handlers
andrewrk Oct 29, 2025
b1d270d
std.os.linux.s390x: fix restore function
andrewrk Oct 29, 2025
e8e1e27
std.Io: make select unit test not depend on cancellation
andrewrk Oct 29, 2025
0205ce4
std.os.linux.IoUring: disable failing test
andrewrk Oct 29, 2025
16185f6
std.http: disable failing test on 32-bit arm
andrewrk Oct 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ set(ZIG_STAGE2_SOURCES
lib/std/Thread/Futex.zig
lib/std/Thread/Mutex.zig
lib/std/Thread/Pool.zig
lib/std/Thread/ResetEvent.zig
lib/std/Thread/WaitGroup.zig
lib/std/array_hash_map.zig
lib/std/array_list.zig
Expand Down
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,15 @@ This produces a `zig2` executable in the current working directory. This is a
[without LLVM extensions](https://github.com/ziglang/zig/issues/16270), and is
therefore lacking these features:
- Release mode optimizations
- [aarch64 machine code backend](https://github.com/ziglang/zig/issues/21172)
- [@cImport](https://github.com/ziglang/zig/issues/20630)
- [zig translate-c](https://github.com/ziglang/zig/issues/20875)
- [Ability to compile assembly files](https://github.com/ziglang/zig/issues/21169)
- [Some ELF linking features](https://github.com/ziglang/zig/issues/17749)
- [Most COFF/PE linking features](https://github.com/ziglang/zig/issues/17751)
- [Some COFF/PE linking features](https://github.com/ziglang/zig/issues/17751)
- [Some WebAssembly linking features](https://github.com/ziglang/zig/issues/17750)
- [Ability to create import libs from def files](https://github.com/ziglang/zig/issues/17807)
- [Ability to create static archives from object files](https://github.com/ziglang/zig/issues/9828)
- [Ability to compile assembly files](https://github.com/ziglang/zig/issues/21169)
- Ability to compile C, C++, Objective-C, and Objective-C++ files

However, a compiler built this way does provide a C backend, which may be
useful for creating system packages of Zig projects using the system C
toolchain. **In this case, LLVM is not needed!**

Furthermore, a compiler built this way provides an LLVM backend that produces
bitcode files, which may be compiled into object files via a system Clang
Even when built this way, Zig provides an LLVM backend that produces bitcode
files, which may be optimized and compiled into object files via a system Clang
package. This can be used to produce system packages of Zig applications
without the Zig package dependency on LLVM.

Expand Down
2 changes: 1 addition & 1 deletion ci/x86_64-windows-debug.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Enter-VsDevShell -VsInstallPath "C:\Program Files (x86)\Microsoft Visual Studio\
CheckLastExitCode

Write-Output "Build and run behavior tests with msvc..."
& cl.exe -I..\lib test-x86_64-windows-msvc.c compiler_rt-x86_64-windows-msvc.c /W3 /Z7 -link -nologo -debug -subsystem:console kernel32.lib ntdll.lib libcmt.lib
& cl.exe -I..\lib test-x86_64-windows-msvc.c compiler_rt-x86_64-windows-msvc.c /W3 /Z7 -link -nologo -debug -subsystem:console kernel32.lib ntdll.lib libcmt.lib ws2_32.lib
CheckLastExitCode

& .\test-x86_64-windows-msvc.exe
Expand Down
2 changes: 1 addition & 1 deletion ci/x86_64-windows-release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Enter-VsDevShell -VsInstallPath "C:\Program Files (x86)\Microsoft Visual Studio\
CheckLastExitCode

Write-Output "Build and run behavior tests with msvc..."
& cl.exe -I..\lib test-x86_64-windows-msvc.c compiler_rt-x86_64-windows-msvc.c /W3 /Z7 -link -nologo -debug -subsystem:console kernel32.lib ntdll.lib libcmt.lib
& cl.exe -I..\lib test-x86_64-windows-msvc.c compiler_rt-x86_64-windows-msvc.c /W3 /Z7 -link -nologo -debug -subsystem:console kernel32.lib ntdll.lib libcmt.lib ws2_32.lib
CheckLastExitCode

& .\test-x86_64-windows-msvc.exe
Expand Down
60 changes: 32 additions & 28 deletions lib/compiler/aro/aro/Compilation.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const std = @import("std");
const Io = std.Io;
const assert = std.debug.assert;
const EpochSeconds = std.time.epoch.EpochSeconds;
const mem = std.mem;
Expand Down Expand Up @@ -113,7 +114,7 @@ pub const Environment = struct {
if (parsed > max_timestamp) return error.InvalidEpoch;
return .{ .provided = parsed };
} else {
const timestamp = std.math.cast(u64, std.time.timestamp()) orelse return error.InvalidEpoch;
const timestamp = std.math.cast(u64, 0) orelse return error.InvalidEpoch;
return .{ .system = std.math.clamp(timestamp, 0, max_timestamp) };
}
}
Expand All @@ -124,6 +125,7 @@ const Compilation = @This();
gpa: Allocator,
/// Allocations in this arena live all the way until `Compilation.deinit`.
arena: Allocator,
io: Io,
diagnostics: *Diagnostics,

code_gen_options: CodeGenOptions = .default,
Expand Down Expand Up @@ -157,21 +159,23 @@ type_store: TypeStore = .{},
ms_cwd_source_id: ?Source.Id = null,
cwd: std.fs.Dir,

pub fn init(gpa: Allocator, arena: Allocator, diagnostics: *Diagnostics, cwd: std.fs.Dir) Compilation {
pub fn init(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics, cwd: std.fs.Dir) Compilation {
return .{
.gpa = gpa,
.arena = arena,
.io = io,
.diagnostics = diagnostics,
.cwd = cwd,
};
}

/// Initialize Compilation with default environment,
/// pragma handlers and emulation mode set to target.
pub fn initDefault(gpa: Allocator, arena: Allocator, diagnostics: *Diagnostics, cwd: std.fs.Dir) !Compilation {
pub fn initDefault(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics, cwd: std.fs.Dir) !Compilation {
var comp: Compilation = .{
.gpa = gpa,
.arena = arena,
.io = io,
.diagnostics = diagnostics,
.environment = try Environment.loadAll(gpa),
.cwd = cwd,
Expand Down Expand Up @@ -222,14 +226,14 @@ pub const SystemDefinesMode = enum {
include_system_defines,
};

fn generateSystemDefines(comp: *Compilation, w: *std.Io.Writer) !void {
fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void {
const define = struct {
fn define(_w: *std.Io.Writer, name: []const u8) !void {
fn define(_w: *Io.Writer, name: []const u8) !void {
try _w.print("#define {s} 1\n", .{name});
}
}.define;
const defineStd = struct {
fn defineStd(_w: *std.Io.Writer, name: []const u8, is_gnu: bool) !void {
fn defineStd(_w: *Io.Writer, name: []const u8, is_gnu: bool) !void {
if (is_gnu) {
try _w.print("#define {s} 1\n", .{name});
}
Expand Down Expand Up @@ -957,7 +961,7 @@ fn generateSystemDefines(comp: *Compilation, w: *std.Io.Writer) !void {
pub fn generateBuiltinMacros(comp: *Compilation, system_defines_mode: SystemDefinesMode) AddSourceError!Source {
try comp.type_store.initNamedTypes(comp);

var allocating: std.Io.Writer.Allocating = try .initCapacity(comp.gpa, 2 << 13);
var allocating: Io.Writer.Allocating = try .initCapacity(comp.gpa, 2 << 13);
defer allocating.deinit();

comp.writeBuiltinMacros(system_defines_mode, &allocating.writer) catch |err| switch (err) {
Expand All @@ -971,7 +975,7 @@ pub fn generateBuiltinMacros(comp: *Compilation, system_defines_mode: SystemDefi
return comp.addSourceFromOwnedBuffer("<builtin>", contents, .user);
}

fn writeBuiltinMacros(comp: *Compilation, system_defines_mode: SystemDefinesMode, w: *std.Io.Writer) !void {
fn writeBuiltinMacros(comp: *Compilation, system_defines_mode: SystemDefinesMode, w: *Io.Writer) !void {
if (system_defines_mode == .include_system_defines) {
try w.writeAll(
\\#define __VERSION__ "Aro
Expand Down Expand Up @@ -1026,7 +1030,7 @@ fn writeBuiltinMacros(comp: *Compilation, system_defines_mode: SystemDefinesMode
}
}

fn generateFloatMacros(w: *std.Io.Writer, prefix: []const u8, semantics: target_util.FPSemantics, ext: []const u8) !void {
fn generateFloatMacros(w: *Io.Writer, prefix: []const u8, semantics: target_util.FPSemantics, ext: []const u8) !void {
const denormMin = semantics.chooseValue(
[]const u8,
.{
Expand Down Expand Up @@ -1101,7 +1105,7 @@ fn generateFloatMacros(w: *std.Io.Writer, prefix: []const u8, semantics: target_
try w.print("#define __{s}_MIN__ {s}{s}\n", .{ prefix, min, ext });
}

fn generateTypeMacro(comp: *const Compilation, w: *std.Io.Writer, name: []const u8, qt: QualType) !void {
fn generateTypeMacro(comp: *const Compilation, w: *Io.Writer, name: []const u8, qt: QualType) !void {
try w.print("#define {s} ", .{name});
try qt.print(comp, w);
try w.writeByte('\n');
Expand Down Expand Up @@ -1136,7 +1140,7 @@ fn generateFastOrLeastType(
bits: usize,
kind: enum { least, fast },
signedness: std.builtin.Signedness,
w: *std.Io.Writer,
w: *Io.Writer,
) !void {
const ty = comp.intLeastN(bits, signedness); // defining the fast types as the least types is permitted

Expand Down Expand Up @@ -1166,7 +1170,7 @@ fn generateFastOrLeastType(
try comp.generateFmt(prefix, w, ty);
}

fn generateFastAndLeastWidthTypes(comp: *Compilation, w: *std.Io.Writer) !void {
fn generateFastAndLeastWidthTypes(comp: *Compilation, w: *Io.Writer) !void {
const sizes = [_]usize{ 8, 16, 32, 64 };
for (sizes) |size| {
try comp.generateFastOrLeastType(size, .least, .signed, w);
Expand All @@ -1176,7 +1180,7 @@ fn generateFastAndLeastWidthTypes(comp: *Compilation, w: *std.Io.Writer) !void {
}
}

fn generateExactWidthTypes(comp: *Compilation, w: *std.Io.Writer) !void {
fn generateExactWidthTypes(comp: *Compilation, w: *Io.Writer) !void {
try comp.generateExactWidthType(w, .schar);

if (QualType.short.sizeof(comp) > QualType.char.sizeof(comp)) {
Expand Down Expand Up @@ -1224,7 +1228,7 @@ fn generateExactWidthTypes(comp: *Compilation, w: *std.Io.Writer) !void {
}
}

fn generateFmt(comp: *const Compilation, prefix: []const u8, w: *std.Io.Writer, qt: QualType) !void {
fn generateFmt(comp: *const Compilation, prefix: []const u8, w: *Io.Writer, qt: QualType) !void {
const unsigned = qt.signedness(comp) == .unsigned;
const modifier = qt.formatModifier(comp);
const formats = if (unsigned) "ouxX" else "di";
Expand All @@ -1233,15 +1237,15 @@ fn generateFmt(comp: *const Compilation, prefix: []const u8, w: *std.Io.Writer,
}
}

fn generateSuffixMacro(comp: *const Compilation, prefix: []const u8, w: *std.Io.Writer, qt: QualType) !void {
fn generateSuffixMacro(comp: *const Compilation, prefix: []const u8, w: *Io.Writer, qt: QualType) !void {
return w.print("#define {s}_C_SUFFIX__ {s}\n", .{ prefix, qt.intValueSuffix(comp) });
}

/// Generate the following for a type:
/// Name macro (e.g. #define __UINT32_TYPE__ unsigned int)
/// Format strings (e.g. #define __UINT32_FMTu__ "u")
/// Suffix macro (e.g. #define __UINT32_C_SUFFIX__ U)
fn generateExactWidthType(comp: *Compilation, w: *std.Io.Writer, original_qt: QualType) !void {
fn generateExactWidthType(comp: *Compilation, w: *Io.Writer, original_qt: QualType) !void {
var qt = original_qt;
const width = qt.sizeof(comp) * 8;
const unsigned = qt.signedness(comp) == .unsigned;
Expand Down Expand Up @@ -1274,7 +1278,7 @@ pub fn hasHalfPrecisionFloatABI(comp: *const Compilation) bool {
return comp.langopts.allow_half_args_and_returns or target_util.hasHalfPrecisionFloatABI(comp.target);
}

fn generateIntMax(comp: *const Compilation, w: *std.Io.Writer, name: []const u8, qt: QualType) !void {
fn generateIntMax(comp: *const Compilation, w: *Io.Writer, name: []const u8, qt: QualType) !void {
const unsigned = qt.signedness(comp) == .unsigned;
const max: u128 = switch (qt.bitSizeof(comp)) {
8 => if (unsigned) std.math.maxInt(u8) else std.math.maxInt(i8),
Expand All @@ -1298,7 +1302,7 @@ pub fn wcharMax(comp: *const Compilation) u32 {
};
}

fn generateExactWidthIntMax(comp: *Compilation, w: *std.Io.Writer, original_qt: QualType) !void {
fn generateExactWidthIntMax(comp: *Compilation, w: *Io.Writer, original_qt: QualType) !void {
var qt = original_qt;
const bit_count: u8 = @intCast(qt.sizeof(comp) * 8);
const unsigned = qt.signedness(comp) == .unsigned;
Expand All @@ -1315,16 +1319,16 @@ fn generateExactWidthIntMax(comp: *Compilation, w: *std.Io.Writer, original_qt:
return comp.generateIntMax(w, name, qt);
}

fn generateIntWidth(comp: *Compilation, w: *std.Io.Writer, name: []const u8, qt: QualType) !void {
fn generateIntWidth(comp: *Compilation, w: *Io.Writer, name: []const u8, qt: QualType) !void {
try w.print("#define __{s}_WIDTH__ {d}\n", .{ name, qt.sizeof(comp) * 8 });
}

fn generateIntMaxAndWidth(comp: *Compilation, w: *std.Io.Writer, name: []const u8, qt: QualType) !void {
fn generateIntMaxAndWidth(comp: *Compilation, w: *Io.Writer, name: []const u8, qt: QualType) !void {
try comp.generateIntMax(w, name, qt);
try comp.generateIntWidth(w, name, qt);
}

fn generateSizeofType(comp: *Compilation, w: *std.Io.Writer, name: []const u8, qt: QualType) !void {
fn generateSizeofType(comp: *Compilation, w: *Io.Writer, name: []const u8, qt: QualType) !void {
try w.print("#define {s} {d}\n", .{ name, qt.sizeof(comp) });
}

Expand Down Expand Up @@ -1805,7 +1809,7 @@ pub const IncludeType = enum {
angle_brackets,
};

fn getPathContents(comp: *Compilation, path: []const u8, limit: std.Io.Limit) ![]u8 {
fn getPathContents(comp: *Compilation, path: []const u8, limit: Io.Limit) ![]u8 {
if (mem.indexOfScalar(u8, path, 0) != null) {
return error.FileNotFound;
}
Expand All @@ -1815,11 +1819,12 @@ fn getPathContents(comp: *Compilation, path: []const u8, limit: std.Io.Limit) ![
return comp.getFileContents(file, limit);
}

fn getFileContents(comp: *Compilation, file: std.fs.File, limit: std.Io.Limit) ![]u8 {
fn getFileContents(comp: *Compilation, file: std.fs.File, limit: Io.Limit) ![]u8 {
const io = comp.io;
var file_buf: [4096]u8 = undefined;
var file_reader = file.reader(&file_buf);
var file_reader = file.reader(io, &file_buf);

var allocating: std.Io.Writer.Allocating = .init(comp.gpa);
var allocating: Io.Writer.Allocating = .init(comp.gpa);
defer allocating.deinit();
if (file_reader.getSize()) |size| {
const limited_size = limit.minInt64(size);
Expand All @@ -1846,7 +1851,7 @@ pub fn findEmbed(
includer_token_source: Source.Id,
/// angle bracket vs quotes
include_type: IncludeType,
limit: std.Io.Limit,
limit: Io.Limit,
opt_dep_file: ?*DepFile,
) !?[]u8 {
if (std.fs.path.isAbsolute(filename)) {
Expand Down Expand Up @@ -2010,8 +2015,7 @@ pub fn locSlice(comp: *const Compilation, loc: Source.Location) []const u8 {
pub fn getSourceMTimeUncached(comp: *const Compilation, source_id: Source.Id) ?u64 {
const source = comp.getSource(source_id);
if (comp.cwd.statFile(source.path)) |stat| {
const mtime = @divTrunc(stat.mtime, std.time.ns_per_s);
return std.math.cast(u64, mtime);
return std.math.cast(u64, stat.mtime.toSeconds());
} else |_| {
return null;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/compiler/aro/aro/Driver.zig
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ pub fn parseArgs(
macro_buf: *std.ArrayList(u8),
args: []const []const u8,
) (Compilation.Error || std.Io.Writer.Error)!bool {
const io = d.comp.io;
var i: usize = 1;
var comment_arg: []const u8 = "";
var hosted: ?bool = null;
Expand Down Expand Up @@ -772,7 +773,7 @@ pub fn parseArgs(
opts.arch_os_abi, @errorName(e),
}),
};
d.comp.target = std.zig.system.resolveTargetQuery(query) catch |e| {
d.comp.target = std.zig.system.resolveTargetQuery(io, query) catch |e| {
return d.fatal("unable to resolve target: {s}", .{errorDescription(e)});
};
}
Expand Down Expand Up @@ -916,8 +917,7 @@ pub fn errorDescription(e: anyerror) []const u8 {
error.NotDir => "is not a directory",
error.NotOpenForReading => "file is not open for reading",
error.NotOpenForWriting => "file is not open for writing",
error.InvalidUtf8 => "path is not valid UTF-8",
error.InvalidWtf8 => "path is not valid WTF-8",
error.BadPathName => "bad path name",
error.FileBusy => "file is busy",
error.NameTooLong => "file name is too long",
error.AccessDenied => "access denied",
Expand Down
Loading
Loading