6121 Commits

Author SHA1 Message Date
Jakub Konka
ddd2cd7330 zld: fix Dylib.Id parsing logic for string values 2021-06-24 23:34:31 +02:00
Jakub Konka
264f5f4544 Apply AST fixes 2021-06-24 23:08:24 +02:00
Jakub Konka
8fc5b5a087 zld: put DICE and CodeSig load commands last
after `LC_LOAD_DYLIB` commands to match ld64 and make the binaries
compatible with Apple tools.
2021-06-24 22:40:19 +02:00
Jakub Konka
ad0be78577 zld: parse dylib's id from tbd 2021-06-24 22:19:44 +02:00
Jakub Konka
5e0e7b2cb4 zld: exclude libs part of the umbrella
when parsing the umbrella lib
2021-06-24 20:27:23 +02:00
Jakub Konka
8669e3d46b zld: when parsing dylibs, allow multiple return values 2021-06-24 18:57:21 +02:00
Jakub Konka
5ac5cd9de7 zld: naively parse all dylib deps in stubs 2021-06-24 18:57:11 +02:00
Jakub Konka
3cb6b6bd90 zld: merge Stub with Dylib struct
After giving it more thought, it doesn't make sense to separate
the two structurally. Instead, there should be two constructors
for a Dylib struct: one from binary file, and the other from a stub
file. This cleans up a lot of code and opens the way for recursive
parsing of re-exports from a dylib which are a hard requirement for
native feel when linking frameworks.
2021-06-24 18:57:04 +02:00
Jakub Konka
3f57468c8b Classify .m as ObjC, compile using clang and link with zld 2021-06-24 18:56:56 +02:00
Jakub Konka
52a9d3f037 zld: clean up memory management and refactor 2021-06-24 18:56:48 +02:00
Jakub Konka
1ff3ebffa3 zld: handle dynamic binding of proxies for objc correctly 2021-06-24 18:56:41 +02:00
Jakub Konka
0736365fa4 zld: fix finding pointers for rebasing 2021-06-24 18:56:33 +02:00
Jakub Konka
d1fcb99848 zld+macho: populate segname from SegmentCommand when adding section 2021-06-24 18:56:17 +02:00
Jakub Konka
a480ae6e37 zld: handle objc-specific sections 2021-06-24 18:56:09 +02:00
Jakub Konka
5f9b4cba6d zld: clean up logic for matching and mapping sections 2021-06-24 18:55:43 +02:00
Jakub Konka
852e1ed23c zld+stage2: refactor creating segments and sections
Move the logic into default-init structs part of constructors in
`SegmentCommand` struct in `commands.zig` module.
2021-06-24 18:53:42 +02:00
Jakub Konka
72f2f68938 zld: parse framework dirs and names 2021-06-24 18:53:28 +02:00
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