Skip to content

Commit

Permalink
Merge pull request #1065 from powdr-labs/update_nightly
Browse files Browse the repository at this point in the history
update rust nightly to 2024-02-01
  • Loading branch information
Leo authored Feb 16, 2024
2 parents 340e059 + 869b63c commit da8335d
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nightly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ jobs:
- name: Install Rust toolchain 1.74
run: rustup toolchain install 1.74-x86_64-unknown-linux-gnu
- name: Install nightly
run: rustup toolchain install nightly-2023-01-03-x86_64-unknown-linux-gnu
run: rustup toolchain install nightly-2024-02-01-x86_64-unknown-linux-gnu
- name: Install riscv target
run: rustup target add riscv32imac-unknown-none-elf --toolchain nightly-2023-01-03-x86_64-unknown-linux-gnu
run: rustup target add riscv32imac-unknown-none-elf --toolchain nightly-2024-02-01-x86_64-unknown-linux-gnu
- name: Install stdlib
run: rustup component add rust-src --toolchain nightly-2023-01-03-x86_64-unknown-linux-gnu
run: rustup component add rust-src --toolchain nightly-2024-02-01-x86_64-unknown-linux-gnu
- name: Install pilcom
run: git clone https://github.com/0xPolygonHermez/pilcom.git && cd pilcom && npm install
- name: Check without Halo2
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ jobs:
- name: Install Rust toolchain 1.74 (with clippy and rustfmt)
run: rustup toolchain install 1.74-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.74-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.74-x86_64-unknown-linux-gnu
- name: Install nightly
run: rustup toolchain install nightly-2023-01-03-x86_64-unknown-linux-gnu
run: rustup toolchain install nightly-2024-02-01-x86_64-unknown-linux-gnu
- name: Install riscv target
run: rustup target add riscv32imac-unknown-none-elf --toolchain nightly-2023-01-03-x86_64-unknown-linux-gnu
run: rustup target add riscv32imac-unknown-none-elf --toolchain nightly-2024-02-01-x86_64-unknown-linux-gnu
- name: Install stdlib
run: rustup component add rust-src --toolchain nightly-2023-01-03-x86_64-unknown-linux-gnu
run: rustup component add rust-src --toolchain nightly-2024-02-01-x86_64-unknown-linux-gnu
- name: Install pilcom
run: git clone https://github.com/0xPolygonHermez/pilcom.git && cd pilcom && npm install
- uses: taiki-e/install-action@nextest
Expand Down Expand Up @@ -113,11 +113,11 @@ jobs:
- name: Install Rust toolchain 1.74 (with clippy and rustfmt)
run: rustup toolchain install 1.74-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.74-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.74-x86_64-unknown-linux-gnu
- name: Install nightly
run: rustup toolchain install nightly-2023-01-03-x86_64-unknown-linux-gnu
run: rustup toolchain install nightly-2024-02-01-x86_64-unknown-linux-gnu
- name: Install riscv target
run: rustup target add riscv32imac-unknown-none-elf --toolchain nightly-2023-01-03-x86_64-unknown-linux-gnu
run: rustup target add riscv32imac-unknown-none-elf --toolchain nightly-2024-02-01-x86_64-unknown-linux-gnu
- name: Install stdlib
run: rustup component add rust-src --toolchain nightly-2023-01-03-x86_64-unknown-linux-gnu
run: rustup component add rust-src --toolchain nightly-2024-02-01-x86_64-unknown-linux-gnu
- name: Install pilcom
run: git clone https://github.com/0xPolygonHermez/pilcom.git && cd pilcom && npm install
- uses: taiki-e/install-action@nextest
Expand Down
3 changes: 3 additions & 0 deletions asm-utils/src/reachability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ fn iterate_basic_block<'a, R: Register, F: FunctionOpKind, A: Architecture>(

fn ends_control_flow<R: Register, F: FunctionOpKind, A: Architecture>(s: &Statement<R, F>) -> bool {
match s {
// The rust compiler allows functions that end in the panic handler (`begin_unwind`) to never return.
// We use this directive to identify the end of these non-returning functions.
Statement::Directive(dir, _) if dir == ".cfi_endproc" => true,
Statement::Instruction(instruction, _) => {
A::instruction_ends_control_flow(instruction.as_str())
}
Expand Down
2 changes: 1 addition & 1 deletion riscv-runtime/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2023-01-03"
channel = "nightly-2024-02-01"
targets = ["riscv32imac-unknown-none-elf"]
profile = "minimal"
33 changes: 24 additions & 9 deletions riscv/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ pub fn compile(
.insert("__runtime".to_string(), runtime(coprocessors))
.is_none());

assert!(assemblies
.insert("__extra_symbols".to_string(), EXTRA_SYMBOLS.to_string())
.is_none());

// TODO remove unreferenced files.
let (mut statements, file_ids) = disambiguator::disambiguate(
assemblies
Expand Down Expand Up @@ -757,6 +761,19 @@ fn memory(with_bootloader: bool) -> String {
"#
}

/// some extra symbols expected by rust code:
/// - __rust_no_alloc_shim_is_unstable: compilation time acknowledgment that this feature is unstable.
/// - __rust_alloc_error_handler_should_panic: needed by the default alloc error handler,
/// not sure why it's not present in the asm.
/// https://github.com/rust-lang/rust/blob/ae9d7b0c6434b27e4e2effe8f05b16d37e7ef33f/library/alloc/src/alloc.rs#L415
static EXTRA_SYMBOLS: &str = r".data
.globl __rust_alloc_error_handler_should_panic
__rust_alloc_error_handler_should_panic: .byte 0
.globl __rust_no_alloc_shim_is_unstable
__rust_no_alloc_shim_is_unstable: .byte 0
.text
";

fn runtime(coprocessors: &CoProcessors) -> String {
[
"__divdi3",
Expand All @@ -782,15 +799,9 @@ fn runtime(coprocessors: &CoProcessors) -> String {
]
.map(|n| format!(".globl {n}@plt\n.globl {n}\n.set {n}@plt, {n}\n"))
.join("\n\n")
+ &[
("__rust_alloc", "__rg_alloc"),
("__rust_dealloc", "__rg_dealloc"),
("__rust_realloc", "__rg_realloc"),
("__rust_alloc_zeroed", "__rg_alloc_zeroed"),
("__rust_alloc_error_handler", "__rg_oom"),
]
.map(|(n, m)| format!(".globl {n}\n.set {n}, {m}\n"))
.join("\n\n")
+ &[("__rust_alloc_error_handler", "__rg_oom")]
.map(|(n, m)| format!(".globl {n}\n.set {n}, {m}\n"))
.join("\n\n")
+ &coprocessors.runtime()
}

Expand All @@ -808,6 +819,10 @@ fn process_statement(s: Statement, coprocessors: &CoProcessors) -> Vec<String> {
// We ignore ".file" directives because they have been extracted to the top.
vec![]
}
(".size", _) => {
// We ignore ".size" directives
vec![]
}
_ if directive.starts_with(".cfi_") => vec![],
_ => panic!(
"Leftover directive in code: {directive} {}",
Expand Down
2 changes: 1 addition & 1 deletion riscv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ fn build_cargo_command(input_dir: &str, target_dir: &Path, produce_build_plan: b

let args = as_ref![
OsStr;
"+nightly-2023-01-03",
"+nightly-2024-02-01",
"build",
"--release",
"-Z",
Expand Down
2 changes: 1 addition & 1 deletion riscv/tests/riscv_data/evm/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2023-01-03"
channel = "nightly-2024-02-01"
targets = ["riscv32imac-unknown-none-elf"]
profile = "minimal"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2023-01-03"
channel = "nightly-2024-02-01"
targets = ["riscv32imac-unknown-none-elf"]
profile = "minimal"
2 changes: 1 addition & 1 deletion riscv/tests/riscv_data/vec_median/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2023-01-03"
channel = "nightly-2024-02-01"
targets = ["riscv32imac-unknown-none-elf"]
profile = "minimal"

0 comments on commit da8335d

Please sign in to comment.