Skip to content
Closed
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
14 changes: 10 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,14 +499,17 @@ impl Build {
let obj = out_dir.join("flag_check");
let target = self.get_target()?;
let host = self.get_host()?;

let mut cfg = Build::new();
cfg.flag(flag)
.target(&target)
.opt_level(0)
.host(&host)
.debug(false)
.cpp(self.cpp)
.cuda(self.cuda);
.cuda(self.cuda)
.warnings_into_errors(true);

if let Some(ref c) = self.compiler {
cfg.compiler(c.clone());
}
Expand Down Expand Up @@ -537,10 +540,13 @@ impl Build {
cmd.arg("-c");
}

cmd.arg(&src);
cmd.arg(&src)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null());
Comment on lines +543 to +546
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we inherit stdout and stderr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should not, since stdout and stderr is for messages from compiler when building the project.
Build::is_flag_supported does not build the project but only test the flags, so I think the stdout and stderr should be piped to null.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we don't provide any other mechanism for the developer to check why a test failed, unlike other build systems that write the output of all these checks/tests to a log file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we don't provide any other mechanism for the developer to check why a test failed, unlike other build systems that write the output of all these checks/tests to a log file.

Ehh that's true, I can set that to inherit but I think the stdout/stderr might be a little bit confusing to users.
If that's fine, then I can remove these lines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s wait for another opinion? That was just my two cents.


let output = cmd.output()?;
let is_supported = output.status.success() && output.stderr.is_empty();
let status = cmd.status()?;
let is_supported = status.success();

known_status.insert(flag.to_owned(), is_supported);
Ok(is_supported)
Expand Down
4 changes: 2 additions & 2 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ mod support;
// CFLAGS or CXXFLAGS environment variables. This function clears the CFLAGS and CXXFLAGS
// variables to make sure that the tests can run correctly.
fn reset_env() {
std::env::set_var("CFLAGS", "");
std::env::set_var("CXXFLAGS", "");
std::env::remove_var("CFLAGS");
std::env::remove_var("CXXFLAGS");
}

#[test]
Expand Down