Parcourir la source

Only checking for necessary extensions when linking

Ilya Epifanov il y a 4 ans
Parent
commit
0b1131dd20

+ 3 - 0
Cargo.toml

@@ -12,5 +12,8 @@ license = "ISC"
 bare-metal = ">=0.2.0,<0.2.5"
 bit_field = "0.9.0"
 
+[build-dependencies]
+riscv-target = "0.1"
+
 [features]
 inline-asm = []

+ 7 - 6
assemble.ps1

@@ -8,12 +8,13 @@ $crate = "riscv"
 riscv64-unknown-elf-gcc -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 -c -mabi=ilp32 -march=rv32imc 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
+riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32ic asm.S -o bin/$crate.o
+riscv64-unknown-elf-ar crs bin/riscv32ic-unknown-none-elf.a bin/$crate.o
 
-riscv64-unknown-elf-gcc -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 -c -mabi=lp64 -march=rv64i asm.S -o bin/$crate.o
+riscv64-unknown-elf-ar crs bin/riscv64i-unknown-none-elf.a bin/$crate.o
+
+riscv64-unknown-elf-gcc -c -mabi=lp64 -march=rv64ic asm.S -o bin/$crate.o
+riscv64-unknown-elf-ar crs bin/riscv64ic-unknown-none-elf.a bin/$crate.o
 
 Remove-Item bin/$crate.o

+ 7 - 6
assemble.sh

@@ -10,12 +10,13 @@ rm -f bin/*.a
 riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32i asm.S -o bin/$crate.o
 ar crs bin/riscv32i-unknown-none-elf.a bin/$crate.o
 
-riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32imc asm.S -o bin/$crate.o
-ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
-ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
+riscv64-unknown-elf-gcc -c -mabi=ilp32 -march=rv32ic asm.S -o bin/$crate.o
+ar crs bin/riscv32ic-unknown-none-elf.a bin/$crate.o
 
-riscv64-unknown-elf-gcc -c -mabi=lp64 -march=rv64imac asm.S -o bin/$crate.o
-ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
-ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o
+riscv64-unknown-elf-gcc -c -mabi=lp64 -march=rv64i asm.S -o bin/$crate.o
+ar crs bin/riscv64i-unknown-none-elf.a bin/$crate.o
+
+riscv64-unknown-elf-gcc -c -mabi=lp64 -march=rv64ic asm.S -o bin/$crate.o
+ar crs bin/riscv64ic-unknown-none-elf.a bin/$crate.o
 
 rm bin/$crate.o

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


BIN
bin/riscv32imac-unknown-none-elf.a → bin/riscv32ic-unknown-none-elf.a


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


BIN
bin/riscv64imac-unknown-none-elf.a → bin/riscv64i-unknown-none-elf.a


BIN
bin/riscv64gc-unknown-none-elf.a → bin/riscv64ic-unknown-none-elf.a


+ 8 - 0
build.rs

@@ -1,3 +1,6 @@
+extern crate riscv_target;
+
+use riscv_target::Target;
 use std::path::PathBuf;
 use std::{env, fs};
 
@@ -7,6 +10,11 @@ fn main() {
     let name = env::var("CARGO_PKG_NAME").unwrap();
 
     if target.starts_with("riscv") && env::var_os("CARGO_FEATURE_INLINE_ASM").is_none() {
+        let mut target = Target::from_target_str(&target);
+        target.retain_extensions("ic");
+
+        let target = target.to_string();    
+
         fs::copy(
             format!("bin/{}.a", target),
             out_dir.join(format!("lib{}.a", name)),