aboutsummaryrefslogtreecommitdiff
path: root/src/target.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-05-23 21:51:10 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-05-23 21:51:10 -0700
commit55811d8dac9109aa6357639908fb4f6c479480f9 (patch)
tree668f796e1c6feeb6972f178c4a9c1333c594cdce /src/target.zig
parent609207801a570508e58d9e02b6ce551fbf1dca30 (diff)
downloadzig-55811d8dac9109aa6357639908fb4f6c479480f9.tar.gz
zig-55811d8dac9109aa6357639908fb4f6c479480f9.zip
stage2: introduce clangAssemblerSupportsMcpuArg
Clang has a completely inconsistent CLI for its integrated assembler for each target architecture. For x86_64, for example, it does not accept an -mcpu parameter, and emits "warning: unused parameter". However, for ARM, -mcpu is needed in order to properly lower assembly to machine code instructions (see new standalone test case provided thanks to @g-w1). This is a compromise between b8f85a805bf61ae11d6ee2bd6d8356fbc98ee3ba and afb9f695b1bdbf81185e7d55d5783bcbab880989.
Diffstat (limited to 'src/target.zig')
-rw-r--r--src/target.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/target.zig b/src/target.zig
index e077d9629c..b4e6123819 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -389,3 +389,12 @@ pub fn clangMightShellOutForAssembly(target: std.Target) bool {
// when targeting a non-BSD OS.
return target.cpu.arch.isSPARC();
}
+
+/// Each backend architecture in Clang has a different codepath which may or may not
+/// support an -mcpu flag.
+pub fn clangAssemblerSupportsMcpuArg(target: std.Target) bool {
+ return switch (target.cpu.arch) {
+ .arm, .armeb, .thumb, .thumbeb => true,
+ else => false,
+ };
+}