about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
author12101111 <w12101111@gmail.com>2021-05-22 00:09:07 +0800
committer12101111 <w12101111@gmail.com>2021-05-22 00:09:07 +0800
commit004614c4b38eead656201c97d2e50f55c28c79b3 (patch)
treec87278508efc80af2730f995e088a55794870483 /compiler/rustc_codegen_ssa/src
parentfc81ad22c453776de16acf9938976930cf8c9401 (diff)
downloadrust-004614c4b38eead656201c97d2e50f55c28c79b3.tar.gz
rust-004614c4b38eead656201c97d2e50f55c28c79b3.zip
native lib: defer the duplicate check after relevant_lib check.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index e330b5e703b..32275e9b073 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -1805,13 +1805,14 @@ fn add_local_native_libraries(
     let search_path = archive_search_paths(sess);
     let mut last = (NativeLibKind::Unspecified, None);
     for lib in relevant_libs {
-        // Skip if this library is the same as the last.
-        last = if (lib.kind, lib.name) == last { continue } else { (lib.kind, lib.name) };
-
         let name = match lib.name {
             Some(l) => l,
             None => continue,
         };
+
+        // Skip if this library is the same as the last.
+        last = if (lib.kind, lib.name) == last { continue } else { (lib.kind, lib.name) };
+
         let verbatim = lib.verbatim.unwrap_or(false);
         match lib.kind {
             NativeLibKind::Dylib { as_needed } => {
@@ -2144,9 +2145,6 @@ fn add_upstream_native_libraries(
     let mut last = (NativeLibKind::Unspecified, None);
     for &(cnum, _) in crates {
         for lib in codegen_results.crate_info.native_libraries[&cnum].iter() {
-            // Skip if this library is the same as the last.
-            last = if (lib.kind, lib.name) == last { continue } else { (lib.kind, lib.name) };
-
             let name = match lib.name {
                 Some(l) => l,
                 None => continue,
@@ -2154,6 +2152,10 @@ fn add_upstream_native_libraries(
             if !relevant_lib(sess, &lib) {
                 continue;
             }
+
+            // Skip if this library is the same as the last.
+            last = if (lib.kind, lib.name) == last { continue } else { (lib.kind, lib.name) };
+
             let verbatim = lib.verbatim.unwrap_or(false);
             match lib.kind {
                 NativeLibKind::Dylib { as_needed } => {