Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0ba1e0f

Browse files
committedJul 7, 2023
Fix standalone build
Add extern declarations and optional dependencies to fix build done directly via `cargo build`.
1 parent fd68a6d commit 0ba1e0f

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed
 

‎Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3949,6 +3949,7 @@ dependencies = [
39493949
"rustc_middle",
39503950
"rustc_span",
39513951
"scoped-tls",
3952+
"rustc_target",
39523953
"tracing",
39533954
]
39543955

‎compiler/rustc_smir/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ version = "0.0.0"
44
edition = "2021"
55

66
[dependencies]
7-
rustc_hir = { path = "../rustc_hir" }
7+
# Use optional dependencies for rustc_* in order to support building this crate separately.
8+
rustc_hir = { path = "../rustc_hir", optional = true }
89
rustc_middle = { path = "../rustc_middle", optional = true }
910
rustc_span = { path = "../rustc_span", optional = true }
11+
rustc_target = { path = "../rustc_target", optional = true }
1012
tracing = "0.1"
1113
scoped-tls = "1.0"
1214

1315
[features]
1416
default = [
17+
"rustc_hir",
1518
"rustc_middle",
1619
"rustc_span",
20+
"rustc_target",
1721
]
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2023-02-28"
2+
channel = "nightly-2023-06-14"
33
components = [ "rustfmt", "rustc-dev" ]

‎compiler/rustc_smir/src/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
#![feature(local_key_cell_methods)]
1515
#![feature(ptr_metadata)]
1616

17+
// Declare extern rustc_* crates to enable building this crate separately from the compiler.
18+
#[cfg(not(feature = "default"))]
19+
extern crate rustc_hir;
20+
#[cfg(not(feature = "default"))]
21+
extern crate rustc_middle;
22+
#[cfg(not(feature = "default"))]
23+
extern crate rustc_span;
24+
#[cfg(not(feature = "default"))]
25+
extern crate rustc_target;
26+
1727
pub mod rustc_internal;
1828
pub mod stable_mir;
1929

0 commit comments

Comments
 (0)
Please sign in to comment.