14376 Commits

Author SHA1 Message Date
Jacob G-W
18c1007a34 stage2 tests: remove unused vars 2021-06-21 17:03:03 -07:00
Jacob G-W
f8b8f50b63 stage2 astgen: make asm outputs count as referencing vars
This is temporary and putting this as a seperate commit
so that it can easily be reverted as andrewrk suggested.
2021-06-21 17:03:03 -07:00
Jacob G-W
796b420092 std.enums: make code correct zig and not stage1 2021-06-21 17:03:02 -07:00
Jacob G-W
7d4c8d7054 stage2: make loop vars be comptime if they are inline
thanks @Vexu
2021-06-21 17:03:02 -07:00
Jacob G-W
2092481265 stage2 astgen: fix bug in struct init where type not refed 2021-06-21 17:03:02 -07:00
Jacob G-W
75f7a8913e stage2 astgen: find unused vars 2021-06-21 17:03:02 -07:00
Veikka Tuominen
8a6de78e07
Merge pull request #8717 from mchudleigh/dwarf-on-windows
Dwarf on windows
2021-06-21 18:48:59 +03:00
g-w1
e13a182990
stage2 Sema: implement @intToPtr (#9144)
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2021-06-21 18:47:34 +03:00
Jacob G-W
a95fdb0635 stage2: simplify codegen for errorToInt and intToError
We can just use bitcast instead of error_to_int, int_to_error since
errorToInt and intToError do not actually do anything, just change types.
This allows us to remove 2 air ops that were the exact same as bitcast
2021-06-21 18:45:28 +03:00
Andrew Kelley
fc1feebdc0
Merge pull request #9168 from LemonBoy/fix-pie
std: Fix PIE startup sequence
2021-06-20 20:01:39 -04:00
Dmitry Matveyev
00982f75e9
stage2: Remove special double ampersand parsing case (#9114)
* Remove parser error on double ampersand

* Add failing test for double ampersand case

* Add error when encountering double ampersand in AstGen

"Bit and" operator should not make sense when one of its operands
is an address.

* Check that 2 ampersands are adjacent to each other in source string

* Remove cases of unused variables in tests
2021-06-20 21:04:14 +03:00
LemonBoy
e4225ca5f7 std: Make copy_file_range checks run at compile-time
* Avoid emitting the copy_file_range symbol at all to prevent link-time
  errors.
* Fix a bug in the check logic, the has_copy_file_range_syscall was
  set to the wrong value in case of ENOSYS
* If link_libc is true don't fall-back to the raw syscall approach,
  there's no policy about what to do in this case but let's follow what
  the other impls do.

Fixes #9146
2021-06-20 20:58:10 +03:00
Veikka Tuominen
6de45c826c
Merge pull request #8636 from jmc-88/issue-3779
Change builtins to return a string literal
2021-06-20 20:27:34 +03:00
Jacob G-W
1071ca6129 fmt: make --ast-check work with --stdin 2021-06-20 19:56:14 +03:00
pithlessly
8a7730672f stage2 sema: change impl of @setCold to use zirSetCold (typo?) 2021-06-20 19:50:06 +03:00
mason1920
37a1028b6e Bring your own MAX_PATH_BYTES
Previous to #7082, users could overwrite PATH_MAX in the root file to support std.os.toPosixPath, permitting the "bring your own operating system" layer to implement the POSIX API for opening files. Unfortunately that is no longer the case.

This commit intends to fix what is arguably a regression from 0.7 in a way that doesn't break any code targeting 0.8.0, making it suitable to be included in a 0.8 patch release.
However in a future release that permits breaking changes, I am of the opinion that it would be beneficial to overwrite the value, even for "supported" operating systems. Same for all the other POSIX/BYOOS functions and values. However this is beyond the scope of this commit. Further discussion of this will be made into an issue in due time.
2021-06-20 19:49:48 +03:00
LemonBoy
aa6422d792 tests: Update line numbers 2021-06-19 20:07:07 +02:00
LemonBoy
fd6d5f1609 std: Fix PIE startup sequence
* Don't skip the TLS initialization (Fixes #9083)
* Add a test case where a PIE program is built and run
* Refactor the common initialization code in the Linux startup
  sequence.
2021-06-19 18:02:51 +02:00
Matt Chudleigh
24b1a0027f Fix crash when compiling with cygwin/msys on windows 2021-06-18 16:19:20 -07:00
Matt Chudleigh
a6c2e44ae7 Add support for reading DWARF debug information from COFF files 2021-06-18 16:19:20 -07:00
Matt Chudleigh
2dcdaa7668 Support long section names in COFF files 2021-06-18 16:19:20 -07:00
Matt Chudleigh
fac0c6f25d Convert remaining addresses to u64 from usize in dwarf.zig 2021-06-18 16:19:20 -07:00
Michael Dusan
e006281d79 macho: LC_RPATH: reserve byte for null-terminator 2021-06-18 15:22:10 +02:00
hadroncfy
1f29b75f08
HashMap.getOrPutAssumeCapacityAdapted should set key to undefined (#9138)
* std.hash_map.HashMap: getOrPutAssumeCapacityAdapted should set key to undefined

* add test for std.hash_map.HashMap.getOrPutAdapted
2021-06-18 08:52:30 +03:00
Andrew Kelley
6ce8440987 AstGen: properly generate errdefer expressions when returning
`return` statements use a new function `nodeMayEvalToError` which does
some basic checks on the AST node to return never, always, or maybe.

Depending on this result, AstGen skips the errdefers, always includes
the errdefers, or emits a conditional branch to check whether the return
value is an error that Sema will have to evaluate.

Closes #8821
Unblocks #9047
2021-06-17 22:44:17 -07:00
LemonBoy
ccb6e1627e stage1: Store the specified code model in the LLVM module
This is needed for LTO builds to pick up the correct module.

Closes #9132
2021-06-18 08:29:23 +03:00
Andrew Kelley
b9e78593bb
Merge pull request #9117 from greenfork/unify-compiler-error-printing
stage2: Unify compiler error printing
2021-06-17 23:25:05 -04:00
Michael Dusan
9ff15e24f8 fix oob during riscv64 feature processing 2021-06-17 23:15:47 -04:00
Vincent Rischmann
6f0cfdb820 zig cc: improve linker args parsing
Handle linker args joined with a = like -Wl,-rpath=foo

Update existing args --major-os-version, --minor-os-version,
--major-subsystem-version and --minor-subsytem-version to work with the
new parsing.

Also handle -Wl,--script in addition to -Wl,-T
2021-06-17 17:32:17 -04:00
Andrew Kelley
e18ef71d98 stage1: fix zig0 help message
closes #9140
2021-06-17 13:39:30 -07:00
d18g
0e71e6ee0f
Fix lakemont CpuModel (#9099)
Lakemont has no x86, no MMX, no SSE and no way of handling any fp-math. In theory LLVM is able to implicitly use the soft-float emulation library calls to legalize any such operation but, given Zig's use of many non-standard features, sometimes we hit a weak spot in the X86 codegen backend.

Consider this as a work-around for this LLVM problem, fixing the problem in LLVM is not so high in my todo list as the target is pretty niche and Intel axed it in '19.

(Commit message by @LemonBoy)
2021-06-17 16:37:38 -04:00
Daniele Cocca
9e88356282 embedFile: change notation from [X:0] to [N:0]
This is for consistency with the documentation on sentinel-terminated
{arrays,slices,pointers} which already use `N` for a comptime-inferred
size rather than `X`.

Also adds a behavioral test to assert that a string literal is returned.
2021-06-16 22:03:02 +01:00
Daniele Cocca
9be2f76741 typeName: amend return type to string literal
This was already the case, but the documentation failed to point out
that the returned value is of type `*const [N:0]u8`, i.e. that of a
string literal.

Also adds a behavioral test to assert that this is the case.
2021-06-16 22:03:02 +01:00
Daniele Cocca
171102ea7c errorName: return a null-terminated slice 2021-06-16 22:02:52 +01:00
Daniele Cocca
00e1c0082c tagName: return a null-terminated slice 2021-06-16 22:02:42 +01:00
Daniele Cocca
1184b1d560 Add create_sentineled_str_lit 2021-06-16 21:56:39 +01:00
Daniele Cocca
2242d3c3aa {create,init}_const_slice: accept custom sentinel 2021-06-16 21:56:39 +01:00
Michael Dusan
bfe3558efe netbsd: add more std.os.bits 2021-06-16 14:46:25 -04:00
Michael Dusan
79a4da14ad netbsd: add args to limit number of PT_LOAD segs
NetBSD expects 2 PT_LOAD segments in a shared object, otherwise
ld.elf_so fails to load, emitting a general "not found" error.

Workaround issue by adding args `--no-rosegment` and `-znorelro`.

see #9109
2021-06-16 14:46:25 -04:00
Andrew Kelley
e125ead2b1 ci: remove confusing message now that --ast-check is added
This extra message was intended to help contributors by clarifying
what to do when they hit a `zig fmt` failure, but now AST errors are
also emitted here and the message may actually introduce confusion.

Remove it for now.
2021-06-15 14:27:56 -07:00
joachimschmidt557
76584ad0c6 stage2 Sema: add type resolving from comptime_float to float 2021-06-15 17:14:09 -04:00
Andrew Kelley
90c73d8768 fix RISC-V assembly CPU features
Previously, Zig did not properly communicate the target CPU features for
RISC-V to clang assembler, because Clang has a different way to pass CPU
features for C code and for assembly code. This commit makes Zig pass a
RISC-V -march flag in order to communicate CPU features to Clang when
compiling assembly files.
2021-06-15 17:12:22 -04:00
Andrew Kelley
515d6430c0 AstGen: support @export with field access
The Zig language specification will support identifiers and field access
in order to refer to which declaration to export with `@export`.

This commit implements the change in AstGen and updates the language
reference.
2021-06-15 14:08:57 -07:00
Jakub Konka
0f4173c5d8
Merge pull request #9122 from ziglang/zld-proxies
zld: clean up stubs resolution, error messages and use ld64 defaults for system libs resolution
2021-06-15 14:55:12 +02:00
Jakub Konka
7f9076c771 Merge branch 'mathetake-cpp-wasi' 2021-06-15 12:20:44 +02:00
Isaac Freund
fb0ecdbe1a zig build: add --libc general option
This new option sets a default libc paths file to be used for all
LibExeObjSteps. Setting LibExeObjStep.libc_file overrides this default.

This is required to allow users to cross compile projects linking system
libraries without needing to patch the build.zig.
2021-06-15 12:14:04 +02:00
Veikka Tuominen
d892d3bbe7 replace usage of meta.cast with builtins
You weren't supposed to use these >:(
2021-06-15 12:14:04 +02:00
Veikka Tuominen
c54af9774d translate-c: move utility functions to a separate namespace 2021-06-15 12:14:04 +02:00
Björn Linse
1fe6a34f69 std: don't reference non-existant ComptimeStringHashMap type 2021-06-15 12:14:04 +02:00
Jakub Konka
6362b82497 zld: map coalesced sections and handle undefines 2021-06-15 12:14:04 +02:00