From 1f2d1420cb1c5c5cb52712955f8ed47dcfda8c67 Mon Sep 17 00:00:00 2001
From: Kai Luo <lkail@cn.ibm.com>
Date: Tue, 2 Apr 2024 17:17:13 +0800
Subject: [PATCH 1/2] Fix linking c++ runtimes on AIX

---
 compiler/rustc_llvm/build.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs
index 4b0c1229da134..66fa4bde785e1 100644
--- a/compiler/rustc_llvm/build.rs
+++ b/compiler/rustc_llvm/build.rs
@@ -391,6 +391,11 @@ fn main() {
         }
     }
 
+    // libc++abi have to be specified explicitly on AIX.
+    if target.contains("aix") {
+        println!("cargo:rustc-link-lib=c++abi");
+    }
+
     // Libstdc++ depends on pthread which Rust doesn't link on MinGW
     // since nothing else requires it.
     if target.ends_with("windows-gnu") {

From 00f7f57159aac2e1df49db2eb87353338bef2bb0 Mon Sep 17 00:00:00 2001
From: Kai Luo <lkail@cn.ibm.com>
Date: Tue, 2 Apr 2024 17:25:22 +0800
Subject: [PATCH 2/2] Fix build on AIX

---
 compiler/rustc_llvm/build.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs
index 66fa4bde785e1..e2c0ec90c7cd3 100644
--- a/compiler/rustc_llvm/build.rs
+++ b/compiler/rustc_llvm/build.rs
@@ -391,9 +391,10 @@ fn main() {
         }
     }
 
-    // libc++abi have to be specified explicitly on AIX.
+    // libc++abi and libunwind have to be specified explicitly on AIX.
     if target.contains("aix") {
         println!("cargo:rustc-link-lib=c++abi");
+        println!("cargo:rustc-link-lib=unwind");
     }
 
     // Libstdc++ depends on pthread which Rust doesn't link on MinGW