aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2021-05-06 19:03:42 +0200
committerIsaac Freund <ifreund@ifreund.xyz>2021-05-11 12:27:24 +0200
commitac546f56eb2b9fd50a69f1d0bda3d0d070b76f52 (patch)
treeb102f9dbd11b9aba60840f9c983fc6044b4218b5 /src
parentb288f8c9a657b1c5a97e3e543d8598a9e749a390 (diff)
downloadzig-ac546f56eb2b9fd50a69f1d0bda3d0d070b76f52.tar.gz
zig-ac546f56eb2b9fd50a69f1d0bda3d0d070b76f52.zip
stage2: Allow building musl/glibc in thumb mode
Diffstat (limited to 'src')
-rw-r--r--src/Compilation.zig12
-rw-r--r--src/target.zig6
2 files changed, 16 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 46fb5e575d..87d4c4c41e 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -2903,7 +2903,17 @@ fn detectLibCIncludeDirs(
if (target_util.canBuildLibC(target)) {
const generic_name = target_util.libCGenericName(target);
// Some architectures are handled by the same set of headers.
- const arch_name = if (target.abi.isMusl()) target_util.archMuslName(target.cpu.arch) else @tagName(target.cpu.arch);
+ const arch_name = if (target.abi.isMusl())
+ target_util.archMuslName(target.cpu.arch)
+ else if (target.cpu.arch.isThumb())
+ // ARM headers are valid for Thumb too.
+ switch (target.cpu.arch) {
+ .thumb => "arm",
+ .thumbeb => "armeb",
+ else => unreachable,
+ }
+ else
+ @tagName(target.cpu.arch);
const os_name = @tagName(target.os.tag);
// Musl's headers are ABI-agnostic and so they all have the "musl" ABI name.
const abi_name = if (target.abi.isMusl()) "musl" else @tagName(target.abi);
diff --git a/src/target.zig b/src/target.zig
index 25ed726fe6..1e31f99dc1 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -24,6 +24,10 @@ pub const available_libcs = [_]ArchOsAbi{
.{ .arch = .arm, .os = .linux, .abi = .gnueabihf },
.{ .arch = .arm, .os = .linux, .abi = .musleabi },
.{ .arch = .arm, .os = .linux, .abi = .musleabihf },
+ .{ .arch = .thumb, .os = .linux, .abi = .gnueabi },
+ .{ .arch = .thumb, .os = .linux, .abi = .gnueabihf },
+ .{ .arch = .thumb, .os = .linux, .abi = .musleabi },
+ .{ .arch = .thumb, .os = .linux, .abi = .musleabihf },
.{ .arch = .arm, .os = .windows, .abi = .gnu },
.{ .arch = .csky, .os = .linux, .abi = .gnueabi },
.{ .arch = .csky, .os = .linux, .abi = .gnueabihf },
@@ -97,7 +101,7 @@ pub fn libCGenericName(target: std.Target) [:0]const u8 {
pub fn archMuslName(arch: std.Target.Cpu.Arch) [:0]const u8 {
switch (arch) {
.aarch64, .aarch64_be => return "aarch64",
- .arm, .armeb => return "arm",
+ .arm, .armeb, .thumb, .thumbeb => return "arm",
.mips, .mipsel => return "mips",
.mips64el, .mips64 => return "mips64",
.powerpc => return "powerpc",