Commit Graph

16438 Commits

Author SHA1 Message Date
John Schmidt
c992164dc7 Check for isDarwin() instead of linked libc 2022-01-14 13:44:38 +01:00
John Schmidt
66fe5bb0d8 Use libc if_nametoindex if available when parsing IPs
Fixes https://github.com/ziglang/zig/issues/10521 and makes a couple of
additional tests pass when linking libc.
2022-01-12 19:32:46 +01:00
riverbl
c4681b4889 translate-c: Fix macro define of float constant using scientific notation
Fixes compiler attempting to use null value when translating macro define of float constant using scientific notation with no decimal point
2022-01-12 13:25:50 -05:00
Jimmi Holst Christensen
a5ac138ae2 Allow BoundArray to be default initialized 2022-01-12 13:17:01 -05:00
Jimmi Holst Christensen
349a7cc272 Make prominent_compile_errors also work for test steps 2022-01-12 00:13:30 -05:00
Andrew Kelley
1a7c47d966
Merge pull request #10572 from Luukdegram/wasm-linker-stack
Stage2: wasm-linker - Place stack at the beginning of the linear memory
2022-01-11 19:41:18 -05:00
Luuk de Gram
975049e96e
wasm-ld: Append --stack-first by default
By placing the stack at the start of the memory section, we prevent the runtime
from silently overwriting the global declarations and instead trap.

We do however, allow users to overwrite this behavior by setting the global-base,
which puts the stack at the end of the memory section and the static data at the base that was specified.
The reason a user would want to do this, is when they are sure the stack will not overflow and they want
to decrease the binary size as the offsets to the static memory are generally smaller.
(Having the stack in front, means that accessing the memory after the stack has a bigger offset when loading/storing from memory).
2022-01-11 20:35:44 +01:00
Luuk de Gram
f767f8e3dc
wasm: Place the stack at the start of memory 2022-01-11 20:21:22 +01:00
afranchuk
7c4c49ff07
Fix a bug in std.Thread.Condition and add a basic Condition test. (#10538)
* Fix FUTEX usage in std.Thread.Condition - It was using an old name.
2022-01-11 13:04:24 -05:00
Andrew Kelley
64363b10f5
Merge pull request #10566 from fifty-six/master
std.os.uefi improvements/fixes
2022-01-11 13:02:28 -05:00
Andrew Kelley
3d89ff5130 std.fs.path: revert recent public API change
41fd343508 made a breaking change to the
public API; this commit reverts the API changes but keeps the
improved logic.
2022-01-11 11:00:19 -07:00
fifty-six
b65a884169 std/os/uefi: Add pool_allocator and raw_pool_allocator 2022-01-11 10:49:40 -07:00
fifty-six
c78a108d10 std/os/uefi: Add create_file_device_path
This allows users to add file paths to device paths, which is often used
in methods like `boot_services.loadImage` and `boot_services.startImage`,
which take a device path with an additional file path appended to locate
the image.
2022-01-11 10:49:40 -07:00
fifty-six
73e4571b4c std/os/uefi: Add methods next() and size() to DevicePathProtocol
These are used for more easily dealing with a series of Device Path
nodes.
2022-01-11 10:49:40 -07:00
fifty-six
608fceffc4 std/os/uefi: Add FileSystemInfo 2022-01-11 10:49:40 -07:00
fifty-six
b6e1613e58 std/os/uefi: Move FileInfo guid from FileProtocol to FileInfo
The GUID on FileProtocol was for EFI_FILE_INFO, FileProtocol itself doesn't
have a GUID, there are only those for the requested information types.
2022-01-11 10:49:40 -07:00
fifty-six
41fd343508 std: fix path joining on UEFI
UEFI uses `\` for paths exclusively. This changes std.fs.path to use `\`
for UEFI path joining. Also adds a few tests regarding it, specifically
in making sure double-separators do not result from path joining, as the
UEFI spec says to convert any that result from joining into single
separators (UEFI Spec Version 2.7, pg. 448).
2022-01-11 10:49:40 -07:00
Evan Haas
f4b3f1d602 translate-c: Handle typedef'ed void return type for functions.
Fixes #10356
2022-01-11 12:42:23 -05:00
Jakub Konka
6d9c02a54f
zig cc: integration with sysroot arg (#10568)
Prior to this change, even if the use specified the sysroot on the
compiler line like so

```
zig cc --sysroot=/path/to/sdk
```

it would only be used as a prefix to include paths and not as a prefix
for `zig ld` linker.
2022-01-11 12:41:26 -05:00
Jakub Konka
48731ccea9 Merge branch 'Luukdegram-linker-eport-symbols' 2022-01-11 13:34:43 +01:00
Jakub Konka
014e55e761 dupe sym name from stage1 before passing to stage2 2022-01-11 13:33:53 +01:00
Jakub Konka
a615425b51 Merge branch 'linker-eport-symbols' of github.com:Luukdegram/zig into Luukdegram-linker-eport-symbols 2022-01-11 11:30:53 +01:00
djg
4731a6e5d5
std: hash_map: optimize isFree/isTombstone (#10562)
- Add an `Metadata.isFree` helper method.
- Implement `Metadata.isTombstone` and `Metadata.isFree` with `@bitCast` then comparing to a constant. I assume `@bitCast`-then-compare is faster than the old method because it only involves one comparison, and doesn't require bitmasking.
- Summary of benchmarked changes (`gotta-go-fast`, run locally, compared to master):
  - 3/4 of the hash map benchmarks used ~10% fewer cycles
  - The last one (project Euler) shows 4% fewer cycles.
2022-01-10 23:54:45 -05:00
Jakub Konka
ada8e17137
Merge pull request #10565 from Luukdegram/wasm-cast
Stage2: wasm - Implement optional equality, casts and more
2022-01-10 23:43:06 +01:00
Jakub Konka
97c6d4fb3e Build fs/filesystem libcxx module when targeting GNU Win 2022-01-10 23:40:15 +01:00
Luuk de Gram
bf46aee878
wasm: Basic 128bit integer support
This implements storing, loading and comparing 128bit integers.
TODO: Make all >64 bit integers make a call to compiler-rt for binary operations.
2022-01-10 21:03:37 +01:00
Luuk de Gram
6a9ddf244a
wasm: Implement optional compare
We now pass all optionals.zig behavior tests
2022-01-10 21:01:12 +01:00
Luuk de Gram
e7b7088056
wasm: Implement float_to_int
- This implements the float_to_int AIR instruction.
- Lowering a decl_ref to a slice was previously assumed to contain a pointer
to a slice, rather than an array. This is now fixed, making `@src()` work as well.
- Some preliminary work on 128bit integers have been done to find out what needs to be done
to implement 128bit arithmetic.
2022-01-10 21:01:00 +01:00
Jakub Konka
a4e6291fbd
stage2: enable zig test on x86_64-macos (#10551)
* stage2: put decls in different MachO sections

Use `getDeclVAddrWithReloc` when targeting MachO backend rather than
`getDeclVAddr` - this fn returns a zero vaddr and instead creates a
relocation on the linker side which will get automatically updated
whenever the target decl is moved in memory. This fn also records
a rebase of the target pointer so that its value is correctly slid
in presence of ASLR.

This commit enables `zig test` on x86_64-macos.

* stage2: fix output section selection for type,val pairs
2022-01-10 16:02:07 +01:00
Andrew Kelley
42ef95d79d
Merge pull request #10554 from joachimschmidt557/stage2-arm
stage2 ARM: refactor and pass 1 more behavior test file
2022-01-10 01:48:49 -05:00
joachimschmidt557
b5f03b3b7a
stage2 codegen: fix airBlock bug in 3 backends 2022-01-09 19:09:57 +01:00
joachimschmidt557
a1526f069a
stage2 ARM: pass behavior/bool.zig 2022-01-09 19:03:45 +01:00
joachimschmidt557
77ca77cf14
stage2 ARM: make Mir.Inst.cond = .al default 2022-01-09 14:16:29 +01:00
Jakub Konka
d66c97d0ef
Merge pull request #10525 from g-w1/plan9-zig-test
Plan9 zig test
2022-01-09 13:27:56 +01:00
Luuk de Gram
2a39d8063d wasm: Implement arrays 2022-01-08 19:56:07 -05:00
Andrew Kelley
7651913fd2
Merge pull request #10542 from Hejsil/stage2-bit-offset-of
Stage2 bitOffsetOf and offsetOf builtin functions
2022-01-08 15:48:14 -05:00
Robin Voetter
cc5c25d48b stage2: implement @src 2022-01-08 14:32:40 -05:00
Robin Voetter
4931b8dc93 stage2: @errorName sema+llvm 2022-01-08 14:30:11 -05:00
Jimmi Holst Christensen
5cbb35abd0 Implement bitOffsetOf
This also refactors getting struct field offsets into two
iterators. This will be useful when implementing bitCast at comptime on
structs.
2022-01-08 14:01:28 +01:00
Jimmi Holst Christensen
d8d5e2d4b9 Implement offsetOf builtin function 2022-01-08 13:00:49 +01:00
Meghan Denny
3f586781b6 std: fix zig.Ast being called Tree internally 2022-01-08 01:01:09 -05:00
Andrew Kelley
c4ab8d9e12
Merge pull request #10532 from Hejsil/stage2-bit-shifting-passing
Stage2 bit_shifting.zig passing
2022-01-08 01:00:59 -05:00
Lee Cannon
1cdc51ec10 handle error.PathAlreadyExists in renameTmpIntoCache 2022-01-07 16:50:37 -05:00
Jimmi Holst Christensen
3871d5e55a bit_shifting.zig now passes stage2 llvm backend 2022-01-07 22:10:36 +01:00
Jimmi Holst Christensen
f48f687c05 Fix llvmFieldIndex for zero sized fields
It is possible for Zig to emit field ptr instructions to fields whos
type is zero sized. In this case llvm should return a pointer which
points to the next none zero sized parameter.
2022-01-07 22:10:36 +01:00
Jimmi Holst Christensen
f78d3b27ca Increment runtime_param_index for zero sized parameters
`runtime_param_index` is used to get the parameter type from `fn_type`,
but this variable was not incremented for zero sized parameters, causing
two zero sized parameters of different type to cause miss complication.
2022-01-07 22:10:36 +01:00
Jimmi Holst Christensen
9d6bef49a5 Add two more resolution status' to Struct and Union
resolveTypeForCodegen is called when we needed to resolve a type fully,
even through pointer. This commit fully implements this, even through
pointer fields on structs and unions.

The function has now also been renamed to resolveTypeFully
2022-01-07 22:10:36 +01:00
Jimmi Holst Christensen
d5093b6c13 Shift right is a noop if rhs is comptime known to be zero 2022-01-07 22:10:36 +01:00
r00ster
dd076d8cba Add missing package to the langref that's always available 2022-01-07 14:18:47 -05:00
Jimmi Holst Christensen
a68e6cd3d7 Return Value.zero when the result of shr requires zero bits 2022-01-07 19:50:00 +01:00