Skip to content

Commit

Permalink
Detect target. enable flags only for rv32
Browse files Browse the repository at this point in the history
  • Loading branch information
preston-evans98 committed Jul 23, 2022
1 parent 6b43416 commit 391260c
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions secp256k1-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,25 @@ fn main() {
// TODO these three should be changed to use libgmp, at least until secp PR 290 is merged
.define("USE_NUM_NONE", Some("1"))
.define("USE_FIELD_INV_BUILTIN", Some("1"))
.define("USE_SCALAR_INV_BUILTIN", Some("1"))
.compiler("/usr/local/opt/llvm/bin/clang")
.flag("--sysroot=/opt/riscv/riscv32-unknown-elf") // https://github.com/riscv-collab/riscv-gnu-toolchain has been built and stored in /opt/riscv
.flag("--gcc-toolchain=/opt/riscv") // https://github.com/riscv-collab/riscv-gnu-toolchain has been built and stored in /opt/riscv
.no_default_flags(true)
.flag("-O3")
.flag("--target=riscv32-unknown-none-elf")
.flag("-mabi=ilp32")
.flag("-mcmodel=medany")
.flag("-Os")
.flag("-fdata-sections")
.flag("-ffunction-sections")
.flag("-dead_strip")
.flag("-flto")
.flag("-march=rv32im")
.target("riscv32-unknown-none-elf");
.define("USE_SCALAR_INV_BUILTIN", Some("1"));

if env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "riscv32" {
base_config.compiler("/usr/local/opt/llvm/bin/clang")
.flag("--sysroot=/opt/riscv/riscv32-unknown-elf") // https://github.com/riscv-collab/riscv-gnu-toolchain has been built and stored in /opt/riscv
.flag("--gcc-toolchain=/opt/riscv") // https://github.com/riscv-collab/riscv-gnu-toolchain has been built and stored in /opt/riscv
.no_default_flags(true)
.flag("-O3")
.flag("--target=riscv32-unknown-none-elf")
.flag("-mabi=ilp32")
.flag("-mcmodel=medany")
.flag("-Os")
.flag("-fdata-sections")
.flag("-ffunction-sections")
.flag("-dead_strip")
.flag("-flto")
.flag("-march=rv32im")
.target("riscv32-unknown-none-elf");
}

if cfg!(feature = "lowmemory") {
base_config.define("ECMULT_WINDOW_SIZE", Some("4")); // A low-enough value to consume negligible memory
Expand Down

0 comments on commit 391260c

Please sign in to comment.