6104 Commits

Author SHA1 Message Date
Jakub Konka
cea8a2f500 tapi: apply ast fixes 2021-06-24 15:01:14 +02:00
Jakub Konka
b55a3cefa4 zld: extract path to libc in the linker proper 2021-06-24 14:45:45 +02:00
Jakub Konka
bc78b02c04 zld: introduce Stub.zig which represents parsed stub file
Instead of trying to fit a stub file into the frame of a Dylib struct,
I think it makes more sense to keep them as separate entities with
possibly shared interface (which would be added in the future).

This cleaned up a lot of logic in Dylib as well as Stub. Also, while
here I've made creating actual *Symbols lazy in the sense Dylib and
Stub only store hash maps of symbol names that they expose but we
defer create and referencing given dylib/stub until link time when
a symbol is actually referenced. This should reduce memory usage
and speed things up a bit.
2021-06-24 14:45:45 +02:00
Jakub Konka
09b46198ff zld: move logic unpacking path to libc stub to Compilation 2021-06-24 14:45:45 +02:00
Jakub Konka
a600d41880 zld: apply AST fixes 2021-06-24 14:45:45 +02:00
Jakub Konka
4854c96bc5 zld: create a synthetic ___dso_handle symbol self-referenced 2021-06-24 14:45:45 +02:00
Jakub Konka
96a0479db2 zld: parse lib stubs as tbds on the linker line 2021-06-24 14:45:45 +02:00
Jakub Konka
089577a71d zld: parse libSystem tbd stub when linking 2021-06-24 14:45:45 +02:00
Jakub Konka
fbdc515418 link: add basic TAPI parser for linkers
Parser uses kubkon/zig-yaml gitrev c3eae1e40a02aedd44ad1171e5c8b259896cbda0
2021-06-24 14:45:45 +02:00
Evan Haas
29314b64bd translate-c: ensure scoped (non-public) enum constants are used 2021-06-23 14:51:19 -04:00
Evan Haas
de9306096e translate-c: remove explicit comptime from shuffle mask expression 2021-06-23 11:01:46 -07:00
Evan Haas
8a5fb4c248 translate-c: Ensure all local variables and function params are used 2021-06-23 10:47:47 -07:00
Andrew Kelley
2beb21c4e4 stage2: fix crash when using stage1 backend
Calling processOutdatedAndDeletedDecls() should not happen when using
the stage1 backend. Problem solved with checking a simple flag.
2021-06-23 10:44:46 -07:00
Jacob G-W
960932a4bf astgen: error on struct field with no type 2021-06-23 10:44:46 -07:00
Andrew Kelley
af40e3f54c stage2: glue code to AstGen root source file when using stage1
Normally we rely on importing std to in turn import the root
in the start code, but when using the stage1 won't happen,
so in order to run AstGen on the root we put it into the
import_table here.
2021-06-23 10:44:46 -07:00
Andrew Kelley
150515f44d stage2: slightly improve error reporting for missing imports
There is now a distinction between `@import` with a .zig extension and
without. Without a .zig extension it assumes it is a package name, and
returns error.PackageNotFound if not mapped into the package table.
2021-06-23 10:44:46 -07:00
Andrew Kelley
6fb45807ab progress bar: call it "AST Lowering" instead of "AstGen" 2021-06-23 10:44:46 -07:00
Andrew Kelley
cf65ab8601 run AstGen even when using the stage1 backend
This change reduces the amount of divergence in the compiler's main
pipeline logic enough to run AstGen for all files in the compilation,
regardless of whether the stage1 or stage2 backend is being used.

Practically, this means that all Zig code is subject to new compile
errors, such as unused local variables.

Additionally:
 * remove leftover unsound asserts from recent hash map changes
 * fix sub-Compilation errors not indenting correctly
2021-06-23 10:44:46 -07:00
Andrew Kelley
fc185a6f71 stage1: @shuffle type and mask params in comptime scope 2021-06-23 09:52:09 -07:00
Evan Haas
0e7897a9a2 translate-c: Remove usage of extern enum
Translate enum types as the underlying integer type. Translate enum constants
as top-level integer constants of the correct type (which does not necessarily
match the enum integer type).

If an enum constant's type cannot be translated for some reason, omit it.

See discussion https://github.com/ziglang/zig/issues/2115#issuecomment-827968279

Fixes #9153
2021-06-23 08:44:25 +03:00
Andrew Kelley
7bebb24838 fix unused locals from merge conflict 2021-06-21 17:09:22 -07:00
Andrew Kelley
d3ddb48075 AstGen: remove unused parameters 2021-06-21 17:03:04 -07:00
Andrew Kelley
06412e04f9 cleanups related to unused params 2021-06-21 17:03:04 -07:00
Andrew Kelley
af9a2c7c50 Sema: don't miscompile fns with inferred error sets 2021-06-21 17:03:04 -07:00
Andrew Kelley
fee5aad699 stage2: remove unused parameter from importPkg 2021-06-21 17:03:04 -07:00
Andrew Kelley
f203334878 stage2: wire up AstGen to the progress bar 2021-06-21 17:03:03 -07:00
Andrew Kelley
a51ff3a903 AstGen: remove unused scope parameter from rvalue 2021-06-21 17:03:03 -07:00
Andrew Kelley
b9b0e53197 AstGen: remove unused parameter 2021-06-21 17:03:03 -07:00
Andrew Kelley
7a595f2e6c remove unused parameters 2021-06-21 17:03:03 -07:00
Andrew Kelley
a04a98ff3e AstGen: while loop continue expr captures in scope
Before this, the continue expression of a while loop did not have the
capture variable in it, making it incorrectly emit a compile error for
not using the capture, even if it was referenced.
2021-06-21 17:03:03 -07:00
Andrew Kelley
4f900e68d3 AstGen: fix crash in debug printing ZIR field types
The printing code did not properly set the parent Decl node field, so
the source location calculations were wrong.

closes #8825
2021-06-21 17:03:03 -07:00
Andrew Kelley
f4a9e0530a AstGen: convert a TODO comment to an issue
See #363
2021-06-21 17:03:03 -07:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Jacob G-W
b83b3883ba stage2 AstGen: fix lots of bugs and catch more errors
Gotta catch 'em all!

also simplify identifier( logic
2021-06-21 17:03:03 -07:00
Jacob G-W
641ecc260f std, src, doc, test: remove unused variables 2021-06-21 17:03:03 -07:00
Jacob G-W
d34a1ccb0e stage2: fix TODO in @export to look for runtime-vars
Also rename LocalPtr.is_comptime to LocalPtr.maybe_comptime as
it is a better name, as it could be runtime, but is not
always runtime.
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
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
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
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
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
Michael Dusan
e006281d79 macho: LC_RPATH: reserve byte for null-terminator 2021-06-18 15:22:10 +02: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