authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-07 17:24:49-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-07 17:56:43-04:00
log336ddb80110ed66582674c73aa5b2bcf7f2aac1b
treec01be6d46e3b52e70f2f57e1c2af2f75135ebc8f
parent7ccf7807b3f12428adc5d9ca0ede4e3f4ec6dbbc
signature Commit is signed but in an unrecognized format.

add -target-glibc to cli help and zig build


2 files changed, 16 insertions(+), 2 deletions(-)

src/main.cpp+1
...@@ -75,6 +75,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {...@@ -75,6 +75,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
75 " -dynamic create a shared library (.so; .dll; .dylib)\n"75 " -dynamic create a shared library (.so; .dll; .dylib)\n"
76 " --strip exclude debug symbols\n"76 " --strip exclude debug symbols\n"
77 " -target [name] <arch><sub>-<os>-<abi> see the targets command\n"77 " -target [name] <arch><sub>-<os>-<abi> see the targets command\n"
78 " -target-glibc [version] target a specific glibc version (default: 2.17)\n"
78 " --verbose-tokenize enable compiler debug output for tokenization\n"79 " --verbose-tokenize enable compiler debug output for tokenization\n"
79 " --verbose-ast enable compiler debug output for AST parsing\n"80 " --verbose-ast enable compiler debug output for AST parsing\n"
80 " --verbose-link enable compiler debug output for linking\n"81 " --verbose-link enable compiler debug output for linking\n"
std/build.zig+15-2
...@@ -1053,7 +1053,8 @@ pub const LibExeObjStep = struct {...@@ -1053,7 +1053,8 @@ pub const LibExeObjStep = struct {
1053 installed_path: ?[]const u8,1053 installed_path: ?[]const u8,
1054 install_step: ?*InstallArtifactStep,1054 install_step: ?*InstallArtifactStep,
10551055
1056 libc_file: ?[]const u8,1056 libc_file: ?[]const u8 = null,
1057 target_glibc: ?Version = null,
10571058
1058 const LinkObject = union(enum) {1059 const LinkObject = union(enum) {
1059 StaticPath: []const u8,1060 StaticPath: []const u8,
...@@ -1148,7 +1149,6 @@ pub const LibExeObjStep = struct {...@@ -1148,7 +1149,6 @@ pub const LibExeObjStep = struct {
1148 .single_threaded = false,1149 .single_threaded = false,
1149 .installed_path = null,1150 .installed_path = null,
1150 .install_step = null,1151 .install_step = null,
1151 .libc_file = null,
1152 };1152 };
1153 self.computeOutFileNames();1153 self.computeOutFileNames();
1154 return self;1154 return self;
...@@ -1220,6 +1220,14 @@ pub const LibExeObjStep = struct {...@@ -1220,6 +1220,14 @@ pub const LibExeObjStep = struct {
1220 self.computeOutFileNames();1220 self.computeOutFileNames();
1221 }1221 }
12221222
1223 pub fn setTargetGLibC(self: *LibExeObjStep, major: u32, minor: u32, patch: u32) void {
1224 self.target_glibc = Version{
1225 .major = major,
1226 .minor = minor,
1227 .patch = patch,
1228 };
1229 }
1230
1223 pub fn setOutputDir(self: *LibExeObjStep, dir: []const u8) void {1231 pub fn setOutputDir(self: *LibExeObjStep, dir: []const u8) void {
1224 self.output_dir = self.builder.dupe(dir);1232 self.output_dir = self.builder.dupe(dir);
1225 }1233 }
...@@ -1581,6 +1589,11 @@ pub const LibExeObjStep = struct {...@@ -1581,6 +1589,11 @@ pub const LibExeObjStep = struct {
1581 },1589 },
1582 }1590 }
15831591
1592 if (self.target_glibc) |ver| {
1593 try zig_args.append("-target-glibc");
1594 try zig_args.append(builder.fmt("{}.{}.{}", ver.major, ver.minor, ver.patch));
1595 }
1596
1584 if (self.linker_script) |linker_script| {1597 if (self.linker_script) |linker_script| {
1585 zig_args.append("--linker-script") catch unreachable;1598 zig_args.append("--linker-script") catch unreachable;
1586 zig_args.append(linker_script) catch unreachable;1599 zig_args.append(linker_script) catch unreachable;