aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 234b28219b..73125c3b55 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -8267,10 +8267,39 @@ static void detect_libc(CodeGen *g) {
if (target_can_build_libc(g->zig_target)) {
const char *generic_name = target_libc_generic_name(g->zig_target);
-
+ const char *arch_name = target_arch_name(g->zig_target->arch);
+ const char *abi_name = target_abi_name(g->zig_target->abi);
+ if (target_is_musl(g->zig_target)) {
+ // musl has some overrides. its headers are ABI-agnostic and so they all have the "musl" ABI name.
+ abi_name = "musl";
+ // some architectures are handled by the same set of headers
+ switch (g->zig_target->arch) {
+ case ZigLLVM_aarch64:
+ case ZigLLVM_aarch64_be:
+ arch_name = "aarch64";
+ break;
+ case ZigLLVM_arm:
+ case ZigLLVM_armeb:
+ arch_name = "arm";
+ break;
+ case ZigLLVM_mips:
+ case ZigLLVM_mipsel:
+ arch_name = "mips";
+ break;
+ case ZigLLVM_mips64:
+ case ZigLLVM_mips64el:
+ arch_name = "mips64";
+ break;
+ case ZigLLVM_ppc64:
+ case ZigLLVM_ppc64le:
+ arch_name = "powerpc64";
+ break;
+ default:
+ break;
+ }
+ }
Buf *arch_include_dir = buf_sprintf("%s" OS_SEP "libc" OS_SEP "include" OS_SEP "%s-%s-%s",
- buf_ptr(g->zig_lib_dir), target_arch_name(g->zig_target->arch),
- target_os_name(g->zig_target->os), target_abi_name(g->zig_target->abi));
+ buf_ptr(g->zig_lib_dir), arch_name, target_os_name(g->zig_target->os), abi_name);
Buf *generic_include_dir = buf_sprintf("%s" OS_SEP "libc" OS_SEP "include" OS_SEP "generic-%s",
buf_ptr(g->zig_lib_dir), generic_name);
Buf *arch_os_include_dir = buf_sprintf("%s" OS_SEP "libc" OS_SEP "include" OS_SEP "%s-%s-any",