404 Commits

Author SHA1 Message Date
Andrew Kelley
1e5e664555
Merge pull request #8773 from ziglang/macho-dsym-path
macho: put dSYM bundle in zig-cache
2021-05-15 01:25:37 -04:00
Jakub Konka
e93254412b macho: if strip is true, do not generate dSYM 2021-05-14 22:27:26 +02:00
Robin Voetter
d45e7dfc24 SPIR-V: Begin generating types 2021-05-14 19:49:32 +02:00
Jakub Konka
af9c6f2c69 macho: put dSYM bundle in zig-cache
Originally, I thought that the dSYM bundle has to reside side-by-side
with the binary it carries the debugging information for. However, it
turns out macOS is clever enough that it auto-searches for matching
dSYM bundle based on the embedded UUID of the binary.

To verify this, run this on your macOS:

```
mdfind "com_apple_xcode_dsym_uuids == <UUID from LC_UUID>"
```

See [here] for more info.

[here]: https://developer.apple.com/documentation/xcode/adding-identifiable-symbol-names-to-a-crash-report
2021-05-14 13:09:40 +02:00
Jakub Konka
00ebbe6df2 macho: require _main as global export in self-hosted
Clean up type and description flags generation for exports
in self-hosted MachO backend.
2021-05-14 13:08:56 +02:00
Jakub Konka
8eea5eddf7 macho: fix bug with symbol growth and realloc 2021-05-14 11:02:43 +02:00
Andrew Kelley
826179bff4 stage2: -lunwind is handled specially
* `-lc++` now implies `-lc`.
 * `-lunwind` is now pulled out into a separate `link_libunwind` flag in
   the frontend driver code. This allows a project to request zig to
   provide libunwind even if the default situation that causes it to be
   implicitly added, is not active.
 * build.zig: ask for -lunwind when building the self-hosted compiler on
   Linux. Otherwise we get linker errors with unresolved symbols to
   libunwind.
2021-05-13 22:42:57 -04:00
Andrew Kelley
76a259799d stage2: only build and link libunwind when linking libc++ 2021-05-13 17:40:39 -04:00
Andrew Kelley
4b59f56434 stage2: build and provide libunwind when compiling for native libc
5ac91794cce8bd53916a378815be01e4365d53d9 made Zig link against the
system libc when targeting the native C ABI. However this made it stop
putting libunwind.a on the linker line when it needed to sometimes,
causing undefined symbols when linking against C++ code.
2021-05-12 22:29:21 -07:00
Isaac Freund
459c9f0535 stage2: fix build on OpenBSD/NetBSD
Apparently these systems do not provide libdl or librt.
2021-05-13 00:44:56 -04:00
Jakub Konka
7b77246289 macho: allow overriding stack size in binary 2021-05-12 19:25:26 +02:00
Isaac Freund
3b2c9ef828
stage2: link all libc components if using system libc 2021-05-11 21:30:13 +02:00
LemonBoy
2bb8e1ff55 stage2: Change libc components' linking order
Use the same order as Clang (and, by extension, GCC) for the three most
important libc components: lm comes first, followed by lpthread and then
lc.
2021-05-11 12:43:58 +02:00
LemonBoy
b288f8c9a6 stage2: Always link -lpthread when using system libc
This is required when cross-compiling glibc targets.
2021-05-11 12:27:24 +02:00
Jakub Konka
f67e756211 zld: adjust signed displacement source target addr
Previously, I mistakenly assumed that offset of the relocation
is enough when calculating relative offset of the target from the
source target section base address in case of section-based relocs
on x86_64. While this is true for `__TEXT,__text` section which
always starts at 0x0 in object files, this is absolutely not true
for `__TEXT,__StaticInit` section which will have nonzero base
address hence resulting in incorrect displacement calculations for
SIGNED relocs.
2021-05-09 16:24:53 +02:00
Andrew Kelley
67154d233e
Merge pull request #8686 from Vexu/try
Allow tests to fail
2021-05-08 17:29:44 -04:00
Andrew Kelley
fed1c9c3ec link/MachO: fix --verbose-link ensureCapacity bug 2021-05-08 11:24:07 -07:00
Veikka Tuominen
42a95197f3 update usage of std.testing in stage2 2021-05-08 15:15:30 +03:00
Jakub Konka
88d40fc005 zld: sort tlv offsets by source address 2021-05-06 17:10:05 +02:00
Jakub Konka
ef8a666797 zld: cleanup relocs and flag errors on unhandled symbol types 2021-05-06 17:09:58 +02:00
Jakub Konka
96556ce8b8 zld: port over a few more bits from ld64
* UTF16 gets its own section, `__TEXT,__ustring`
* TLV data and bss sections have to aligned to the same max alignment
  according to Apple rdar comment in the latest ld64
2021-05-04 13:09:32 +02:00
Jakub Konka
1867c3c34c zld: disable most logs 2021-05-04 13:09:32 +02:00
Jakub Konka
9e11f27c41 zld: build updated macho backend 2021-05-04 13:09:32 +02:00
Jakub Konka
00c3d57a51 zld: rewrite symbol allocations 2021-05-04 13:09:32 +02:00
Jakub Konka
fcd57f0857 zld: resolve GOT loads and stubs 2021-05-04 13:09:32 +02:00
Jakub Konka
68ebc7cba0 zld: rewrite symbol resolution 2021-05-04 13:09:32 +02:00
Jakub Konka
86ab6ca56c zld: rewrite Object to include pointers to Symbols 2021-05-04 13:09:32 +02:00
Jakub Konka
4ec6d174ad zld: new approach at handling static inits 2021-04-24 08:13:53 +02:00
Jakub Konka
b00d08b667 zld: add temp debug info fix by setting mtime=0 2021-04-24 08:13:53 +02:00
Jakub Konka
b03983b450 zld: analyze static initializers 2021-04-24 08:13:53 +02:00
Jakub Konka
4f7765de7c zld: common section should be writable 2021-04-24 08:13:53 +02:00
Jakub Konka
d64c76e8f1 zld: fix parsing of weak symbols 2021-04-20 16:55:32 +02:00
Jakub Konka
7bc6554a58 zld: map __DATA,__common as __DATA_CONST,__common 2021-04-20 16:55:32 +02:00
Jakub Konka
e5b83056ae zld: resolve symbols as globals before resolving locals 2021-04-20 16:55:32 +02:00
Jakub Konka
8943a0aaaa zld: dedup initializers and finalizers 2021-04-20 16:55:32 +02:00
Jakub Konka
3e73a3c29b zld: treat priv extern as weak symbol 2021-04-20 16:55:32 +02:00
Jakub Konka
461543a5fd zld: fix symbol resolution from interdep archives
Fixes symbol resolution if an archive occurring later in the linker
line depends on a object embedded within the archive that occurred
before.
2021-04-13 13:36:08 +02:00
Jakub Konka
a5bbc66f10 zld: cleanup redundant changes 2021-04-13 10:56:03 +02:00
Jakub Konka
db30033de2 zld: rebase to new naming conv for aarch64 2021-04-13 10:56:03 +02:00
Jakub Konka
1119970d22 zld: add x86_64 relocs 2021-04-13 10:56:03 +02:00
Jakub Konka
b1f9db75f3 zld: save locals per TU 2021-04-13 10:56:03 +02:00
Jakub Konka
3b7c9dd6bd zld: differentiate between static and global in stabs 2021-04-13 10:56:03 +02:00
Jakub Konka
717d382871 zld: streamline tags for Symbol 2021-04-13 10:56:03 +02:00
Jakub Konka
b377e0b370 zld: fix indirect symtab 2021-04-13 10:56:03 +02:00
Jakub Konka
b0a4e1fa46 zld: fix rebase vs bind for GOT entries 2021-04-13 10:56:03 +02:00
Jakub Konka
6e3f82ef28 zld: fix parsing debug info 2021-04-13 10:56:03 +02:00
Jakub Konka
65c27d51f6 zld: limit exports to just main entrypoint 2021-04-13 10:56:03 +02:00
Jakub Konka
421102ba72 zld: move parsing debug info into object 2021-04-13 10:56:03 +02:00
Jakub Konka
dc7cff8ebc zld: add prelim support for locals 2021-04-13 10:56:03 +02:00
Jakub Konka
23bb6fa9f4 zld: flush MachO 2021-04-13 10:56:03 +02:00