Skip to content

Commit 5a1a756

Browse files
Fix compiletest run when using GCC as backend
1 parent ba3a448 commit 5a1a756

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,8 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17711771

17721772
if let Some(codegen_backend) = builder.config.codegen_backends(compiler.host).first() {
17731773
cmd.arg("--codegen-backend").arg(codegen_backend);
1774-
} else if let Some(codegen_backend) = builder.config.default_codegen_backend(compiler.host) {
1774+
} else if let Some(codegen_backend) = builder.config.default_codegen_backend(compiler.host)
1775+
{
17751776
cmd.arg("--codegen-backend").arg(&codegen_backend);
17761777
}
17771778

@@ -1919,6 +1920,11 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
19191920
cmd.arg(exclude);
19201921
}
19211922

1923+
if builder.config.codegen_backends(target).first().map(|b| b.as_str()) == Some("gcc") {
1924+
cmd.arg("--extra-library-path");
1925+
cmd.arg(builder.config.libgccjit_root());
1926+
}
1927+
19221928
// Get paths from cmd args
19231929
let paths = match &builder.config.cmd {
19241930
Subcommand::Test { .. } => &builder.config.paths[..],

src/tools/compiletest/src/common.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,9 @@ pub struct Config {
684684

685685
/// Current codegen backend used.
686686
pub codegen_backend: CodegenBackend,
687+
688+
/// Only used by GCC codegen backend for now. It is used to pass `libgccjit.so`'s path.
689+
pub extra_library_path: Option<Utf8PathBuf>,
687690
}
688691

689692
impl Config {
@@ -787,6 +790,7 @@ impl Config {
787790
diff_command: Default::default(),
788791
minicore_path: Default::default(),
789792
codegen_backend: CodegenBackend::Llvm,
793+
extra_library_path: None,
790794
}
791795
}
792796

@@ -1151,7 +1155,11 @@ fn supported_crate_types(config: &Config) -> HashSet<String> {
11511155

11521156
fn rustc_output(config: &Config, args: &[&str], envs: HashMap<String, String>) -> String {
11531157
let mut command = Command::new(&config.rustc_path);
1154-
add_dylib_path(&mut command, iter::once(&config.compile_lib_path));
1158+
if let Some(ref extra_lib) = config.extra_library_path {
1159+
add_dylib_path(&mut command, [&config.compile_lib_path, &extra_lib].iter());
1160+
} else {
1161+
add_dylib_path(&mut command, iter::once(&config.compile_lib_path));
1162+
}
11551163
command.args(&config.target_rustcflags).args(args);
11561164
command.env("RUSTC_BOOTSTRAP", "1");
11571165
command.envs(envs);

src/tools/compiletest/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
204204
"only test a specific debugger in debuginfo tests",
205205
"gdb | lldb | cdb",
206206
)
207+
.optopt("", "codegen-backend", "the codegen backend currently used", "CODEGEN BACKEND NAME")
207208
.optopt(
208209
"",
209-
"codegen-backend",
210-
"the codegen backend currently used",
211-
"CODEGEN BACKEND NAME",
210+
"extra-library-path",
211+
"extra path to be passed into LIBRARY_PATH environment variable",
212+
"library path",
212213
);
213214

214215
let (argv0, args_) = args.split_first().unwrap();
@@ -466,6 +467,10 @@ pub fn parse_config(args: Vec<String>) -> Config {
466467
minicore_path: opt_path(matches, "minicore-path"),
467468

468469
codegen_backend,
470+
471+
extra_library_path: matches
472+
.opt_str("extra-library-path")
473+
.map(|p| make_absolute(Utf8PathBuf::from(p))),
469474
}
470475
}
471476

0 commit comments

Comments
 (0)