macho: fix various linker flags

fix drivers: zig {cc,c++}
  - `-dynamiclib` is an alias to `-shared`
  - associate `-dynamiclib` with zig `.shared` semantics

fix drivers: zig {cc,c++,build-lib,build-exe}
  - use `-dynamic` for {exe,dylib}
  - for dylib this fixes a regression
  - for exe this replaces incorrect use of `-static`
This commit is contained in:
Michael Dusan 2021-03-14 10:52:35 -04:00 committed by Andrew Kelley
parent 27d07c6c4d
commit a502c160cd
3 changed files with 13 additions and 4 deletions

View File

@ -2426,7 +2426,14 @@ flagpd1("dwarf-ext-refs"),
sepd1("dylib_file"),
flagpd1("dylinker"),
flagpd1("dynamic"),
flagpd1("dynamiclib"),
.{
.name = "dynamiclib",
.syntax = .flag,
.zig_equivalent = .shared,
.pd1 = true,
.pd2 = false,
.psl = false,
},
flagpd1("emit-ast"),
flagpd1("emit-codegen-only"),
flagpd1("emit-header-module"),

View File

@ -644,9 +644,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
try argv.append("defs");
}
if (is_dyn_lib) {
try argv.append("-static");
} else {
if (is_exe_or_dyn_lib) {
try argv.append("-dynamic");
}

View File

@ -332,6 +332,10 @@ const known_options = [_]KnownOpt{
.name = "s",
.ident = "strip",
},
.{
.name = "dynamiclib",
.ident = "shared",
},
};
const blacklisted_options = [_][]const u8{};