aboutsummaryrefslogtreecommitdiff
path: root/std/build.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-08-27 17:16:42 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-08-27 17:16:42 -0400
commitebdc6b594ddc0762ed9e41b5f36e6da5e03c19e0 (patch)
treefcc648080b4684e96d1016a912c647d0c8e313cd /std/build.zig
parent5fd579a51c44c31b99cf34d9e8ada3b7692b4c43 (diff)
downloadzig-ebdc6b594ddc0762ed9e41b5f36e6da5e03c19e0.tar.gz
zig-ebdc6b594ddc0762ed9e41b5f36e6da5e03c19e0.zip
all tests passing in MacOS
depends on LLD 5.0.0 with 3 patches See #273
Diffstat (limited to 'std/build.zig')
-rw-r--r--std/build.zig42
1 files changed, 38 insertions, 4 deletions
diff --git a/std/build.zig b/std/build.zig
index 7a40e97f52..072a400b30 100644
--- a/std/build.zig
+++ b/std/build.zig
@@ -784,10 +784,27 @@ pub const LibExeObjStep = struct {
if (self.static) {
self.out_filename = self.builder.fmt("lib{}.a", self.name);
} else {
- self.out_filename = self.builder.fmt("lib{}.so.{d}.{d}.{d}",
- self.name, self.version.major, self.version.minor, self.version.patch);
- self.major_only_filename = self.builder.fmt("lib{}.so.{d}", self.name, self.version.major);
- self.name_only_filename = self.builder.fmt("lib{}.so", self.name);
+ const target_os = switch (self.target) {
+ Target.Native => builtin.os,
+ Target.Cross => |t| t.os,
+ };
+ switch (target_os) {
+ builtin.Os.darwin, builtin.Os.ios, builtin.Os.macosx => {
+ self.out_filename = self.builder.fmt("lib{}.dylib.{d}.{d}.{d}",
+ self.name, self.version.major, self.version.minor, self.version.patch);
+ self.major_only_filename = self.builder.fmt("lib{}.dylib.{d}", self.name, self.version.major);
+ self.name_only_filename = self.builder.fmt("lib{}.dylib", self.name);
+ },
+ builtin.Os.windows => {
+ self.out_filename = self.builder.fmt("lib{}.dll", self.name);
+ },
+ else => {
+ self.out_filename = self.builder.fmt("lib{}.so.{d}.{d}.{d}",
+ self.name, self.version.major, self.version.minor, self.version.patch);
+ self.major_only_filename = self.builder.fmt("lib{}.so.{d}", self.name, self.version.major);
+ self.name_only_filename = self.builder.fmt("lib{}.so", self.name);
+ },
+ }
}
},
}
@@ -1124,6 +1141,7 @@ pub const CLibExeObjStep = struct {
kind: Kind,
build_mode: builtin.Mode,
strip: bool,
+ need_flat_namespace_hack: bool,
const Kind = enum {
Exe,
@@ -1178,6 +1196,7 @@ pub const CLibExeObjStep = struct {
.object_src = undefined,
.build_mode = builtin.Mode.Debug,
.strip = false,
+ .need_flat_namespace_hack = false,
};
clib.computeOutFileNames();
return clib;
@@ -1223,6 +1242,7 @@ pub const CLibExeObjStep = struct {
%%self.full_path_libs.append(lib.getOutputPath());
// TODO should be some kind of isolated directory that only has this header in it
%%self.include_dirs.append(self.builder.cache_root);
+ self.need_flat_namespace_hack = true;
}
pub fn linkSystemLibrary(self: &CLibExeObjStep, name: []const u8) {
@@ -1448,6 +1468,20 @@ pub const CLibExeObjStep = struct {
%%cc_args.append("-rdynamic");
+ const target_os = switch (self.target) {
+ Target.Native => builtin.os,
+ Target.Cross => |t| t.os,
+ };
+ switch (target_os) {
+ builtin.Os.darwin, builtin.Os.ios, builtin.Os.macosx => {
+ if (self.need_flat_namespace_hack) {
+ %%cc_args.append("-Wl,-flat_namespace");
+ }
+ %%cc_args.append("-Wl,-search_paths_first");
+ },
+ else => {}
+ }
+
for (self.full_path_libs.toSliceConst()) |full_path_lib| {
%%cc_args.append(builder.pathFromRoot(full_path_lib));
}