]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #106811 - khuey:dwp_extension, r=davidtwco
authorMatthias Krüger <matthias.krueger@famsik.de>
Thu, 26 Jan 2023 06:53:23 +0000 (07:53 +0100)
committerGitHub <noreply@github.com>
Thu, 26 Jan 2023 06:53:23 +0000 (07:53 +0100)
Append .dwp to the binary filename instead of replacing the existing extension.

gdb et al. expect to find the dwp file at `<binary>`.dwp, even if <binary> already has an extension (e.g. libfoo.so's dwp is expected to be at libfoo.so.dwp).

1  2 
compiler/rustc_codegen_ssa/src/back/link.rs

index b148e4185a68a795ce5f2c02e8e164dbcee8cada,06dbeac2850e7594550e2f1050939d1068651852..0a7bf6ff00c73b6d2eeb0b66f11a4c67793afdaf
@@@ -445,7 -445,7 +445,7 @@@ fn link_rlib<'a>
  /// Extract all symbols defined in raw-dylib libraries, collated by library name.
  ///
  /// If we have multiple extern blocks that specify symbols defined in the same raw-dylib library,
 -/// then the CodegenResults value contains one NativeLib instance for each block.  However, the
 +/// then the CodegenResults value contains one NativeLib instance for each block. However, the
  /// linker appears to expect only a single import library for each library used, so we need to
  /// collate the symbols together by library name before generating the import libraries.
  fn collate_raw_dylibs<'a, 'b>(
@@@ -599,7 -599,8 +599,8 @@@ fn link_dwarf_object<'a>
      cg_results: &CodegenResults,
      executable_out_filename: &Path,
  ) {
-     let dwp_out_filename = executable_out_filename.with_extension("dwp");
+     let mut dwp_out_filename = executable_out_filename.to_path_buf().into_os_string();
+     dwp_out_filename.push(".dwp");
      debug!(?dwp_out_filename, ?executable_out_filename);
  
      #[derive(Default)]
@@@ -1197,7 -1198,7 +1198,7 @@@ pub fn linker_and_flavor(sess: &Session
                          if cfg!(any(target_os = "solaris", target_os = "illumos")) {
                              // On historical Solaris systems, "cc" may have
                              // been Sun Studio, which is not flag-compatible
 -                            // with "gcc".  This history casts a long shadow,
 +                            // with "gcc". This history casts a long shadow,
                              // and many modern illumos distributions today
                              // ship GCC as "gcc" without also making it
                              // available as "cc".
                      sess.emit_fatal(errors::LinkerFileStem);
                  });
  
 +                // Remove any version postfix.
 +                let stem = stem
 +                    .rsplit_once('-')
 +                    .and_then(|(lhs, rhs)| rhs.chars().all(char::is_numeric).then_some(lhs))
 +                    .unwrap_or(stem);
 +
 +                // GCC can have an optional target prefix.
                  let flavor = if stem == "emcc" {
                      LinkerFlavor::EmCc
                  } else if stem == "gcc"
                      || stem.ends_with("-gcc")
 +                    || stem == "g++"
 +                    || stem.ends_with("-g++")
                      || stem == "clang"
 -                    || stem.ends_with("-clang")
 +                    || stem == "clang++"
                  {
                      LinkerFlavor::from_cli(LinkerFlavorCli::Gcc, &sess.target)
                  } else if stem == "wasm-ld" || stem.ends_with("-wasm-ld") {