From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Date: Thu, 7 Aug 2025 20:12:53 +0200
Subject: [PATCH] compiler: Swap primary and secondary lib dirs

Arch Linux prefers "lib" over "lib64".
---
 compiler/rustc_target/src/lib.rs | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs
index b3fe1fffcceb..913bb3fde66a 100644
--- a/compiler/rustc_target/src/lib.rs
+++ b/compiler/rustc_target/src/lib.rs
@@ -53,20 +53,22 @@ fn find_relative_libdir(sysroot: &Path) -> std::borrow::Cow<'static, str> {
     // If --libdir is set during configuration to the value other than
     // "lib" (i.e., non-default), this value is used (see issue #16552).
 
+    const PRIMARY_LIB_DIR: &str = "lib";
+
     #[cfg(target_pointer_width = "64")]
-    const PRIMARY_LIB_DIR: &str = "lib64";
+    const SECONDARY_LIB_DIR: &str = "lib64";
 
     #[cfg(target_pointer_width = "32")]
-    const PRIMARY_LIB_DIR: &str = "lib32";
-
-    const SECONDARY_LIB_DIR: &str = "lib";
+    const SECONDARY_LIB_DIR: &str = "lib32";
 
     match option_env!("CFG_LIBDIR_RELATIVE") {
         None | Some("lib") => {
             if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
                 PRIMARY_LIB_DIR.into()
-            } else {
+            } else if sysroot.join(SECONDARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
                 SECONDARY_LIB_DIR.into()
+            } else {
+                PRIMARY_LIB_DIR.into()
             }
         }
         Some(libdir) => libdir.into(),
