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
4 changes: 2 additions & 2 deletions cmake/rust-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -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")
4 changes: 3 additions & 1 deletion libc-dep/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
Expand Down
4 changes: 3 additions & 1 deletion libcc2rs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion rule-preprocessor/src/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::compiler_entrypoint(&args, &mut resolver);
})
.is_err()
{
Expand Down
49 changes: 22 additions & 27 deletions tests/lit/lit/formats/Cpp2RustTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand All @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
Loading