14444 Commits

Author SHA1 Message Date
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
8216ce6789
Merge pull request #9171 from ziglang/zld-tapi
zld: add TAPI parser for linkers, ship libSystem.B.tbd with Zig, and parse tbd stubs on macOS
2021-06-24 18:41:33 +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
Andrew Kelley
31c49ad64d
Merge pull request #9191 from ziglang/stage1-astcheck
run AstGen even when using the stage1 backend
2021-06-23 18:09:19 -04:00
Evan Haas
29314b64bd translate-c: ensure scoped (non-public) enum constants are used 2021-06-23 14:51:19 -04:00
Andrew Kelley
3259532080 langref: fix unused vars 2021-06-23 11:32:28 -07: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
84fe5d4681 fix unused variable errors in runtime safety test cases 2021-06-23 10:44:46 -07:00
Andrew Kelley
3a4a710894 update godbolt test case for unused parameter 2021-06-23 10:44:46 -07:00
Andrew Kelley
189fc964f7 fix unused parameters in compare_output test cases 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
c3f637a54c cmake: debug builds of zig enable logging by default
when logging is enabled, the --debug-log flag is available.
2021-06-23 10:44:46 -07:00
Andrew Kelley
96ebf9396f ci: no need for --ast-check
since zig will now run AstGen even when using the stage1 backend.
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
Jonathan Marler
0134cb0214 nice error for unsupported async sockets on Windows 2021-06-23 12:54:20 +03:00
Veikka Tuominen
29945fb8b3 fix typos in langref.html
I thought I built the docs locally but apparently not.
2021-06-23 09:20:39 +03:00
Roman Frołow
ce3679aa45
Docs clarification: local static variable (#8381) 2021-06-23 08:45:36 +03:00
Jacob G-W
da063ebd96 docs: top level global assembly -> container level 2021-06-23 08:44:52 +03: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
Luna
d1f99eabb7 add compile error if root.log is not a function 2021-06-22 16:38:18 +03:00
Andrew Kelley
c6844072ce
Merge pull request #9047 from g-w1/spider-astgen
stage2 astgen: catch unused vars
2021-06-21 20:20:48 -04: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
d279a23c93 mips: fix syscall_pipe
Previously the fd parameter was ignored and so the result would not get
populated. Now it passes the fd pointer to the inline assembly so that
the results can be observed.
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