diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-12-09 14:12:51 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-09 14:12:51 -0800 |
| commit | 01cb0bdb8317484cab0f8ee3896c981c851d3bb1 (patch) | |
| tree | f638df428189364463da042fa0019552ec9f7a0a /src | |
| parent | 803178353976fe4ef343aef25dfa6d8e418ef88f (diff) | |
| parent | f69f55c807efa336e85862efdfe2abe03e15bd0d (diff) | |
| download | zig-01cb0bdb8317484cab0f8ee3896c981c851d3bb1.tar.gz zig-01cb0bdb8317484cab0f8ee3896c981c851d3bb1.zip | |
Merge pull request #10304 from ziglang/musl-stubgrade
Improve musl libc.so stubs
Diffstat (limited to 'src')
| -rw-r--r-- | src/musl.zig | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/musl.zig b/src/musl.zig index cad6246c98..d15d691a9c 100644 --- a/src/musl.zig +++ b/src/musl.zig @@ -191,11 +191,20 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { return comp.build_crt_file("c", .Lib, c_source_files.items); }, .libc_so => { + const target = comp.getTarget(); + const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{ + @tagName(target.cpu.arch), + }); + const clang_argv: []const []const u8 = if (target.cpu.arch.ptrBitWidth() == 64) + &[_][]const u8{ "-DPTR64", arch_define } + else + &[_][]const u8{arch_define}; + const sub_compilation = try Compilation.create(comp.gpa, .{ .local_cache_directory = comp.global_cache_directory, .global_cache_directory = comp.global_cache_directory, .zig_lib_directory = comp.zig_lib_directory, - .target = comp.getTarget(), + .target = target, .root_name = "c", .main_pkg = null, .output_mode = .Lib, @@ -223,8 +232,9 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, .clang_passthrough_mode = comp.clang_passthrough_mode, .c_source_files = &[_]Compilation.CSourceFile{ - .{ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "libc.s" }) }, + .{ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "libc.S" }) }, }, + .clang_argv = clang_argv, .skip_linker_dependencies = true, .soname = "libc.so", }); |
