| ... | @@ -867,9 +867,9 @@ pub const LibExeObjStep = struct { | ... | @@ -867,9 +867,9 @@ pub const LibExeObjStep = struct { |
| 867 | }; | 867 | }; |
| 868 | switch (target_os) { | 868 | switch (target_os) { |
| 869 | builtin.Os.darwin, builtin.Os.ios, builtin.Os.macosx => { | 869 | builtin.Os.darwin, builtin.Os.ios, builtin.Os.macosx => { |
| 870 | self.out_filename = self.builder.fmt("lib{}.dylib.{d}.{d}.{d}", | 870 | self.out_filename = self.builder.fmt("lib{}.{d}.{d}.{d}.dylib", |
| 871 | self.name, self.version.major, self.version.minor, self.version.patch); | 871 | self.name, self.version.major, self.version.minor, self.version.patch); |
| 872 | self.major_only_filename = self.builder.fmt("lib{}.dylib.{d}", self.name, self.version.major); | 872 | self.major_only_filename = self.builder.fmt("lib{}.{d}.dylib", self.name, self.version.major); |
| 873 | self.name_only_filename = self.builder.fmt("lib{}.dylib", self.name); | 873 | self.name_only_filename = self.builder.fmt("lib{}.dylib", self.name); |
| 874 | }, | 874 | }, |
| 875 | builtin.Os.windows => { | 875 | builtin.Os.windows => { |
| ... | @@ -1225,6 +1225,15 @@ pub const LibExeObjStep = struct { | ... | @@ -1225,6 +1225,15 @@ pub const LibExeObjStep = struct { |
| 1225 | var cc_args = ArrayList([]const u8).init(builder.allocator); | 1225 | var cc_args = ArrayList([]const u8).init(builder.allocator); |
| 1226 | defer cc_args.deinit(); | 1226 | defer cc_args.deinit(); |
| 1227 | | 1227 | |
| | 1228 | const target_os = switch (self.target) { |
| | 1229 | Target.Native => builtin.os, |
| | 1230 | Target.Cross => |t| t.os, |
| | 1231 | }; |
| | 1232 | const is_darwin = switch (target_os) { |
| | 1233 | builtin.Os.darwin, builtin.Os.ios, builtin.Os.macosx => true, |
| | 1234 | else => false, |
| | 1235 | }; |
| | 1236 | |
| 1228 | switch (self.kind) { | 1237 | switch (self.kind) { |
| 1229 | Kind.Obj => { | 1238 | Kind.Obj => { |
| 1230 | %%cc_args.append("-c"); | 1239 | %%cc_args.append("-c"); |
| ... | @@ -1286,12 +1295,27 @@ pub const LibExeObjStep = struct { | ... | @@ -1286,12 +1295,27 @@ pub const LibExeObjStep = struct { |
| 1286 | } else { | 1295 | } else { |
| 1287 | %%cc_args.resize(0); | 1296 | %%cc_args.resize(0); |
| 1288 | | 1297 | |
| 1289 | %%cc_args.append("-fPIC"); | 1298 | if (is_darwin) { |
| 1290 | %%cc_args.append("-shared"); | 1299 | %%cc_args.append("-dynamiclib"); |
| | 1300 | |
| | 1301 | %%cc_args.append("-Wl,-headerpad_max_install_names"); |
| | 1302 | |
| | 1303 | %%cc_args.append("-compatibility_version"); |
| | 1304 | %%cc_args.append(builder.fmt("{}.0.0", self.version.major)); |
| 1291 | | 1305 | |
| 1292 | const soname_arg = builder.fmt("-Wl,-soname,lib{}.so.{d}", self.name, self.version.major); | 1306 | %%cc_args.append("-current_version"); |
| 1293 | defer builder.allocator.free(soname_arg); | 1307 | %%cc_args.append(builder.fmt("{}.{}.{}", self.version.major, self.version.minor, self.version.patch)); |
| 1294 | %%cc_args.append(soname_arg); | 1308 | |
| | 1309 | %%cc_args.append("-install_name"); |
| | 1310 | %%cc_args.append(builder.pathFromRoot(self.major_only_filename)); |
| | 1311 | } else { |
| | 1312 | %%cc_args.append("-fPIC"); |
| | 1313 | %%cc_args.append("-shared"); |
| | 1314 | |
| | 1315 | const soname_arg = builder.fmt("-Wl,-soname,lib{}.so.{d}", self.name, self.version.major); |
| | 1316 | defer builder.allocator.free(soname_arg); |
| | 1317 | %%cc_args.append(soname_arg); |
| | 1318 | } |
| 1295 | | 1319 | |
| 1296 | const output_path = builder.pathFromRoot(self.getOutputPath()); | 1320 | const output_path = builder.pathFromRoot(self.getOutputPath()); |
| 1297 | %%cc_args.append("-o"); | 1321 | %%cc_args.append("-o"); |
| ... | @@ -1301,12 +1325,14 @@ pub const LibExeObjStep = struct { | ... | @@ -1301,12 +1325,14 @@ pub const LibExeObjStep = struct { |
| 1301 | %%cc_args.append(builder.pathFromRoot(object_file)); | 1325 | %%cc_args.append(builder.pathFromRoot(object_file)); |
| 1302 | } | 1326 | } |
| 1303 | | 1327 | |
| 1304 | const rpath_arg = builder.fmt("-Wl,-rpath,{}", | 1328 | if (!is_darwin) { |
| 1305 | %%os.path.real(builder.allocator, builder.pathFromRoot(builder.cache_root))); | 1329 | const rpath_arg = builder.fmt("-Wl,-rpath,{}", |
| 1306 | defer builder.allocator.free(rpath_arg); | 1330 | %%os.path.real(builder.allocator, builder.pathFromRoot(builder.cache_root))); |
| 1307 | %%cc_args.append(rpath_arg); | 1331 | defer builder.allocator.free(rpath_arg); |
| | 1332 | %%cc_args.append(rpath_arg); |
| 1308 | | 1333 | |
| 1309 | %%cc_args.append("-rdynamic"); | 1334 | %%cc_args.append("-rdynamic"); |
| | 1335 | } |
| 1310 | | 1336 | |
| 1311 | for (self.full_path_libs.toSliceConst()) |full_path_lib| { | 1337 | for (self.full_path_libs.toSliceConst()) |full_path_lib| { |
| 1312 | %%cc_args.append(builder.pathFromRoot(full_path_lib)); | 1338 | %%cc_args.append(builder.pathFromRoot(full_path_lib)); |
| ... | @@ -1364,10 +1390,6 @@ pub const LibExeObjStep = struct { | ... | @@ -1364,10 +1390,6 @@ pub const LibExeObjStep = struct { |
| 1364 | | 1390 | |
| 1365 | %%cc_args.append("-rdynamic"); | 1391 | %%cc_args.append("-rdynamic"); |
| 1366 | | 1392 | |
| 1367 | const target_os = switch (self.target) { | | |
| 1368 | Target.Native => builtin.os, | | |
| 1369 | Target.Cross => |t| t.os, | | |
| 1370 | }; | | |
| 1371 | switch (target_os) { | 1393 | switch (target_os) { |
| 1372 | builtin.Os.darwin, builtin.Os.ios, builtin.Os.macosx => { | 1394 | builtin.Os.darwin, builtin.Os.ios, builtin.Os.macosx => { |
| 1373 | if (self.need_flat_namespace_hack) { | 1395 | if (self.need_flat_namespace_hack) { |