From 7a7a4f8ce87dfbf47eb741ecaaaabfb94fb3bb4d Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 12 Nov 2026 21:55:16 +0000 Subject: [PATCH 1/4] Update to Rust 1.100 --- cmake/rust-toolchain.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/rust-toolchain.cmake b/cmake/rust-toolchain.cmake index 3e04f1fde4..f809d8c920 100644 --- a/cmake/rust-toolchain.cmake +++ b/cmake/rust-toolchain.cmake @@ -1,2 +1,2 @@ -set(RUST_STABLE_VERSION "1.99.0") -set(RUST_NIGHTLY_VERSION "nightly-2026-10-01") +set(RUST_STABLE_VERSION "1.100.0") +set(RUST_NIGHTLY_VERSION "nightly-2026-11-11") From 97c166c518b0d982cac73fd310ff81e095197cc5 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 12 Nov 2026 22:18:33 +0000 Subject: [PATCH 2/4] fix --- rule-preprocessor/src/semantic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rule-preprocessor/src/semantic.rs b/rule-preprocessor/src/semantic.rs index 00f8518d7d..fa25d08a11 100644 --- a/rule-preprocessor/src/semantic.rs +++ b/rule-preprocessor/src/semantic.rs @@ -14,7 +14,7 @@ impl SemanticAnalysis { let mut resolver = MethodResolver { ir }; if rustc_driver::catch_fatal_errors(|| { - rustc_driver::run_compiler(&args, &mut resolver); + rustc_driver::RunCompiler::new(&args, &mut resolver).run(); }) .is_err() { From 8edec337fc85a7bae87bc7a6af18c6df84396258 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Fri, 13 Nov 2026 08:00:41 +0000 Subject: [PATCH 3/4] fix --- rule-preprocessor/src/semantic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rule-preprocessor/src/semantic.rs b/rule-preprocessor/src/semantic.rs index fa25d08a11..10c856a7cc 100644 --- a/rule-preprocessor/src/semantic.rs +++ b/rule-preprocessor/src/semantic.rs @@ -14,7 +14,7 @@ impl SemanticAnalysis { let mut resolver = MethodResolver { ir }; if rustc_driver::catch_fatal_errors(|| { - rustc_driver::RunCompiler::new(&args, &mut resolver).run(); + rustc_driver::compiler_entrypoint(&args, &mut resolver); }) .is_err() { From 2ff88475cc471d05c6167127b5bd0437338b17c1 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Fri, 13 Nov 2026 08:19:17 +0000 Subject: [PATCH 4/4] fix --- libc-dep/CMakeLists.txt | 4 ++- libcc2rs/CMakeLists.txt | 4 ++- tests/lit/lit/formats/Cpp2RustTest.py | 49 ++++++++++++--------------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/libc-dep/CMakeLists.txt b/libc-dep/CMakeLists.txt index 2308b869e0..bee25f49f1 100644 --- a/libc-dep/CMakeLists.txt +++ b/libc-dep/CMakeLists.txt @@ -1,9 +1,11 @@ set(LIBC_DEP_DIR ${CMAKE_SOURCE_DIR}/libc-dep) set(LIBC_DEP_OUTPUT ${CMAKE_BINARY_DIR}/libc-dep-target/release/liblibc_dep.rlib) +set(LIBC_DEP_ARTIFACTS ${CMAKE_BINARY_DIR}/libc-dep-target/artifacts.json) add_custom_command( - OUTPUT ${LIBC_DEP_OUTPUT} + OUTPUT ${LIBC_DEP_OUTPUT} ${LIBC_DEP_ARTIFACTS} COMMAND ${CARGO_ENV_LIBC_DEP} cargo +${RUST_STABLE_VERSION} build --release + --message-format=json-render-diagnostics > ${LIBC_DEP_ARTIFACTS} WORKING_DIRECTORY ${LIBC_DEP_DIR} DEPENDS "${RUST_STAMP_FILE}" ${LIBC_DEP_DIR}/Cargo.toml ) diff --git a/libcc2rs/CMakeLists.txt b/libcc2rs/CMakeLists.txt index 39acc31bba..794bb1e814 100644 --- a/libcc2rs/CMakeLists.txt +++ b/libcc2rs/CMakeLists.txt @@ -1,14 +1,16 @@ set(LIBCC2RC_LIB_DIR ${CMAKE_SOURCE_DIR}/libcc2rs) set(LIBCC2RC_MACROS_LIB_DIR ${CMAKE_SOURCE_DIR}/libcc2rs-macros) set(LIBCC2RS_RLIB ${CMAKE_BINARY_DIR}/libcc2rs-target/release/liblibcc2rs.rlib) +set(LIBCC2RS_ARTIFACTS ${CMAKE_BINARY_DIR}/libcc2rs-target/artifacts.json) set(LIBCC2RS_MACROS_RLIB ${CMAKE_BINARY_DIR}/libcc2rs-macros-target/release/liblibcc2rs-macros.rlib) file(GLOB_RECURSE LIBCC2RS_SOURCES "${LIBCC2RC_LIB_DIR}/src/*.rs") file(GLOB_RECURSE LIBCC2RS_MACROS_SOURCES "${LIBCC2RC_MACROS_LIB_DIR}/src/*.rs") file(GLOB LIBCC2RS_RULE_SHIMS CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/rules/*/shim.rs") add_custom_command( - OUTPUT ${LIBCC2RS_RLIB} + OUTPUT ${LIBCC2RS_RLIB} ${LIBCC2RS_ARTIFACTS} COMMAND ${CARGO_ENV_LIBCC2RS} cargo +${RUST_STABLE_VERSION} build --release + --message-format=json-render-diagnostics > ${LIBCC2RS_ARTIFACTS} WORKING_DIRECTORY ${LIBCC2RC_LIB_DIR} DEPENDS "${RUST_STAMP_FILE}" diff --git a/tests/lit/lit/formats/Cpp2RustTest.py b/tests/lit/lit/formats/Cpp2RustTest.py index 5e77edae55..533c0c8c50 100644 --- a/tests/lit/lit/formats/Cpp2RustTest.py +++ b/tests/lit/lit/formats/Cpp2RustTest.py @@ -9,6 +9,8 @@ from pathlib import Path from typing import NamedTuple, Optional import difflib +import functools +import json import os import re import shlex @@ -217,21 +219,7 @@ def build_cpp(self): def build_rust(self): exp = self.expectations - cc2rs_dir = BUILD_DIR / "libcc2rs-target" / "release" - libc_dep_deps = BUILD_DIR / "libc-dep-target" / "release" / "deps" - # pick the most recently compiled libc - libc_rlib = max( - libc_dep_deps.glob("liblibc-*.rlib"), - key=lambda p: p.stat().st_mtime, - ) - nix_rlib = max( - libc_dep_deps.glob("libnix-*.rlib"), - key=lambda p: p.stat().st_mtime, - ) - jiff_rlib = max( - libc_dep_deps.glob("libjiff-*.rlib"), - key=lambda p: p.stat().st_mtime, - ) + libs = read_cargo_artifacts() cmd = [ "rustc", "+" + read_rust_version(), @@ -248,19 +236,11 @@ def build_rust(self): "panic=abort", "--out-dir", str(self.tmp_dir), - "-L", - f"dependency={cc2rs_dir / 'deps'}", - "-L", - f"dependency={libc_dep_deps}", - "--extern", - f"libcc2rs={cc2rs_dir / 'liblibcc2rs.rlib'}", - "--extern", - f"libc={libc_rlib}", - "--extern", - f"nix={nix_rlib}", - "--extern", - f"jiff={jiff_rlib}", ] + for lib_dir in sorted({p.parent for p in libs.values()}): + cmd += ["-L", f"dependency={lib_dir}"] + for crate in ("libcc2rs", "libc", "nix", "jiff"): + cmd += ["--extern", f"{crate}={libs[crate]}"] _, err, returncode = lit.util.executeCommand(cmd, str(self.tmp_dir)) if exp.should_not_compile: if returncode != 0: @@ -403,6 +383,21 @@ def read_rust_version(): raise Exception("could not find rust version in " + toolchain_path) +@functools.cache +def read_cargo_artifacts(): + libs = {} + for crate in ("libc-dep", "libcc2rs"): + path = BUILD_DIR / f"{crate}-target" / "artifacts.json" + for line in path.read_text().splitlines(): + msg = json.loads(line) + if msg.get("reason") != "compiler-artifact": + continue + for f in map(Path, msg["filenames"]): + if f.suffix in (".rlib", ".so", ".dylib"): + libs[msg["target"]["name"]] = f + return libs + + def get_temp_dir(): shm = Path("/dev/shm") if shm.exists() and os.access(shm, os.W_OK):