From ff17ef1e07a5abaf644b6819b4beef6206a7333e Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 13 May 2026 22:19:50 +0100 Subject: [PATCH 1/9] edits --- CMakeLists.txt | 42 +++++++++++---------------- cmake/rust-toolchain.cmake | 11 ------- libcc2rs/rust-toolchain.toml | 2 -- rule-preprocessor/rust-toolchain.toml | 1 - rules/rust-toolchain.toml | 2 -- 5 files changed, 17 insertions(+), 41 deletions(-) delete mode 100644 libcc2rs/rust-toolchain.toml delete mode 100644 rules/rust-toolchain.toml diff --git a/CMakeLists.txt b/CMakeLists.txt index e0bbfe7b..e7f6d258 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,12 +64,6 @@ if (NOT RUSTC_LLVM_VERSION STREQUAL LLVM_PACKAGE_VERSION) endif() include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake) - -# rule-preprocessor uses nightly -foreach(_dir libcc2rs rules) - write_rust_toolchain(${CMAKE_SOURCE_DIR}/${_dir}) -endforeach() - set(RUST_STAMP_FILE "${CMAKE_BINARY_DIR}/.rust-toolchain.stamp") add_custom_command( @@ -95,18 +89,18 @@ set(PYTHON_SOURCES ${PROJECT_SOURCE_DIR}/tests/lit/lit/formats/Cpp2RustTest.py) add_custom_target("format" COMMAND ${CLANG_FORMAT} -i ${ALL_CXX_SOURCES} - COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml - COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml - COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml - COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml - COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}/rules - cargo clippy --fix --allow-dirty --allow-staged --all-targets --all-features -- -Dwarnings - COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}/rule-preprocessor - cargo clippy --fix --allow-dirty --allow-staged --all-targets --all-features -- -Dwarnings - COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}/libcc2rs - cargo clippy --fix --allow-dirty --allow-staged --all-targets --all-features -- -Dwarnings - COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}/libcc2rs-macros - cargo clippy --fix --allow-dirty --allow-staged --all-targets --all-features -- -Dwarnings + COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml + COMMAND cargo +${RUST_STABLE_VERSION} --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml + COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml + COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml + COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features + --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml -- -Dwarnings + COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features + --manifest-path chdir ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml -- -Dwarnings + COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features + --manifest-path $${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml -- -Dwarnings + COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features + --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml -- -Dwarnings COMMAND ${RUFF} --silent check --fix ${PYTHON_SOURCES} COMMAND ${RUFF} --silent format ${PYTHON_SOURCES} DEPENDS "${RUST_STAMP_FILE}" @@ -119,7 +113,7 @@ if (NOT LIT_FLAGS) endif() add_custom_target("check-libcc2rs" - COMMAND cargo test + COMMAND cargo +${RUST_STABLE_VERSION} test WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/libcc2rs" DEPENDS "${RUST_STAMP_FILE}" USES_TERMINAL @@ -188,12 +182,10 @@ file(GLOB_RECURSE rule_preprocessor_sources add_custom_command( OUTPUT ${rust_rules_ir_outputs} - COMMAND cargo build - COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}/rule-preprocessor - ${CMAKE_COMMAND} -E env - CARGO_TARGET_DIR=${PROJECT_SOURCE_DIR}/rule-preprocessor/target - cargo run - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/rules" + COMMAND cargo +${RUST_STABLE_VERSION} build --release --manifest-path "${PROJECT_SOURCE_DIR}/rules/Cargo.toml" + COMMAND ${CMAKE_COMMAND} -E env + CARGO_TARGET_DIR="${CMAKE_CURRENT_BINARY_DIR}/target_preprocessor" + cargo +nightly-2026-05-13 run --manifest-path "${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml" DEPENDS ${rust_rules_inputs} ${rule_preprocessor_sources} "${RUST_STAMP_FILE}" VERBATIM ) diff --git a/cmake/rust-toolchain.cmake b/cmake/rust-toolchain.cmake index e6449eda..21762a3a 100644 --- a/cmake/rust-toolchain.cmake +++ b/cmake/rust-toolchain.cmake @@ -1,12 +1 @@ set(RUST_STABLE_VERSION "1.95.0") - -function(write_rust_toolchain DIR) - set(_content "[toolchain]\nchannel = \"${RUST_STABLE_VERSION}\"\n") - set(_file ${DIR}/rust-toolchain.toml) - if (EXISTS ${_file}) - file(READ ${_file} _existing) - endif() - if (NOT "${_existing}" STREQUAL "${_content}") - file(WRITE ${_file} ${_content}) - endif() -endfunction() diff --git a/libcc2rs/rust-toolchain.toml b/libcc2rs/rust-toolchain.toml deleted file mode 100644 index f25b5b14..00000000 --- a/libcc2rs/rust-toolchain.toml +++ /dev/null @@ -1,2 +0,0 @@ -[toolchain] -channel = "1.95.0" diff --git a/rule-preprocessor/rust-toolchain.toml b/rule-preprocessor/rust-toolchain.toml index a2476a8e..5d993c2c 100644 --- a/rule-preprocessor/rust-toolchain.toml +++ b/rule-preprocessor/rust-toolchain.toml @@ -1,3 +1,2 @@ [toolchain] -channel = "nightly-2026-03-25" components = ["rustc-dev", "llvm-tools"] diff --git a/rules/rust-toolchain.toml b/rules/rust-toolchain.toml deleted file mode 100644 index f25b5b14..00000000 --- a/rules/rust-toolchain.toml +++ /dev/null @@ -1,2 +0,0 @@ -[toolchain] -channel = "1.95.0" From 0ef4dd404b6fd31ecec6ede89e9933c9c54b976a Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 13 May 2026 22:22:55 +0100 Subject: [PATCH 2/9] edits --- CMakeLists.txt | 3 ++- rule-preprocessor/rust-toolchain.toml | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 rule-preprocessor/rust-toolchain.toml diff --git a/CMakeLists.txt b/CMakeLists.txt index e7f6d258..293579af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,7 +185,8 @@ add_custom_command( COMMAND cargo +${RUST_STABLE_VERSION} build --release --manifest-path "${PROJECT_SOURCE_DIR}/rules/Cargo.toml" COMMAND ${CMAKE_COMMAND} -E env CARGO_TARGET_DIR="${CMAKE_CURRENT_BINARY_DIR}/target_preprocessor" - cargo +nightly-2026-05-13 run --manifest-path "${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml" + cargo +nightly-2026-05-13 run --component rustc-dev + --manifest-path "${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml" DEPENDS ${rust_rules_inputs} ${rule_preprocessor_sources} "${RUST_STAMP_FILE}" VERBATIM ) diff --git a/rule-preprocessor/rust-toolchain.toml b/rule-preprocessor/rust-toolchain.toml deleted file mode 100644 index 5d993c2c..00000000 --- a/rule-preprocessor/rust-toolchain.toml +++ /dev/null @@ -1,2 +0,0 @@ -[toolchain] -components = ["rustc-dev", "llvm-tools"] From bb73cc5621e515e97a1d82fec9697876d86c224e Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 13 May 2026 22:24:30 +0100 Subject: [PATCH 3/9] edits --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 293579af..52108f70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ set(RUST_STAMP_FILE "${CMAKE_BINARY_DIR}/.rust-toolchain.stamp") add_custom_command( OUTPUT "${RUST_STAMP_FILE}" COMMAND rustup toolchain install ${RUST_STABLE_VERSION} + COMMAND rustup toolchain install nightly-2026-05-13 --component rustc-dev COMMAND ${CMAKE_COMMAND} -E touch "${RUST_STAMP_FILE}" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake" USES_TERMINAL @@ -185,8 +186,7 @@ add_custom_command( COMMAND cargo +${RUST_STABLE_VERSION} build --release --manifest-path "${PROJECT_SOURCE_DIR}/rules/Cargo.toml" COMMAND ${CMAKE_COMMAND} -E env CARGO_TARGET_DIR="${CMAKE_CURRENT_BINARY_DIR}/target_preprocessor" - cargo +nightly-2026-05-13 run --component rustc-dev - --manifest-path "${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml" + cargo +nightly-2026-05-13 run --manifest-path "${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml" DEPENDS ${rust_rules_inputs} ${rule_preprocessor_sources} "${RUST_STAMP_FILE}" VERBATIM ) From 14e4f1e3f7a115cb8f831f372a6d6e4d16bbb52c Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 13 May 2026 22:25:36 +0100 Subject: [PATCH 4/9] edits --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52108f70..ca1489ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ set(RUST_STAMP_FILE "${CMAKE_BINARY_DIR}/.rust-toolchain.stamp") add_custom_command( OUTPUT "${RUST_STAMP_FILE}" COMMAND rustup toolchain install ${RUST_STABLE_VERSION} - COMMAND rustup toolchain install nightly-2026-05-13 --component rustc-dev + COMMAND rustup toolchain install nightly-2026-05-13 --component rustc-dev --component llvm-tools COMMAND ${CMAKE_COMMAND} -E touch "${RUST_STAMP_FILE}" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake" USES_TERMINAL From f39186d6e65ad94f9f9a9f8bf8f25ca2978f9d75 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 13 May 2026 22:27:59 +0100 Subject: [PATCH 5/9] edits --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca1489ff..425c45f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,11 +65,12 @@ endif() include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake) set(RUST_STAMP_FILE "${CMAKE_BINARY_DIR}/.rust-toolchain.stamp") +set(RUST_NIGHTLY_VERSION nightly-2026-05-13) add_custom_command( OUTPUT "${RUST_STAMP_FILE}" COMMAND rustup toolchain install ${RUST_STABLE_VERSION} - COMMAND rustup toolchain install nightly-2026-05-13 --component rustc-dev --component llvm-tools + COMMAND rustup toolchain install ${RUST_NIGHTLY_VERSION} --component rustc-dev --component llvm-tools COMMAND ${CMAKE_COMMAND} -E touch "${RUST_STAMP_FILE}" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake" USES_TERMINAL @@ -186,7 +187,7 @@ add_custom_command( COMMAND cargo +${RUST_STABLE_VERSION} build --release --manifest-path "${PROJECT_SOURCE_DIR}/rules/Cargo.toml" COMMAND ${CMAKE_COMMAND} -E env CARGO_TARGET_DIR="${CMAKE_CURRENT_BINARY_DIR}/target_preprocessor" - cargo +nightly-2026-05-13 run --manifest-path "${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml" + cargo +${RUST_NIGHTLY_VERSION} run --manifest-path "${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml" DEPENDS ${rust_rules_inputs} ${rule_preprocessor_sources} "${RUST_STAMP_FILE}" VERBATIM ) From 33523483eb5ee53f08cb6276c9631cb7e75938d1 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 13 May 2026 22:29:20 +0100 Subject: [PATCH 6/9] edits --- CMakeLists.txt | 1 - cmake/rust-toolchain.cmake | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 425c45f0..e16dda8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,6 @@ endif() include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake) set(RUST_STAMP_FILE "${CMAKE_BINARY_DIR}/.rust-toolchain.stamp") -set(RUST_NIGHTLY_VERSION nightly-2026-05-13) add_custom_command( OUTPUT "${RUST_STAMP_FILE}" diff --git a/cmake/rust-toolchain.cmake b/cmake/rust-toolchain.cmake index 21762a3a..60a4cadf 100644 --- a/cmake/rust-toolchain.cmake +++ b/cmake/rust-toolchain.cmake @@ -1 +1,2 @@ set(RUST_STABLE_VERSION "1.95.0") +set(RUST_NIGHTLY_VERSION "nightly-2026-05-13") From a4d44cd57f9ba1ac0273752603118c7119566364 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 13 May 2026 22:38:08 +0100 Subject: [PATCH 7/9] edits --- .github/workflows/run-tests.yml | 3 --- tests/lit/lit/formats/Cpp2RustTest.py | 16 ++++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d480451b..95c5e402 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -44,9 +44,6 @@ jobs: with: python-version: '3.x' - - name: Install Python dependencies - run: pip install tomli - - name: Configure run: | mkdir build && cd build diff --git a/tests/lit/lit/formats/Cpp2RustTest.py b/tests/lit/lit/formats/Cpp2RustTest.py index 717ba3fd..684502b9 100644 --- a/tests/lit/lit/formats/Cpp2RustTest.py +++ b/tests/lit/lit/formats/Cpp2RustTest.py @@ -9,15 +9,18 @@ import re import shutil import random -import tomli def read_rust_version(): toolchain_path = os.path.join( - os.path.dirname(__file__), "../../../../libcc2rs/rust-toolchain.toml" + os.path.dirname(__file__), "../../../../cmake/rust-toolchain.cmake" ) - with open(toolchain_path, "rb") as f: - return tomli.load(f)["toolchain"]["channel"] + with open(toolchain_path, "r") as f: + for line in f: + m = re.match(r'set\s*\(\s*RUST_VERSION\s+"([^"]+)', line) + if m: + return m.group(1) + raise Exception("could not find rust version in " + toolchain_path) def shared_target_dir(): @@ -170,15 +173,12 @@ def fail(str, code=fail_code): pkg_name = "test_" + re.sub(r"[^a-zA-Z0-9_]", "_", os.path.basename(tmp_dir)) # Check if we can compile the rust file - with open(tmp_dir + "/rust-toolchain.toml", "w") as f: - f.write(f'[toolchain]\nchannel = "{self.rust_version}"\n') with open(tmp_dir + "/Cargo.toml", "w") as f: f.write(f""" [package] name = "{pkg_name}" version = "0.1.0" edition = "2021" -rust-version = "{self.rust_version}" [[bin]] name = "{pkg_name}" @@ -189,7 +189,7 @@ def fail(str, code=fail_code): libcc2rs = {{ path = "../../../libcc2rs" }} """) - cmd = ["cargo", "build", "--release", "--quiet"] + cmd = ["cargo", "+" + self.rust_version, "build", "--release", "--quiet"] _, err, returncode = lit.util.executeCommand(cmd, tmp_dir, env=cargo_env()) if should_not_compile: if returncode != 0: From 09af4df350845a6b2b3ef62c1adf114f72760ce1 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 13 May 2026 22:40:49 +0100 Subject: [PATCH 8/9] edits --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 522a1260..5e51854b 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,7 @@ while satisfying Rust's borrow checker through checked run-time operations. On Ubuntu, install the required dependencies with: ```bash -sudo apt install libclang-22-dev clang++-22 ninja-build cmake python3-tomli -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.95.0 +sudo apt install libclang-22-dev clang++-22 ninja-build cmake curl -LsSf https://astral.sh/ruff/install.sh | sh ``` From 55f0b521060b6ce7893a823f896f499cf280b164 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 14 May 2026 11:09:01 +0100 Subject: [PATCH 9/9] edits --- tests/lit/lit/formats/Cpp2RustTest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lit/lit/formats/Cpp2RustTest.py b/tests/lit/lit/formats/Cpp2RustTest.py index 684502b9..c6375902 100644 --- a/tests/lit/lit/formats/Cpp2RustTest.py +++ b/tests/lit/lit/formats/Cpp2RustTest.py @@ -17,7 +17,7 @@ def read_rust_version(): ) with open(toolchain_path, "r") as f: for line in f: - m = re.match(r'set\s*\(\s*RUST_VERSION\s+"([^"]+)', line) + m = re.match(r'set\(RUST_STABLE_VERSION\s+"([^"]+)', line) if m: return m.group(1) raise Exception("could not find rust version in " + toolchain_path)