diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-10-18 21:09:03 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2021-10-19 20:39:42 +0200 |
| commit | 372e9709ad2f4af24461f0fa601754a469091c2b (patch) | |
| tree | d989814d9c7665d41f8afa973fc00a91ba61b387 /src/link.zig | |
| parent | 2d7b55aa0ac30bd0e85cc43e22ef578c7a0d766c (diff) | |
| download | zig-372e9709ad2f4af24461f0fa601754a469091c2b.tar.gz zig-372e9709ad2f4af24461f0fa601754a469091c2b.zip | |
macho: fix LLVM codepaths in self-hosted linker
* do not add linkage scope to aliased exported symbols - this is
not respected on macOS
* special-case `MachO.openPath` in `link.File.openPath` as on macOS
we always link with zld
* redirect to `MachO.flushObject` when linking relocatable objects
in MachO linker whereas move the entire linking logic into
`MachO.flushModule`
Diffstat (limited to 'src/link.zig')
| -rw-r--r-- | src/link.zig | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/link.zig b/src/link.zig index 9af7fe929c..5874ed5703 100644 --- a/src/link.zig +++ b/src/link.zig @@ -192,12 +192,16 @@ pub const File = struct { /// rewriting it. A malicious file is detected as incremental link failure /// and does not cause Illegal Behavior. This operation is not atomic. pub fn openPath(allocator: *Allocator, options: Options) !*File { + if (options.object_format == .macho) { + return &(try MachO.openPath(allocator, options)).base; + } + const use_stage1 = build_options.is_stage1 and options.use_stage1; if (use_stage1 or options.emit == null) { return switch (options.object_format) { .coff => &(try Coff.createEmpty(allocator, options)).base, .elf => &(try Elf.createEmpty(allocator, options)).base, - .macho => &(try MachO.createEmpty(allocator, options)).base, + .macho => unreachable, .wasm => &(try Wasm.createEmpty(allocator, options)).base, .plan9 => return &(try Plan9.createEmpty(allocator, options)).base, .c => unreachable, // Reported error earlier. @@ -215,7 +219,7 @@ pub const File = struct { return switch (options.object_format) { .coff => &(try Coff.createEmpty(allocator, options)).base, .elf => &(try Elf.createEmpty(allocator, options)).base, - .macho => &(try MachO.createEmpty(allocator, options)).base, + .macho => unreachable, .plan9 => &(try Plan9.createEmpty(allocator, options)).base, .wasm => &(try Wasm.createEmpty(allocator, options)).base, .c => unreachable, // Reported error earlier. @@ -235,7 +239,7 @@ pub const File = struct { const file: *File = switch (options.object_format) { .coff => &(try Coff.openPath(allocator, sub_path, options)).base, .elf => &(try Elf.openPath(allocator, sub_path, options)).base, - .macho => &(try MachO.openPath(allocator, sub_path, options)).base, + .macho => unreachable, .plan9 => &(try Plan9.openPath(allocator, sub_path, options)).base, .wasm => &(try Wasm.openPath(allocator, sub_path, options)).base, .c => &(try C.openPath(allocator, sub_path, options)).base, @@ -576,7 +580,11 @@ pub const File = struct { const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; } - try base.flushModule(comp); + if (base.options.object_format == .macho) { + try base.cast(MachO).?.flushObject(comp); + } else { + try base.flushModule(comp); + } const obj_basename = base.intermediary_basename.?; const full_obj_path = try directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; |
