Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Deps
run: |
rustup target add riscv64imac-unknown-none-elf
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 18 && rm llvm.sh
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 21 && rm llvm.sh
- name: Test
run: |
cargo build --features=stub-syscalls
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ckb-std"
version = "1.0.2"
version = "1.1.0"
authors = ["Nervos network"]
edition = "2024"
license = "MIT"
Expand Down Expand Up @@ -43,8 +43,8 @@ type-id = ["ckb-hash", "ckb-types"]
cc = "1.0"

[dependencies]
ckb-types = { package = "ckb-gen-types", version = "1.0.0", default-features = false, optional = true }
ckb-hash = { version = "1.0.0", default-features = false, features = [
ckb-types = { package = "ckb-gen-types", version = "1.1.0", default-features = false, optional = true }
ckb-hash = { version = "1.1.0", default-features = false, features = [
"ckb-contract",
], optional = true }

Expand Down
49 changes: 44 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::env;
use std::io;
use std::process::Output;

fn main() {
println!("cargo:rerun-if-changed=c/dlopen.c");
Expand Down Expand Up @@ -26,9 +28,49 @@ fn main() {
}
}

fn show_clang_version(clang: &str) -> io::Result<Output> {
std::process::Command::new(clang).arg("--version").output()
}

fn find_clang() -> String {
// The 1st, check if the CLANG environment variable is set and valid.
if let Ok(clang) = std::env::var("CLANG") {
match show_clang_version(&clang) {
Ok(ok) => println!("{}", String::from_utf8_lossy(&ok.stdout)),
Err(_) => panic!(
"Clang compiler not found. Error CLANG environment: {}",
clang
),
}
return clang;
}

// The 2nd, try clang-22, clang-21, ..., clang-19 in order.
for version in [22, 21, 20, 19, 30, 29, 28, 27, 26, 25, 24, 23] {
let clang = format!("clang-{}", version);
match show_clang_version(&clang) {
Ok(ok) => {
println!("{}", String::from_utf8_lossy(&ok.stdout));
return clang;
}
Err(_) => continue,
}
}

// The 3rd, try clang.
match show_clang_version("clang") {
Ok(ok) => {
println!("{}", String::from_utf8_lossy(&ok.stdout));
return "clang".to_string();
}
Err(_) => panic!(
"Clang compiler not found. Please set the CLANG environment variable to the path of your clang executable."
),
}
}

fn setup_compiler_flags(build: &mut cc::Build) {
build
.static_flag(true)
.flag("-fno-builtin-printf")
.flag("-fno-builtin-memcmp")
.flag("-nostdinc")
Expand All @@ -42,10 +84,7 @@ fn setup_compiler_flags(build: &mut cc::Build) {
.flag("-Wno-nonnull")
.include("c/ckb-c-stdlib/libc");

let clang = match std::env::var_os("CLANG") {
Some(val) => val,
None => "clang-18".into(),
};
let clang = find_clang();

if cfg!(feature = "build-with-clang") {
build.compiler(clang);
Expand Down
Loading
Loading