diff options
Diffstat (limited to 'vendor/cc')
-rw-r--r-- | vendor/cc/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/cc/Cargo.lock | 2 | ||||
-rw-r--r-- | vendor/cc/Cargo.toml | 2 | ||||
-rw-r--r-- | vendor/cc/src/lib.rs | 67 | ||||
-rw-r--r-- | vendor/cc/tests/test.rs | 42 |
5 files changed, 103 insertions, 12 deletions
diff --git a/vendor/cc/.cargo-checksum.json b/vendor/cc/.cargo-checksum.json index fb36f0442..1b81a54d2 100644 --- a/vendor/cc/.cargo-checksum.json +++ b/vendor/cc/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.lock":"6ff475c12a6d2bbc578d694793d0590a2c5132e46f511eb8896532ff22b570c3","Cargo.toml":"94b3fa599de37079bddec0afce9a86ec285ebf1eca8ef4134597bc8f840ea37e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"58af5106352aafa62175a90f8a5f25fa114028bf909220dc0735d79745999ec1","src/bin/gcc-shim.rs":"b77907875029494b6288841c3aed2e4939ed40708c7f597fca5c9e2570490ca6","src/com.rs":"29d0dee08a656ab1a4cc3e5fe24542e0fab5c1373cbc9b05059f7572cf9b8313","src/lib.rs":"209c8351f1db1e3ce2fdd2ac487dbe7849f5d3a7bfade054877270b6f4782232","src/registry.rs":"98ae2b71781acc49297e5544fa0cf059f735636f8f1338edef8dbf7232443945","src/setup_config.rs":"72deaf1927c0b713fd5c2b2d5b8f0ea3a303a00fda1579427895cac26a94122d","src/vs_instances.rs":"2d3f8278a803b0e7052f4eeb1979b29f963dd0143f4458e2cb5f33c4e5f0963b","src/winapi.rs":"e128e95b2d39ae7a02f54a7e25d33c488c14759b9f1a50a449e10545856950c3","src/windows_registry.rs":"c0340379c1f540cf96f45bbd4cf8fc28db555826f30ac937b75b87e4377b716b","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"a3c8d116973bb16066bf6ec4de5143183f97de7aad085d85f8118a2eaac3e1e0","tests/test.rs":"3e91f8de57aeae2c74bbb35fc14df8323220cdcbd0da3bde80274519c8779216"},"package":"76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f"}
\ No newline at end of file +{"files":{"Cargo.lock":"35e9b5c9b3f3c70765a2749ea977aa0b2c8f5ce8872afbd4a5ba7cd59befba6a","Cargo.toml":"129464bf762db9e7db00f3e80d4b702b8c69a6e5fab070db0c8e66d4f693765e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"58af5106352aafa62175a90f8a5f25fa114028bf909220dc0735d79745999ec1","src/bin/gcc-shim.rs":"b77907875029494b6288841c3aed2e4939ed40708c7f597fca5c9e2570490ca6","src/com.rs":"29d0dee08a656ab1a4cc3e5fe24542e0fab5c1373cbc9b05059f7572cf9b8313","src/lib.rs":"2403bbe39ff511ea5a517c0841d825173a4fdc8a0899c64282bba49127f0dc33","src/registry.rs":"98ae2b71781acc49297e5544fa0cf059f735636f8f1338edef8dbf7232443945","src/setup_config.rs":"72deaf1927c0b713fd5c2b2d5b8f0ea3a303a00fda1579427895cac26a94122d","src/vs_instances.rs":"2d3f8278a803b0e7052f4eeb1979b29f963dd0143f4458e2cb5f33c4e5f0963b","src/winapi.rs":"e128e95b2d39ae7a02f54a7e25d33c488c14759b9f1a50a449e10545856950c3","src/windows_registry.rs":"c0340379c1f540cf96f45bbd4cf8fc28db555826f30ac937b75b87e4377b716b","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"a3c8d116973bb16066bf6ec4de5143183f97de7aad085d85f8118a2eaac3e1e0","tests/test.rs":"61fb35ae6dd5cf506ada000bdd82c92e9f8eac9cc053b63e83d3f897436fbf8f"},"package":"e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"}
\ No newline at end of file diff --git a/vendor/cc/Cargo.lock b/vendor/cc/Cargo.lock index fc1a6596d..c9564008e 100644 --- a/vendor/cc/Cargo.lock +++ b/vendor/cc/Cargo.lock @@ -10,7 +10,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "cc" -version = "1.0.76" +version = "1.0.77" dependencies = [ "jobserver", "tempfile", diff --git a/vendor/cc/Cargo.toml b/vendor/cc/Cargo.toml index 7be741e1e..4ec5fa658 100644 --- a/vendor/cc/Cargo.toml +++ b/vendor/cc/Cargo.toml @@ -12,7 +12,7 @@ [package] edition = "2018" name = "cc" -version = "1.0.76" +version = "1.0.77" authors = ["Alex Crichton <alex@alexcrichton.com>"] exclude = ["/.github"] description = """ diff --git a/vendor/cc/src/lib.rs b/vendor/cc/src/lib.rs index a89e35318..486d67e0b 100644 --- a/vendor/cc/src/lib.rs +++ b/vendor/cc/src/lib.rs @@ -97,6 +97,7 @@ pub struct Build { flags_supported: Vec<String>, known_flag_support_status: Arc<Mutex<HashMap<String, bool>>>, ar_flags: Vec<String>, + asm_flags: Vec<String>, no_default_flags: bool, files: Vec<PathBuf>, cpp: bool, @@ -214,13 +215,17 @@ enum ToolFamily { impl ToolFamily { /// What the flag to request debug info for this family of tools look like - fn add_debug_flags(&self, cmd: &mut Tool) { + fn add_debug_flags(&self, cmd: &mut Tool, dwarf_version: Option<u32>) { match *self { ToolFamily::Msvc { .. } => { cmd.push_cc_arg("-Z7".into()); } ToolFamily::Gnu | ToolFamily::Clang => { - cmd.push_cc_arg("-g".into()); + cmd.push_cc_arg( + dwarf_version + .map_or_else(|| "-g".into(), |v| format!("-gdwarf-{}", v)) + .into(), + ); } } } @@ -295,6 +300,7 @@ impl Build { flags_supported: Vec::new(), known_flag_support_status: Arc::new(Mutex::new(HashMap::new())), ar_flags: Vec::new(), + asm_flags: Vec::new(), no_default_flags: false, files: Vec::new(), shared_flag: None, @@ -430,6 +436,25 @@ impl Build { self } + /// Add a flag that will only be used with assembly files. + /// + /// The flag will be applied to input files with either a `.s` or + /// `.asm` extension (case insensitive). + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .asm_flag("-Wa,-defsym,abc=1") + /// .file("src/foo.S") // The asm flag will be applied here + /// .file("src/bar.c") // The asm flag will not be applied here + /// .compile("foo"); + /// ``` + pub fn asm_flag(&mut self, flag: &str) -> &mut Build { + self.asm_flags.push(flag.to_string()); + self + } + fn ensure_check_file(&self) -> Result<PathBuf, Error> { let out_dir = self.get_out_dir()?; let src = if self.cuda { @@ -1314,7 +1339,7 @@ impl Build { } fn compile_object(&self, obj: &Object) -> Result<(), Error> { - let is_asm = obj.src.extension().and_then(|s| s.to_str()) == Some("asm"); + let is_asm = is_asm(&obj.src); let target = self.get_target()?; let msvc = target.contains("msvc"); let compiler = self.try_get_compiler()?; @@ -1345,6 +1370,9 @@ impl Build { if self.cuda && self.files.len() > 1 { cmd.arg("--device-c"); } + if is_asm { + cmd.args(&self.asm_flags); + } if compiler.family == (ToolFamily::Msvc { clang_cl: true }) && !is_asm { // #513: For `clang-cl`, separate flags/options from the input file. // When cross-compiling macOS -> Windows, this avoids interpreting @@ -1589,7 +1617,7 @@ impl Build { cmd.args.push("-G".into()); } let family = cmd.family; - family.add_debug_flags(cmd); + family.add_debug_flags(cmd, self.get_dwarf_version()); } if self.get_force_frame_pointer() { @@ -2848,6 +2876,25 @@ impl Build { }) } + fn get_dwarf_version(&self) -> Option<u32> { + // Tentatively matches the DWARF version defaults as of rustc 1.62. + let target = self.get_target().ok()?; + if target.contains("android") + || target.contains("apple") + || target.contains("dragonfly") + || target.contains("freebsd") + || target.contains("netbsd") + || target.contains("openbsd") + || target.contains("windows-gnu") + { + Some(2) + } else if target.contains("linux") { + Some(4) + } else { + None + } + } + fn get_force_frame_pointer(&self) -> bool { self.force_frame_pointer.unwrap_or_else(|| self.get_debug()) } @@ -3448,3 +3495,15 @@ fn which(tool: &Path) -> Option<PathBuf> { return if check_exe(&mut exe) { Some(exe) } else { None }; }) } + +/// Check if the file's extension is either "asm" or "s", case insensitive. +fn is_asm(file: &Path) -> bool { + if let Some(ext) = file.extension() { + if let Some(ext) = ext.to_str() { + let ext = ext.to_lowercase(); + return ext == "asm" || ext == "s"; + } + } + + false +} diff --git a/vendor/cc/tests/test.rs b/vendor/cc/tests/test.rs index 35ef87577..161abd8ab 100644 --- a/vendor/cc/tests/test.rs +++ b/vendor/cc/tests/test.rs @@ -20,7 +20,7 @@ fn gnu_smoke() { test.cmd(0) .must_have("-O2") .must_have("foo.c") - .must_not_have("-g") + .must_not_have("-gdwarf-4") .must_have("-c") .must_have("-ffunction-sections") .must_have("-fdata-sections"); @@ -53,10 +53,25 @@ fn gnu_opt_level_s() { } #[test] +fn gnu_debug() { + let test = Test::gnu(); + test.gcc().debug(true).file("foo.c").compile("foo"); + test.cmd(0).must_have("-gdwarf-4"); + + let test = Test::gnu(); + test.gcc() + .target("x86_64-apple-darwin") + .debug(true) + .file("foo.c") + .compile("foo"); + test.cmd(0).must_have("-gdwarf-2"); +} + +#[test] fn gnu_debug_fp_auto() { let test = Test::gnu(); test.gcc().debug(true).file("foo.c").compile("foo"); - test.cmd(0).must_have("-g"); + test.cmd(0).must_have("-gdwarf-4"); test.cmd(0).must_have("-fno-omit-frame-pointer"); } @@ -64,7 +79,7 @@ fn gnu_debug_fp_auto() { fn gnu_debug_fp() { let test = Test::gnu(); test.gcc().debug(true).file("foo.c").compile("foo"); - test.cmd(0).must_have("-g"); + test.cmd(0).must_have("-gdwarf-4"); test.cmd(0).must_have("-fno-omit-frame-pointer"); } @@ -78,7 +93,7 @@ fn gnu_debug_nofp() { .force_frame_pointer(false) .file("foo.c") .compile("foo"); - test.cmd(0).must_have("-g"); + test.cmd(0).must_have("-gdwarf-4"); test.cmd(0).must_not_have("-fno-omit-frame-pointer"); let test = Test::gnu(); @@ -87,7 +102,7 @@ fn gnu_debug_nofp() { .debug(true) .file("foo.c") .compile("foo"); - test.cmd(0).must_have("-g"); + test.cmd(0).must_have("-gdwarf-4"); test.cmd(0).must_not_have("-fno-omit-frame-pointer"); } @@ -427,3 +442,20 @@ fn msvc_no_dash_dash() { test.cmd(0).must_not_have("--"); } + +// Disable this test with the parallel feature because the execution +// order is not deterministic. +#[cfg(not(feature = "parallel"))] +#[test] +fn asm_flags() { + let test = Test::gnu(); + test.gcc() + .file("foo.c") + .file("x86_64.asm") + .file("x86_64.S") + .asm_flag("--abc") + .compile("foo"); + test.cmd(0).must_not_have("--abc"); + test.cmd(1).must_have("--abc"); + test.cmd(2).must_have("--abc"); +} |