Andrew Kelley
5b2a79848c
stage2: cleanups regarding red zone CLI flags
...
* CLI: change to -mred-zone and -mno-red-zone to match gcc/clang.
* build.zig: remove the double negative and make it an optional bool.
This follows precedent from other flags, allowing the compiler CLI to
be the decider of what is default instead of duplicating the default
value into the build system code.
* Compilation: make it an optional `want_red_zone` instead of a
`no_red_zone` bool. The default is decided by a call to
`target_util.hasRedZone`.
* When creating a Clang command line, put -mred-zone on the command
line if we are forcing it to be enabled.
* Update update_clang_options.zig with respect to the recent {s}/{} format changes.
* `zig cc` integration with red zone preference.
2021-01-11 22:07:21 -07:00
Lee Cannon
8932c2d745
Added support for no red zone
2021-01-11 22:07:14 -07:00
Andrew Kelley
56c03881eb
Merge branch 'rohlem-fix-GetFinalPathNameByHandle-before-win10_rs4'
...
Merges #7379
2021-01-11 17:48:33 -07:00
Rohlem
c96272f618
std.os.windows.GetFinalPathNameByHandle: remove intermediate buffers
...
... and mem.copy operations. Requires slightly larger input buffers than result length. Add helper functions std.mem.alignInBytes and std.mem.alignInSlice.
2021-01-11 17:48:19 -07:00
Rohlem
f301a8467c
std.os.windows.GetFinalPathNameByHandle: remove QueryInformationFile code path
2021-01-11 17:48:18 -07:00
Rohlem
cb20503990
std.os.windows.GetFinalPathNameByHandle: address non-structural review comments
2021-01-11 17:48:18 -07:00
Rohlem
64c5f4979e
std.os.windows.GetFinalPathNameByHandle: replace kernel32 by ntdll call
...
Removes the call to kernel32.GetFinalPathNameByHandleW in favor of NtQueryObject, which means we can reuse the other codepath's logic for DOS naming.
2021-01-11 17:48:18 -07:00
Rohlem
964bbcd0b1
introduce std.os.windows.QueryObjectName
2021-01-11 17:48:18 -07:00
Rohlem
09dc651476
std.os.windows.GetFinalPathNameByHandle: add test
2021-01-11 17:48:18 -07:00
Rohlem
450e467201
std.os.windows.GetFinalPathNameByHandle: reintroduce kernel32 for compatibility
...
The NtQueryInformationFile with .FileNormalizedNameInformation is only available in Windows 10 1803 (rs4) and later, however there is probably still another route we can go via ntdll.
2021-01-11 17:48:18 -07:00
Rohlem
4b280ac7e9
add std.zig.system.windows version check utility functions
2021-01-11 17:48:17 -07:00
Rohlem
2922a48309
move windows runtime version detection into std.zig.system.windows
2021-01-11 17:48:16 -07:00
Jonathan Knezek
fc10c9c4ce
Add std.fmt.formatDuration and std.fmt.duration ( #7297 )
...
`formatDuration` works on a writer, and `duration` wraps a u64 to allow pleasant injection into format strings.
2021-01-11 19:15:56 -05:00
Andrew Kelley
025f1559a0
Merge pull request #7200 from Vexu/arr
...
Type coercion for pointers to anon literals
2021-01-11 16:09:28 -08:00
Andrew Kelley
4f5fa90d6d
Merge pull request #7195 from Aransentin/master
...
A win32-api proposal, implemented for user32.zig
2021-01-11 16:02:40 -08:00
Andrew Kelley
483c057a77
Merge branch 'clean up writeFileAllUnseekable by using readers'
...
closes #7156
2021-01-11 16:52:29 -07:00
Andrew Kelley
d68adc5382
std.EarlyEOFReader: rename to LimitedReader
2021-01-11 16:51:56 -07:00
daurnimator
01d1a8a783
std: use fifo.pump in writeFileAllUnseekable
2021-01-11 16:48:56 -07:00
daurnimator
e873668d38
std: add LimitedReader: reader that returns EOF early
2021-01-11 16:48:30 -07:00
daurnimator
8695b9fbe7
std: use reader.skipBytes to avoid infinite loop in writeFileAllUnseekable
...
skipBytes correctly handles EOF for us
2021-01-11 16:47:48 -07:00
daurnimator
0ab8ae944c
std: reader.skipBytes's num_bytes should be a u64
2021-01-11 16:47:48 -07:00
Vincent Rischmann
3468872d83
os/bits/linux: add the termios cc bits
2021-01-11 15:39:36 -08:00
Andrew Kelley
ec9158305d
Merge pull request #7124 from LemonBoy/netstuff1
...
std: Decouple network streams from fs.File
2021-01-11 15:35:00 -08:00
Andrew Kelley
29c9d5896c
Merge branch 'Stage2 begin implementing container types'
2021-01-11 16:25:21 -07:00
Andrew Kelley
5cc2e500e6
Merge branch 'SpexGuy-fix-comptime-cityhash'
...
I commented out the comptime test though since it was causing OOM on the
CI server.
closes #7331
2021-01-11 13:58:31 -07:00
Andrew Kelley
0c8e2c987d
std CityHash: disable memory-expensive tests for now
2021-01-11 13:58:06 -07:00
Martin Wickham
21213127ec
Modify cityhash to work at comptime
2021-01-11 13:52:52 -07:00
Andrew Kelley
73b17474d7
Merge pull request #7134 from alexnask/fix_std_fs_watch
...
The std.fs.Watch rewrite PR
2021-01-11 12:45:36 -08:00
LemonBoy
34720da3d0
Apparently unix sockets are supported on Windows
...
Starting from Windows 10 build 17063.
2021-01-11 21:43:15 +01:00
LemonBoy
d0beb4badb
Let the kernel pick a random port
...
Avoid errors if the socket enters the TIME_WAIT state and we need to
re-execute this test before the OS releases it.
This problem was not really a problem before since the accept()-ed
socket was never closed on the server-side.
2021-01-11 21:43:14 +01:00
LemonBoy
676d7fc63c
std: Add a small test for i/o on unix sockets
2021-01-11 21:43:13 +01:00
LemonBoy
89d6317b93
std: Decouple network streams from fs.File
...
The overlap between files and sockets is minimal and lumping them
together means supporting only a small subset of the functionalities
provided by the OS.
Moreover the socket and file handles are not always interchangeable: on
Windows one should use Winsock's close() call rather than the one used
for common files.
2021-01-11 21:43:09 +01:00
Travis
cc2981edfc
update path.join to recognize any separators that isSep does
2021-01-11 11:15:34 -08:00
Andrew Kelley
1295525a7a
Merge branch 'AdamGoertz-master'
...
closes #5080
closes #6887
2021-01-10 19:04:22 -07:00
Andrew Kelley
169810b20f
zig fmt
2021-01-10 19:04:10 -07:00
Adam Goertz
0f32de77c9
impl lossyCast #5080
2021-01-10 19:02:41 -07:00
Timon Kruiper
e1d8073d2f
stage2: add support for loops in LLVM backend
...
A simple `while(true) {}` loop generates the following LLVMIR:
```
define i32 @main() {
Entry:
br label %Loop
Loop: ; preds = %Loop, %Entry
br label %Loop
}
```
Also implement TZIR printing for loops and add a corresponding test.
2021-01-10 17:47:34 -08:00
Vincent Rischmann
2117489e05
debug: don't fail printLineInfo if the source file is not readable
...
Without this dumping a stacktrace fails with this:
Unable to dump stack trace: AccessDenied
2021-01-10 17:46:15 -08:00
joachimschmidt557
a7da90071e
stage2: fix bug in genArg
...
When an argument is unused in the function body, still increment
arg_index so we still select the correct arguments in the args slice.
2021-01-10 00:41:02 -08:00
Andrew Kelley
29928af600
Merge pull request #7729 from jayschwa/remove-deprecated-stream
...
Remove deprecated stream aliases
2021-01-09 13:04:08 -08:00
Jay Petacat
a0ad2dee6a
builtin: Add zig_version
...
This will enable code to perform version checks and make it easier to
support multiple versions of Zig.
Within the SemVer implementation, an intermediate value needed to be
coerced to a slice to workaround a comptime bug.
Closes #6466
2021-01-09 12:50:39 -08:00
Andrew Kelley
5c49a137d5
Merge pull request #7725 from FireFox317/even-more-llvm
...
stage2: initial implementation of control flow in LLVM backend + TZIR printing
2021-01-09 12:32:10 -08:00
xackus
e4b8148e9c
Fix system library path detection on linux
...
Uses the NativeTargetInfo results instead of std.Target.current.
2021-01-08 20:07:59 -07:00
LemonBoy
eb696e453f
stage2: Implicitly enable --eh_frame_hdr when compiling c/c++ files
...
Matches what Clang/GCC driver do.
Closes #7711
2021-01-08 19:01:05 -08:00
Sobeston
95e66a915b
added mem.containsAtLeast
2021-01-08 18:12:30 -08:00
Jakub Konka
7e0e27e738
libstd: add missing MachO rebase opcodes in macho.zig
2021-01-08 23:41:51 +01:00
Jay Petacat
e72472d953
io: FindByteOutStream to FindByteWriter
...
See #4917
2021-01-08 16:54:56 -05:00
Jay Petacat
1595ce273e
Remove deprecated stream aliases
2021-01-08 16:54:56 -05:00
Timon Kruiper
56c059077c
stage2: add initial impl of control flow in LLVM backend
...
The following TZIR instrutions have been implemented in the backend:
- all cmp operators (lt, lte, gt, gte, eq, neq)
- block
- br
- condbr
The following LLVMIR is generated for a simple assert function:
```
define void @assert(i1 %0) {
Entry:
%1 = alloca i1, align 1
store i1 %0, i1* %1, align 1
%2 = load i1, i1* %1, align 1
%3 = xor i1 %2, true
br i1 %3, label %Then, label %Else
Then: ; preds = %Entry
call void @llvm.debugtrap()
unreachable
Else: ; preds = %Entry
br label %Block
Block: ; preds = %Else
ret void
}
```
See tests for more examples.
2021-01-08 19:30:52 +01:00
Timon Kruiper
3715ed7b54
stage2: implement TZIR printing for block and condbr
...
Zig code:
```
fn assert(ok: bool) void {
if (!ok) unreachable;
}
```
TZIR:
```
Module.Function(name=assert):
@0: void = {};
%0: bool = arg(ok)
%1: void = dbg_stmt()
%2: void = block(
%3: bool = not(%0)
%4: noreturn = condbr(%3,
then:
%5: void = breakpoint()
%6: noreturn = unreach()
else:
%7: noreturn = br(%2, @0)
)
)
%8: noreturn = retvoid()
```
2021-01-08 12:13:27 +01:00