Commit 6e9396e32b

Andrew Kelley <andrew@ziglang.org>
2020-09-15 08:03:13
integrate target features into building assembly code
This brings us up to par from what stage1 does. There will still be an open issue for completing this.
1 parent 1ad60c4
Changed files (2)
src-self-hosted/Compilation.zig
@@ -1241,10 +1241,20 @@ fn addCCArgs(
         },
         .so, .assembly, .ll, .bc, .unknown => {},
     }
-    // TODO CLI args for cpu features when compiling assembly
-    //for (size_t i = 0; i < g->zig_target->llvm_cpu_features_asm_len; i += 1) {
-    //    try argv.append(g->zig_target->llvm_cpu_features_asm_ptr[i]);
-    //}
+    // Argh, why doesn't the assembler accept the list of CPU features?!
+    // I don't see a way to do this other than hard coding everything.
+    switch (target.cpu.arch) {
+        .riscv32, .riscv64 => {
+            if (std.Target.riscv.featureSetHas(target.cpu.features, .relax)) {
+                try argv.append("-mrelax");
+            } else {
+                try argv.append("-mno-relax");
+            }
+        },
+        else => {
+            // TODO
+        },
+    }
 
     if (target.os.tag == .freestanding) {
         try argv.append("-ffreestanding");
BRANCH_TODO
@@ -1,4 +1,3 @@
- * integrate target features into building assembly code
  * handle .d files from c objects
  * glibc .so files
  * support rpaths in ELF linker code
@@ -46,3 +45,4 @@
  * improve robustness of response file parsing
  * there are a couple panic("TODO") in clang options parsing
  * std.testing needs improvement to support exposing directory path for its tmp dir (look for "bogus")
+ * integrate target features into building assembly code