aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-12-09 01:35:25 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-12-09 01:39:07 -0700
commitf69f55c807efa336e85862efdfe2abe03e15bd0d (patch)
treed0bbd8dfd1354a87ec989542f8e512d2130eaafc /src
parentda9542c0af1955c54fba4a9466d43d94290e36c9 (diff)
downloadzig-f69f55c807efa336e85862efdfe2abe03e15bd0d.tar.gz
zig-f69f55c807efa336e85862efdfe2abe03e15bd0d.zip
stage2: upgrade musl libc stub file
This is the result of the work on tools/gen_stubs.zig. It now uses the preprocessor to emit different symbols and sizes depending on the architecture. The data is collected directly from multiple libc.so files on disk built with upstream musl. Closes #8178 Addresses #8896 for musl There is still room for further improvement to this, which is to put `.ds` directives after symbols that are not followed by aliases, to avoid the potential problem of a linker believing that all symbols are aliases of each other.
Diffstat (limited to 'src')
-rw-r--r--src/musl.zig14
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",
});