Jakub Konka
600348283f
macho: include __StaticInit input sections as GC roots
2022-07-22 21:19:33 +02:00
Jakub Konka
f8458a549b
macho: dead_strip defaults: off for debug, on for release
2022-07-22 16:58:21 +02:00
Jakub Konka
0901e4805c
macho: fix zig cc and c++ using stage2 llvm
2022-07-22 16:58:21 +02:00
Jakub Konka
ca74656685
macho: move GC code into dead_strip.zig module
...
Implement marking live atoms that reference other live atoms if
required by the compiler (via section attribute).
2022-07-22 16:58:21 +02:00
Jakub Konka
7345976261
macho: sort subsection symbols by seniority
2022-07-22 16:58:21 +02:00
Jakub Konka
39df241df4
macho: do not GC local symbols unless reference dead symbols
...
If a local references another local, we keep it. If it doesn't
reference anything, we keep it. Otherwise, we dead strip it.
2022-07-22 16:58:21 +02:00
Jakub Konka
a089a6dc4f
macho: parse data-in-code when writing LINKEDIT segment
2022-07-22 16:58:21 +02:00
Jakub Konka
2dfc78dc03
macho: limit export info to entrypoint and mh symbol when executable
2022-07-22 16:58:21 +02:00
Jakub Konka
0f1b5d45bc
macho: mark __mh_execute_header as ref'd dynamically
2022-07-22 16:58:21 +02:00
Jakub Konka
0da8ba816a
macho: do not store stabs; generate on-the-fly instead
2022-07-22 16:58:21 +02:00
Jakub Konka
41b91442f4
macho: improve logs for dyld info
2022-07-22 16:58:21 +02:00
Jakub Konka
4658d857de
macho: fix caching linker line in incremental setting
2022-07-22 16:58:20 +02:00
Jakub Konka
b380ed6a72
macho: deallocate globals keys
2022-07-22 16:58:20 +02:00
Jakub Konka
817939d20a
macho: don't store GC roots globally
...
Instead, if dead-strip was requested, create a temp container and
pass it around.
2022-07-22 16:58:20 +02:00
Jakub Konka
61b4119a7d
macho: link atom starting section by orig section id
...
In x86_64 relocs, it can so happen that the compiler
refers to the same atom by both the actual assigned symbol
and the start of the section. In this case, we need to
link the two together so add an alias.
2022-07-22 16:58:20 +02:00
Jakub Konka
35a5a4a0e4
macho: fix marking sections for pruning in GC
2022-07-22 16:58:20 +02:00
Jakub Konka
d80fcc8a0b
macho: rework symbol handling for incremental stage2 builds
2022-07-22 16:58:20 +02:00
Jakub Konka
eeb6d8f045
macho: fix compilation issues on 32bit hosts
2022-07-22 16:58:20 +02:00
Jakub Konka
9eb7e5182b
macho: rework symbol handling to match zld/ELF
...
Now, each object file will store a mutable table of symbols that it
defines. Upon symbol resolution between object files, the symbol
will be updated with a globally allocated section ordinal and address
in virtual memory. If the object defines a globally available symbol,
its location only (comprising of the symbol index and object index)
will be stored in the globals map for easy access when relocating, etc.
This approach cleans up the symbol management significantly, and matches
the status quo used in zld/ELF.
Additionally, this makes scoping symbol stabs easier too as they are
now naturally contained within each object file.
2022-07-22 16:58:20 +02:00
Jakub Konka
843701d0fe
macho: remove unused fields from Atom
2022-07-22 16:58:20 +02:00
Jakub Konka
03feea0fb2
macho: split section into subsections if requested and/or possible
2022-07-22 16:58:20 +02:00
Jakub Konka
d042b88c11
macho: put parsing into an atom into a helper
2022-07-22 16:58:20 +02:00
Jakub Konka
b81c48d985
macho: read the entire file contents into memory at once
2022-07-22 16:58:20 +02:00
Jakub Konka
7ec9a4f382
cli: support --gc-sections and --no-gc-sections for Zig sources
2022-07-22 16:58:20 +02:00
Jakub Konka
44ee42c6bc
cli: parse -dead_strip MachO linker flag
2022-07-22 16:58:20 +02:00
Andrew Kelley
25f3be32db
Sema: fix fn pointer align disagrees with fn align error
...
Check the specified function alignment rather than the effective
function alignment.
2022-07-21 15:19:56 -07:00
Andrew Kelley
fc6e111b76
Sema: improve compile error for bad function alignment
...
* Integrate more declaratively with src/target.zig
* Only trigger the check when a function body is found, do not trigger
for function types.
2022-07-21 13:55:29 -07:00
Veikka Tuominen
794beafb9c
Sema: validate extern struct field types earlier
...
`validateExternType` does not require the type to be resolved so we can
check it earlier. Only doing it in `resolveTypeFully` lead to worse or
missing compile errors.
2022-07-21 12:21:30 -07:00
Veikka Tuominen
821e4063f9
Sema: better source location for function call args
2022-07-21 12:21:30 -07:00
Veikka Tuominen
79ef0cdf30
Sema: better function parameter source location
2022-07-21 12:21:30 -07:00
Veikka Tuominen
83b2d2cd3e
Sema: better source location for incompatible capture group
2022-07-21 12:21:30 -07:00
Veikka Tuominen
9fb8d21a01
AstGen: add error for fields in opaque types
2022-07-21 12:21:30 -07:00
Veikka Tuominen
1705a21f80
Sema: more union and enum tag type validation
2022-07-21 12:21:30 -07:00
Veikka Tuominen
8feb398760
Sema: validate function parameter types and return type
2022-07-21 12:21:30 -07:00
Veikka Tuominen
d851b24180
Sema: validate function pointer alignment
2022-07-21 12:21:30 -07:00
Veikka Tuominen
76e7959a90
Sema: explain why comptime is needed
2022-07-21 12:21:30 -07:00
Veikka Tuominen
d729173204
stage2: better pointer source location
2022-07-21 12:21:30 -07:00
Veikka Tuominen
29815fe9de
Sema: disallow 'align' on functions on wasm
2022-07-21 12:21:30 -07:00
Veikka Tuominen
62120e3d0e
Sema: fix non-exhaustive union switch checks
2022-07-21 12:21:30 -07:00
Veikka Tuominen
d41dd499a9
stage2 llvm: fix handling of pointer fields in packed structs
2022-07-20 17:07:12 +03:00
Andrew Kelley
0efc6a35be
Sema: fix enum value without tag name used as switch item
...
Previously stage2 would report a false positive compile error saying there
was no tag for this value.
2022-07-19 18:39:48 -07:00
Andrew Kelley
1d5f865cfa
Sema: fix runtime instructions omitted
...
in the presence of comptime control flow.
fixes #12171
2022-07-19 17:45:38 -07:00
Andrew Kelley
fe8c3ffeb1
LLVM: change commentary on isByRef
...
This branch originally started out as a potential workaround to
address #11450 . It did not solve that problem, however, it did end
up fixing #11498 !
2022-07-19 11:31:37 -07:00
Andrew Kelley
74fb65fb42
LLVM: lower all error unions as byref=true
...
Same reasoning as previous commit.
2022-07-19 11:26:19 -07:00
Andrew Kelley
bab570a225
LLVM: lower all structs as byref=true
...
Same reasoning as previous commit.
2022-07-19 11:26:18 -07:00
Andrew Kelley
65bc4d915d
LLVM: lower optional types as byref=true
...
This is a possible workaround for
https://github.com/llvm/llvm-project/issues/56585
On my computer it makes stage3-release go from false positive
compilation errors on the behavior tests to "segmentation fault".
Is this forwards progress or backwards progress? I have no idea.
See #11450
2022-07-19 11:22:48 -07:00
Cody Tapscott
b93a38860d
stage2: Change optional non-null field to i8
...
This is a workaround for https://github.com/llvm/llvm-project/issues/56585
which causes writes to i1 in memory to be optimized to an incorrect value.
Unfortunately, this does not save users from running into this bug with u1
in their own types.
However, this does seem to be enough to get the behavior tests working.
This resolves #11450 on my machine.
2022-07-19 13:33:41 -04:00
Andrew Kelley
a39c51c6a4
Sema: fix UAF in coerceInMemoryAllowed
2022-07-16 13:48:12 -07:00
Veikka Tuominen
b2486fbc5e
Merge pull request #12121 from Vexu/span
...
Stage2 point to error location using spans
2022-07-16 12:22:53 +03:00
Veikka Tuominen
da94227f78
Merge pull request #12060 from Vexu/IterableDir
...
std.fs: split `Dir` into `IterableDir`
2022-07-16 12:18:21 +03:00