https://github.com/honeygoyal updated 
https://github.com/llvm/llvm-project/pull/125388

>From f9d8e7f9c0df6beb8b4a63a01ebbc3b3ab93d091 Mon Sep 17 00:00:00 2001
From: Honey Goyal <honey.goy...@ibm.com>
Date: Sun, 2 Feb 2025 14:27:01 +0530
Subject: [PATCH 01/14] Test Cases for adding -latomic (the access size (8
 bytes) exceeds the max lock-free size

---
 clang/test/Driver/aix-ld.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 7e0f2bf91e06ee5..de65597bcf5d914 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -1120,3 +1120,21 @@
 // RUN:        -c \
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
+
+// Check No Sanitizer on 32-bit AIX
+// RUN: %if target={{.*aix.*}} %{ \
+// RUN:   %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LD32-NO-SANITIZER %s \
+// RUN: %}
+// %if target={{.*aix.*}} %{ 
+// CHECK-LD32-NO-SANITIZER-NOT: "-latomic"
+// %}
+
+// Check enable AddressSanitizer on 32-bit AIX
+// RUN: %if target={{.*aix.*}} %{ \
+// RUN:   %clang -target powerpc-ibm-aix -m32 -fsanitize=address %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LD32-ASAN %s \
+// RUN: %}
+// %if target={{.*aix.*}} %{ 
+// CHECK-LD32-ASAN: "-latomic"
+// %}

>From 1b7439e43798c8a1663e9cb72d61a1625b391cec Mon Sep 17 00:00:00 2001
From: Honey Goyal <honey.goy...@ibm.com>
Date: Sun, 2 Feb 2025 14:37:11 +0530
Subject: [PATCH 02/14] Added -latomic when sanitizer flag is enabled and
 processor is 32-bit

---
 clang/lib/Driver/ToolChains/AIX.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 09a8dc2f4fa5dd8..493983468b0bcf9 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -232,7 +232,7 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   // Specify linker input file(s).
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
-
+  const SanitizerArgs &Sanitize = ToolChain.getSanitizerArgs(Args);
   if (D.isUsingLTO()) {
     assert(!Inputs.empty() && "Must have at least one input.");
     // Find the first filename InputInfo object.
@@ -338,6 +338,10 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
     CmdArgs.push_back("-lpthread");
   }
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+  
+  if (Sanitize.hasAnySanitizer() && IsArch32Bit) {
+    CmdArgs.push_back("-latomic");
+  }
   C.addCommand(std::make_unique<Command>(JA, *this, 
ResponseFileSupport::None(),
                                          Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal <honey.goy...@ibm.com>
Date: Sun, 2 Feb 2025 14:38:49 +0530
Subject: [PATCH 03/14] Suppress -Watomic-alignment warnings by not treating
 them as errors

---
 compiler-rt/lib/sanitizer_common/CMakeLists.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt 
b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index 09391e4f5f3704b..79eeb31c035a282 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -239,6 +239,9 @@ append_list_if(SANITIZER_LIMIT_FRAME_SIZE 
-Wframe-larger-than=570
 append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
                SANITIZER_CFLAGS)
 
+# Suppress -Watomic-alignment warnings by not treating them as errors
+list(APPEND SANITIZER_CFLAGS "-Wno-error=atomic-alignment")
+
 if(APPLE)
   set(OS_OPTION OS ${SANITIZER_COMMON_SUPPORTED_OS})
 endif()

>From 3addb864505ae401c9be99eee6031dea2908f949 Mon Sep 17 00:00:00 2001
From: Honey Goyal <honeygoya...@gmail.com>
Date: Mon, 3 Feb 2025 14:06:24 +0530
Subject: [PATCH 04/14] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong <hubert.reinterpretc...@gmail.com>
---
 clang/test/Driver/aix-ld.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index de65597bcf5d914..85e8ea1aded3e09 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -1126,9 +1126,7 @@
 // RUN:   %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LD32-NO-SANITIZER %s \
 // RUN: %}
-// %if target={{.*aix.*}} %{ 
 // CHECK-LD32-NO-SANITIZER-NOT: "-latomic"
-// %}
 
 // Check enable AddressSanitizer on 32-bit AIX
 // RUN: %if target={{.*aix.*}} %{ \

>From b0b9c5ab175d64002440b3b50e99e696d29b6b39 Mon Sep 17 00:00:00 2001
From: Honey Goyal <honeygoya...@gmail.com>
Date: Mon, 3 Feb 2025 14:06:35 +0530
Subject: [PATCH 05/14] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong <hubert.reinterpretc...@gmail.com>
---
 clang/test/Driver/aix-ld.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 85e8ea1aded3e09..d18279e009c63e1 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -1133,6 +1133,4 @@
 // RUN:   %clang -target powerpc-ibm-aix -m32 -fsanitize=address %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LD32-ASAN %s \
 // RUN: %}
-// %if target={{.*aix.*}} %{ 
 // CHECK-LD32-ASAN: "-latomic"
-// %}

>From 317f5ca4ff2ea5dc3f40292c912aae5daeddc546 Mon Sep 17 00:00:00 2001
From: Honey Goyal <honey.goy...@ibm.com>
Date: Tue, 4 Feb 2025 04:04:10 +0530
Subject: [PATCH 06/14] Added Comments Required for 64-bit atomic operations
 used in sanitizer runtimes

---
 clang/lib/Driver/ToolChains/AIX.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 493983468b0bcf9..bdd73497a2893bf 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -338,7 +338,10 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
     CmdArgs.push_back("-lpthread");
   }
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
-  
+    
+// Required for 64-bit atomic operations used in sanitizer runtimes 
+// (e.g., sanitizer_common's atomic utilities). On 32-bit AIX, these 
+// are not natively supported, necessitating linkage with -latomic.
   if (Sanitize.hasAnySanitizer() && IsArch32Bit) {
     CmdArgs.push_back("-latomic");
   }

>From 2bae0814b0066b8016e507e16432d4a1f5fb095a Mon Sep 17 00:00:00 2001
From: Honey Goyal <honey.goy...@ibm.com>
Date: Tue, 4 Feb 2025 04:12:05 +0530
Subject: [PATCH 07/14] Added Comments in aix-id.c test

---
 clang/test/Driver/aix-ld.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index d18279e009c63e1..8c26d922ec7106d 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -1121,6 +1121,13 @@
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
 
+
+// This check is only applicable to AIX targets. 
+// AIX-specific link behavior requires `-latomic` for 32-bit sanitizer 
libraries, 
+// Running this test on non-AIX targets will result in an unrelated error 
+// (e.g., missing atomic support on certain architectures), 
+// which is outside the scope of this bug and is addressed separately.
+
 // Check No Sanitizer on 32-bit AIX
 // RUN: %if target={{.*aix.*}} %{ \
 // RUN:   %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
@@ -1134,3 +1141,4 @@
 // RUN:   | FileCheck -check-prefix=CHECK-LD32-ASAN %s \
 // RUN: %}
 // CHECK-LD32-ASAN: "-latomic"
+

>From 0b737c92995bac35f2045157d7222c7ad327e7ca Mon Sep 17 00:00:00 2001
From: Honey Goyal <honey.goy...@ibm.com>
Date: Tue, 4 Feb 2025 04:40:03 +0530
Subject: [PATCH 08/14] Added Check specific to AIX and 32 bit processor in
 CMakeLists.txt

---
 compiler-rt/lib/sanitizer_common/CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt 
b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index 79eeb31c035a282..c2b106917d9c58c 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -240,7 +240,9 @@ append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG 
-Wglobal-constructors
                SANITIZER_CFLAGS)
 
 # Suppress -Watomic-alignment warnings by not treating them as errors
-list(APPEND SANITIZER_CFLAGS "-Wno-error=atomic-alignment")
+if (CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_NAME STREQUAL "AIX")
+  list(APPEND SANITIZER_CFLAGS "-Wno-error=atomic-alignment")
+endif()
 
 if(APPLE)
   set(OS_OPTION OS ${SANITIZER_COMMON_SUPPORTED_OS})

>From e130b148ac40cf761305e7c28e3df726041c68a3 Mon Sep 17 00:00:00 2001
From: Honey Goyal <honey.goy...@ibm.com>
Date: Tue, 4 Feb 2025 04:53:30 +0530
Subject: [PATCH 09/14] - Use MATCHES for flexible OS detection

---
 compiler-rt/lib/sanitizer_common/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt 
b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index c2b106917d9c58c..e46b576a04b7988 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -240,7 +240,7 @@ append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG 
-Wglobal-constructors
                SANITIZER_CFLAGS)
 
 # Suppress -Watomic-alignment warnings by not treating them as errors
-if (CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_NAME STREQUAL "AIX")
+if (CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_NAME MATCHES "AIX")
   list(APPEND SANITIZER_CFLAGS "-Wno-error=atomic-alignment")
 endif()
 

>From 9715d9e37a1002882c798d1233496742dd5eb11c Mon Sep 17 00:00:00 2001
From: Honey Goyal <honeygoya...@gmail.com>
Date: Tue, 4 Feb 2025 08:36:04 +0530
Subject: [PATCH 10/14] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong <hubert.reinterpretc...@gmail.com>
---
 clang/test/Driver/aix-ld.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 8c26d922ec7106d..344549e8f853884 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -1125,8 +1125,8 @@
 // This check is only applicable to AIX targets. 
 // AIX-specific link behavior requires `-latomic` for 32-bit sanitizer 
libraries, 
 // Running this test on non-AIX targets will result in an unrelated error 
-// (e.g., missing atomic support on certain architectures), 
-// which is outside the scope of this bug and is addressed separately.
+// (e.g., missing atomic support on certain architectures).
+// FIXME: Address issues with non-AIX environments/configurations.
 
 // Check No Sanitizer on 32-bit AIX
 // RUN: %if target={{.*aix.*}} %{ \

>From 721a57c599b15a7810182c4fa2cf5669195eb2c2 Mon Sep 17 00:00:00 2001
From: Honey Goyal <honeygoya...@gmail.com>
Date: Wed, 5 Feb 2025 11:37:53 +0530
Subject: [PATCH 11/14] Update aix-ld.c

---
 clang/test/Driver/aix-ld.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 344549e8f853884..6bc6dac1c26c9fc 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -1121,10 +1121,9 @@
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
 
-
-// This check is only applicable to AIX targets. 
+// This check is only applicable to AIX host. 
 // AIX-specific link behavior requires `-latomic` for 32-bit sanitizer 
libraries, 
-// Running this test on non-AIX targets will result in an unrelated error 
+// Running this test on non-AIX host will result in an unrelated error 
 // (e.g., missing atomic support on certain architectures).
 // FIXME: Address issues with non-AIX environments/configurations.
 

>From 395131e1dc73885da61f4279ebf337dc8586433d Mon Sep 17 00:00:00 2001
From: Honey Goyal <honeygoya...@gmail.com>
Date: Wed, 5 Feb 2025 11:58:26 +0530
Subject: [PATCH 12/14] Update aix-ld.c

---
 clang/test/Driver/aix-ld.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 6bc6dac1c26c9fc..fe89d0acd44c634 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -1124,8 +1124,7 @@
 // This check is only applicable to AIX host. 
 // AIX-specific link behavior requires `-latomic` for 32-bit sanitizer 
libraries, 
 // Running this test on non-AIX host will result in an unrelated error 
-// (e.g., missing atomic support on certain architectures).
-// FIXME: Address issues with non-AIX environments/configurations.
+// FIXME: Sanitizer interface functions must be exported by export files on AIX
 
 // Check No Sanitizer on 32-bit AIX
 // RUN: %if target={{.*aix.*}} %{ \

>From 04857d63153de11c9914c25a3d8603c53316c077 Mon Sep 17 00:00:00 2001
From: Honey Goyal <ho...@recycler.rtp.raleigh.ibm.com>
Date: Wed, 5 Feb 2025 07:17:02 +0000
Subject: [PATCH 13/14] Update the comments and mention the specific issue on
 non-AIX host

---
 clang/test/Driver/aix-ld.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index fe89d0acd44c634..a7738d6238f3dd5 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -1121,8 +1121,8 @@
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
 
-// This check is only applicable to AIX host. 
-// AIX-specific link behavior requires `-latomic` for 32-bit sanitizer 
libraries, 
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
 // Running this test on non-AIX host will result in an unrelated error 
 // FIXME: Sanitizer interface functions must be exported by export files on AIX
 

>From a45304abaa46ed872c6ff1613566c4188da2a4b3 Mon Sep 17 00:00:00 2001
From: Honey Goyal <honeygoya...@gmail.com>
Date: Thu, 6 Feb 2025 00:10:07 +0530
Subject: [PATCH 14/14] Update clang/test/Driver/aix-ld.c

Co-authored-by: Wael Yehia <wmyehia2...@yahoo.com>
---
 clang/test/Driver/aix-ld.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index a7738d6238f3dd5..3e58ef7b5034f14 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -1123,8 +1123,8 @@
 
 
 // This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
-// Running this test on non-AIX host will result in an unrelated error 
-// FIXME: Sanitizer interface functions must be exported by export files on AIX
+// FIXME: Running this test on non-AIX host will result in the following error:
+// LLVM ERROR: Sanitizer interface functions must be exported by export files 
on AIX
 
 // Check No Sanitizer on 32-bit AIX
 // RUN: %if target={{.*aix.*}} %{ \

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to