Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For non-MSVC, separate flags/options from the input file. (#513) #514

Merged
merged 1 commit into from May 11, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/lib.rs
Expand Up @@ -1171,6 +1171,13 @@ impl Build {
if !msvc || !is_asm || !is_arm {
cmd.arg("-c");
}
if compiler.family == (ToolFamily::Msvc { clang_cl: true }) {
// #513: For `clang-cl`, separate flags/options from the input file.
// When cross-compiling macOS -> Windows, this avoids interpreting
// common `/Users/...` paths as the `/U` flag and triggering
// `-Wslash-u-filename` warning.
cmd.arg("--");
}
cmd.arg(&obj.src);

run(&mut cmd, &name)?;
Expand Down
16 changes: 16 additions & 0 deletions tests/test.rs
Expand Up @@ -343,6 +343,14 @@ fn gnu_static() {
test.cmd(0).must_have("-static").must_not_have("-shared");
}

#[test]
fn gnu_no_dash_dash() {
let test = Test::gnu();
test.gcc().file("foo.c").compile("foo");

test.cmd(0).must_not_have("--");
}

#[test]
fn msvc_smoke() {
reset_env();
Expand Down Expand Up @@ -411,3 +419,11 @@ fn msvc_no_static_crt() {

test.cmd(0).must_have("-MD");
}

#[test]
fn msvc_no_dash_dash() {
let test = Test::msvc();
test.gcc().file("foo.c").compile("foo");

test.cmd(0).must_not_have("--");
}