Commit 336ddb8011
src/main.cpp
@@ -75,6 +75,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
" -dynamic create a shared library (.so; .dll; .dylib)\n"
" --strip exclude debug symbols\n"
" -target [name] <arch><sub>-<os>-<abi> see the targets command\n"
+ " -target-glibc [version] target a specific glibc version (default: 2.17)\n"
" --verbose-tokenize enable compiler debug output for tokenization\n"
" --verbose-ast enable compiler debug output for AST parsing\n"
" --verbose-link enable compiler debug output for linking\n"
std/build.zig
@@ -1053,7 +1053,8 @@ pub const LibExeObjStep = struct {
installed_path: ?[]const u8,
install_step: ?*InstallArtifactStep,
- libc_file: ?[]const u8,
+ libc_file: ?[]const u8 = null,
+ target_glibc: ?Version = null,
const LinkObject = union(enum) {
StaticPath: []const u8,
@@ -1148,7 +1149,6 @@ pub const LibExeObjStep = struct {
.single_threaded = false,
.installed_path = null,
.install_step = null,
- .libc_file = null,
};
self.computeOutFileNames();
return self;
@@ -1220,6 +1220,14 @@ pub const LibExeObjStep = struct {
self.computeOutFileNames();
}
+ pub fn setTargetGLibC(self: *LibExeObjStep, major: u32, minor: u32, patch: u32) void {
+ self.target_glibc = Version{
+ .major = major,
+ .minor = minor,
+ .patch = patch,
+ };
+ }
+
pub fn setOutputDir(self: *LibExeObjStep, dir: []const u8) void {
self.output_dir = self.builder.dupe(dir);
}
@@ -1581,6 +1589,11 @@ pub const LibExeObjStep = struct {
},
}
+ if (self.target_glibc) |ver| {
+ try zig_args.append("-target-glibc");
+ try zig_args.append(builder.fmt("{}.{}.{}", ver.major, ver.minor, ver.patch));
+ }
+
if (self.linker_script) |linker_script| {
zig_args.append("--linker-script") catch unreachable;
zig_args.append(linker_script) catch unreachable;