Parcourir la source

Only checking for necessary extensions when linking, made debug information location-independent

Ilya Epifanov il y a 4 ans
Parent
commit
b67cb52045

+ 3 - 0
riscv-rt/Cargo.toml

@@ -18,3 +18,6 @@ inline-asm = ["riscv/inline-asm"]
 
 [dev-dependencies]
 panic-halt = "0.2.0"
+
+[build-dependencies]
+riscv-target = "0.1.2"

+ 7 - 9
riscv-rt/assemble.ps1

@@ -2,16 +2,14 @@
 Remove-Item -Force bin/*.a
 
 $crate = "riscv-rt"
+$extension_sets = @("i", "im", "ic", "imc")
 
-riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32imac asm.S -o bin/$crate.o
-riscv64-unknown-elf-ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
-riscv64-unknown-elf-ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
+foreach ($ext in $extension_sets) {
+    riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32$ext asm.S -o bin/$crate.o
+    riscv64-unknown-elf-ar crs bin/riscv32$ext-unknown-none-elf.a bin/$crate.o
 
-riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32i asm.S -o bin/$crate.o
-riscv64-unknown-elf-ar crs bin/riscv32i-unknown-none-elf.a bin/$crate.o
-
-riscv64-unknown-elf-gcc -ggdb3 -c -mabi=lp64 -march=rv64imac asm.S -o bin/$crate.o
-riscv64-unknown-elf-ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
-riscv64-unknown-elf-ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o
+    riscv64-unknown-elf-gcc -ggdb3 -c -mabi=lp64 -march=rv64$ext asm.S -o bin/$crate.o
+    riscv64-unknown-elf-ar crs bin/riscv64$ext-unknown-none-elf.a bin/$crate.o
+}
 
 Remove-Item bin/$crate.o

+ 7 - 9
riscv-rt/assemble.sh

@@ -7,15 +7,13 @@ crate=riscv-rt
 # remove existing blobs because otherwise this will append object files to the old blobs
 rm -f bin/*.a
 
-riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32imac asm.S -o bin/$crate.o
-riscv64-unknown-elf-ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
-riscv64-unknown-elf-ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
+for ext in i ic im imc
+do
+    riscv64-unknown-elf-gcc -ggdb3 -fdebug-prefix-map=$(pwd)=/riscv-rt -c -mabi=ilp32 -march=rv32${ext} asm.S -o bin/$crate.o
+    riscv64-unknown-elf-ar crs bin/riscv32${ext}-unknown-none-elf.a bin/$crate.o
 
-riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32i asm.S -o bin/$crate.o
-riscv64-unknown-elf-ar crs bin/riscv32i-unknown-none-elf.a bin/$crate.o
-
-riscv64-unknown-elf-gcc -ggdb3 -c -mabi=lp64 -march=rv64imac asm.S -o bin/$crate.o
-riscv64-unknown-elf-ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
-riscv64-unknown-elf-ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o
+    riscv64-unknown-elf-gcc -ggdb3 -fdebug-prefix-map=$(pwd)=/riscv-rt -c -mabi=lp64 -march=rv64${ext} asm.S -o bin/$crate.o
+    riscv64-unknown-elf-ar crs bin/riscv64${ext}-unknown-none-elf.a bin/$crate.o
+done
 
 rm bin/$crate.o

BIN
riscv-rt/bin/riscv32i-unknown-none-elf.a


BIN
riscv-rt/bin/riscv32ic-unknown-none-elf.a


BIN
riscv-rt/bin/riscv32im-unknown-none-elf.a


BIN
riscv-rt/bin/riscv32imac-unknown-none-elf.a


BIN
riscv-rt/bin/riscv32imc-unknown-none-elf.a


BIN
riscv-rt/bin/riscv64i-unknown-none-elf.a


BIN
riscv-rt/bin/riscv64ic-unknown-none-elf.a


BIN
riscv-rt/bin/riscv64im-unknown-none-elf.a


BIN
riscv-rt/bin/riscv64imac-unknown-none-elf.a


BIN
riscv-rt/bin/riscv64gc-unknown-none-elf.a → riscv-rt/bin/riscv64imc-unknown-none-elf.a


+ 8 - 0
riscv-rt/build.rs

@@ -1,4 +1,7 @@
 // NOTE: Adapted from cortex-m/build.rs
+extern crate riscv_target;
+
+use riscv_target::Target;
 use std::env;
 use std::fs;
 use std::io::Write;
@@ -10,6 +13,11 @@ fn main() {
     let name = env::var("CARGO_PKG_NAME").unwrap();
 
     if target.starts_with("riscv") {
+        let mut target = Target::from_target_str(&target);
+        target.retain_extensions("imc");
+
+        let target = target.to_string();    
+
         fs::copy(
             format!("bin/{}.a", target),
             out_dir.join(format!("lib{}.a", name)),