Skip to content

Commit fae4d47

Browse files
authored
build: Use temporary file for can_compile (#1497)
The can_compile function in build.rs previously invoked rustc with -o -, which causes rustc to attempt to create a temporary metadata directory in the current working directory. When building with Portage for ChromeOS, this happens in a sandbox where the current working directory is not writeable, resulting in a sandbox access violation. This change modifies the can_compile function to use a temporary directory for the output file. This forces rustc to create the temporary file in a writeable location, avoiding the sandbox issue.
1 parent cb1a89a commit fae4d47

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ fn can_compile<T: AsRef<str>>(test: T) -> bool {
258258
.arg("--target")
259259
.arg(target)
260260
.arg("-o")
261-
.arg("-")
261+
.arg(std::env::temp_dir().join("rustix_test_can_compile"))
262262
.stdout(Stdio::null()); // We don't care about the output (only whether it builds or not)
263263

264264
// If Cargo wants to set RUSTFLAGS, use that.

0 commit comments

Comments
 (0)