-
Notifications
You must be signed in to change notification settings - Fork 550
fix llvm-ar as archiver for msvc targets; fix clang-cl detection; fix assembler output flag detection; add clang/clang-cl windows CI #1015
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
Changes from 7 commits
829e054
094d406
d388cb8
d737de1
9eff753
7c20d23
3da03c7
0571f2a
4581b26
c5c7562
ea91a79
0ec9ca3
d44e733
8b7ed60
e022679
4c5260a
9d35dcd
ba42c16
d69c416
975a9d7
6237e2e
f573a66
6e72ff5
ad8d072
940bc3e
2c41d81
ff0f7af
fe5ae81
fd6b59a
80a2f81
006ac81
eed65b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2398,7 +2398,8 @@ impl Build { | |
| } | ||
|
|
||
| let target = self.get_target()?; | ||
| if target.contains("msvc") { | ||
| let (mut ar, cmd, _any_flags) = self.get_ar()?; | ||
| if target.contains("msvc") && !cmd.to_string_lossy().contains("llvm-") { | ||
| // The Rust compiler will look for libfoo.a and foo.lib, but the | ||
| // MSVC linker will also be passed foo.lib, so be sure that both | ||
| // exist for now. | ||
|
|
@@ -2421,7 +2422,6 @@ impl Build { | |
| // Non-msvc targets (those using `ar`) need a separate step to add | ||
| // the symbol table to archives since our construction command of | ||
| // `cq` doesn't add it for us. | ||
| let (mut ar, cmd, _any_flags) = self.get_ar()?; | ||
|
|
||
| // NOTE: We add `s` even if flags were passed using $ARFLAGS/ar_flag, because `s` | ||
| // here represents a _mode_, not an arbitrary flag. Further discussion of this choice | ||
|
|
@@ -2435,8 +2435,8 @@ impl Build { | |
| fn assemble_progressive(&self, dst: &Path, objs: &[&Path]) -> Result<(), Error> { | ||
| let target = self.get_target()?; | ||
|
|
||
| if target.contains("msvc") { | ||
| let (mut cmd, program, any_flags) = self.get_ar()?; | ||
| let (mut cmd, program, any_flags) = self.get_ar()?; | ||
| if target.contains("msvc") && !program.to_string_lossy().contains("llvm-") { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will probably need adjusting but for now is fine. |
||
| // NOTE: -out: here is an I/O flag, and so must be included even if $ARFLAGS/ar_flag is | ||
| // in use. -nologo on the other hand is just a regular flag, and one that we'll skip if | ||
| // the caller has explicitly dictated the flags they want. See | ||
|
|
@@ -2455,8 +2455,6 @@ impl Build { | |
| cmd.args(objs); | ||
| run(&mut cmd, &program, &self.cargo_output)?; | ||
| } else { | ||
| let (mut ar, cmd, _any_flags) = self.get_ar()?; | ||
|
|
||
| // Set an environment variable to tell the OSX archiver to ensure | ||
| // that all dates listed in the archive are zero, improving | ||
| // determinism of builds. AFAIK there's not really official | ||
|
|
@@ -2479,12 +2477,16 @@ impl Build { | |
| // | ||
| // In any case if this doesn't end up getting read, it shouldn't | ||
| // cause that many issues! | ||
| ar.env("ZERO_AR_DATE", "1"); | ||
| cmd.env("ZERO_AR_DATE", "1"); | ||
|
|
||
| // NOTE: We add cq here regardless of whether $ARFLAGS/ar_flag have been used because | ||
| // it dictates the _mode_ ar runs in, which the setter of $ARFLAGS/ar_flag can't | ||
| // dictate. See https://github.com/rust-lang/cc-rs/pull/763 for further discussion. | ||
| run(ar.arg("cq").arg(dst).args(objs), &cmd, &self.cargo_output)?; | ||
| run( | ||
| cmd.arg("cq").arg(dst).args(objs), | ||
| &program, | ||
| &self.cargo_output, | ||
| )?; | ||
| } | ||
|
|
||
| Ok(()) | ||
|
|
@@ -3124,12 +3126,17 @@ impl Build { | |
| Ok(self.get_base_archiver_variant("RANLIB", "ranlib")?.0) | ||
| } | ||
|
|
||
| fn get_base_archiver_variant(&self, env: &str, tool: &str) -> Result<(Command, String), Error> { | ||
| fn get_base_archiver_variant( | ||
| &self, | ||
| env: &str, | ||
| tool: &str, | ||
| ) -> Result<(Command, PathBuf), Error> { | ||
| let target = self.get_target()?; | ||
| let mut name = String::new(); | ||
| let mut name = PathBuf::new(); | ||
| let tool_opt: Option<Command> = self | ||
| .env_tool(env) | ||
| .map(|(tool, _wrapper, args)| { | ||
| name = tool.clone(); | ||
| let mut cmd = self.cmd(tool); | ||
| cmd.args(args); | ||
| cmd | ||
|
|
@@ -3139,11 +3146,11 @@ impl Build { | |
| // Windows use bat files so we have to be a bit more specific | ||
| if cfg!(windows) { | ||
| let mut cmd = self.cmd("cmd"); | ||
| name = format!("em{}.bat", tool); | ||
| name = format!("em{}.bat", tool).into(); | ||
| cmd.arg("/c").arg(&name); | ||
| Some(cmd) | ||
| } else { | ||
| name = format!("em{}", tool); | ||
| name = format!("em{}", tool).into(); | ||
| Some(self.cmd(&name)) | ||
| } | ||
| } else if target.starts_with("wasm32") { | ||
|
|
@@ -3154,7 +3161,7 @@ impl Build { | |
| // of "llvm-ar"... | ||
| let compiler = self.get_base_compiler().ok()?; | ||
| if compiler.is_like_clang() { | ||
| name = format!("llvm-{}", tool); | ||
| name = format!("llvm-{}", tool).into(); | ||
| search_programs(&mut self.cmd(&compiler.path), &name, &self.cargo_output) | ||
| .map(|name| self.cmd(name)) | ||
| } else { | ||
|
|
@@ -3170,10 +3177,10 @@ impl Build { | |
| Some(t) => t, | ||
| None => { | ||
| if target.contains("android") { | ||
| name = format!("llvm-{}", tool); | ||
| name = format!("llvm-{}", tool).into(); | ||
| match Command::new(&name).arg("--version").status() { | ||
| Ok(status) if status.success() => (), | ||
| _ => name = format!("{}-{}", target.replace("armv7", "arm"), tool), | ||
| _ => name = format!("{}-{}", target.replace("armv7", "arm"), tool).into(), | ||
| } | ||
| self.cmd(&name) | ||
| } else if target.contains("msvc") { | ||
|
|
@@ -3200,7 +3207,7 @@ impl Build { | |
| } | ||
|
|
||
| if lib.is_empty() { | ||
| name = String::from("lib.exe"); | ||
| name = PathBuf::from("lib.exe"); | ||
| let mut cmd = match windows_registry::find(&target, "lib.exe") { | ||
| Some(t) => t, | ||
| None => self.cmd("lib.exe"), | ||
|
|
@@ -3210,15 +3217,15 @@ impl Build { | |
| } | ||
| cmd | ||
| } else { | ||
| name = lib; | ||
| name = lib.into(); | ||
| self.cmd(&name) | ||
| } | ||
| } else if target.contains("illumos") { | ||
| // The default 'ar' on illumos uses a non-standard flags, | ||
| // but the OS comes bundled with a GNU-compatible variant. | ||
| // | ||
| // Use the GNU-variant to match other Unix systems. | ||
| name = format!("g{}", tool); | ||
| name = format!("g{}", tool).into(); | ||
| self.cmd(&name) | ||
| } else if self.get_host()? != target { | ||
| match self.prefix_for_target(&target) { | ||
|
|
@@ -3238,16 +3245,16 @@ impl Build { | |
| break; | ||
| } | ||
| } | ||
| name = chosen; | ||
| name = chosen.into(); | ||
| self.cmd(&name) | ||
| } | ||
| None => { | ||
| name = default; | ||
| name = default.into(); | ||
| self.cmd(&name) | ||
| } | ||
| } | ||
| } else { | ||
| name = default; | ||
| name = default.into(); | ||
| self.cmd(&name) | ||
| } | ||
| } | ||
|
|
@@ -3939,7 +3946,7 @@ fn which(tool: &Path, path_entries: Option<OsString>) -> Option<PathBuf> { | |
| } | ||
|
|
||
| // search for |prog| on 'programs' path in '|cc| -print-search-dirs' output | ||
| fn search_programs(cc: &mut Command, prog: &str, cargo_output: &CargoOutput) -> Option<PathBuf> { | ||
| fn search_programs(cc: &mut Command, prog: &Path, cargo_output: &CargoOutput) -> Option<PathBuf> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally the change to use &Path would be in a different pr. But I'm not about to hold this up for that, since it is a good change. |
||
| let search_dirs = run_output( | ||
| cc.arg("-print-search-dirs"), | ||
| "cc", | ||
|
|
@@ -3952,7 +3959,7 @@ fn search_programs(cc: &mut Command, prog: &str, cargo_output: &CargoOutput) -> | |
| let search_dirs = std::str::from_utf8(&search_dirs).ok()?; | ||
| for dirs in search_dirs.split(|c| c == '\r' || c == '\n') { | ||
| if let Some(path) = dirs.strip_prefix("programs: =") { | ||
| return which(Path::new(prog), Some(OsString::from(path))); | ||
| return which(prog, Some(OsString::from(path))); | ||
| } | ||
| } | ||
| None | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.