From 6e9396e32b4f31eb57ac18da510fff1ad24637a0 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 14 Sep 2020 23:03:13 -0700 Subject: [PATCH] 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. --- BRANCH_TODO | 2 +- src-self-hosted/Compilation.zig | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/BRANCH_TODO b/BRANCH_TODO index 5ec11da3f0..c3f80a204d 100644 --- a/BRANCH_TODO +++ b/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 diff --git a/src-self-hosted/Compilation.zig b/src-self-hosted/Compilation.zig index 48bc20630b..94c6f7909f 100644 --- a/src-self-hosted/Compilation.zig +++ b/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");