[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits


@@ -1120,3 +1120,18 @@
 // 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
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
+// RUN: %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-LD32-NO-SANITIZER %s 
+// CHECK-LD32-NO-SANITIZER-NOT: "-latomic"
+
+// Check enable AddressSanitizer on 32-bit AIX
+// FIXME: Running this test on non-AIX hosts will result in the following 
error:
+// LLVM ERROR: Sanitizer interface functions must be exported by export files 
on AIX
+// RUN: %if target={{.*aix.*}} %{ \

hubert-reinterpretcast wrote:

> Where is this diagnostic `Sanitizer interface functions must be exported by 
> export files on AIX` defined and why is there a host difference?

It is strictly in IBM's downstream at this time. It will likely need revisiting 
before upstreaming. I have requested the removal of the driver part from this 
PR.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast edited 
https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast edited 
https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits


@@ -338,6 +338,13 @@ 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");

hubert-reinterpretcast wrote:

re: https://github.com/llvm/llvm-project/pull/125388/files#r1945365070:

> By keeping it in AIX.cpp, we maintain a clear separation between 
> platform-specific behavior and the more general sanitizer runtime dependency 
> logic.

In this case, the actual result would have been unintentional platform-specific 
behaviour.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast edited 
https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast edited 
https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits


@@ -338,6 +338,13 @@ 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");

hubert-reinterpretcast wrote:

> Please let me know if there are additional points to consider.

The addition of `-latomic` is not actually required _even on AIX_ if the only 
sanitizer runtimes that are linked in are purely shared libraries.

The addition of `-latomic` for 32-bit AIX belongs in 
`clang::tools::driver::linkSanitizerRuntimeDeps` because the wider logic is 
already present to call that function only when sanitizer runtimes that contain 
static components are linked in.

See
https://github.com/llvm/llvm-project/blob/f7294776570e125b94bb5625905cbc57a4956760/clang/lib/Driver/ToolChains/Gnu.cpp#L541
https://github.com/llvm/llvm-project/blob/f7294776570e125b94bb5625905cbc57a4956760/clang/lib/Driver/ToolChains/Gnu.cpp#L585-L586
https://github.com/llvm/llvm-project/blob/f7294776570e125b94bb5625905cbc57a4956760/clang/lib/Driver/ToolChains/CommonArgs.cpp#L1607-L1608
https://github.com/llvm/llvm-project/blob/f7294776570e125b94bb5625905cbc57a4956760/clang/lib/Driver/ToolChains/CommonArgs.cpp#L1678

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits


@@ -338,6 +338,13 @@ 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");

hubert-reinterpretcast wrote:

re: https://github.com/llvm/llvm-project/pull/125388/files#r1945365836:

> Our implementation in AIX.cpp follows the established behavior in the LLVM 
> community codebase.

Ignoring the lack of elaboration on how exactly placing this logic in `AIX.cpp` 
"follows the established behavior in the LLVM community codebase". The 
statement ignores the fact that the majority of `linkSanitizerRuntimeDeps` is 
code that is conditional based on platforms. For example:
https://github.com/llvm/llvm-project/blob/f7294776570e125b94bb5625905cbc57a4956760/clang/lib/Driver/ToolChains/CommonArgs.cpp#L1452-L1454

> While IBM’s downstream has opted to centralize similar logic in 
> clang::tools::driver::linkSanitizerRuntimeDeps

The characterization that it is "IBM's downstream" that opted to centralize the 
logic in said function is misleading. The _LLVM community_ had created said 
function for logic associated with linking in dependencies for static sanitizer 
components; IBM's downstream followed with that.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits


@@ -338,6 +338,13 @@ 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");

hubert-reinterpretcast wrote:

> This minimizes the risk of inadvertently impacting sanitizer handling on 
> non-AIX targets.

Generally, placing the code in a more widely used path will lead to more likely 
detection of problems. In other words, minimizing the risk of inadvertently 
impacting sanitizer handling on AIX targets _increases the risk_ of having 
broken sanitizer handling on AIX. Considering that the risk of breaking non-AIX 
should be low (especially in an undetected manner) and that the risk of 
incorrect sanitizer handling on AIX is high during active development, I think 
deliberate attempts to isolate the AIX code (as opposed to using common code 
paths) is a mistake.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast edited 
https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast requested changes to this pull 
request.

@honeygoyal, I do not believe that the prerequisite changes from IBM's 
downstream are present to support the Clang driver test being added in this PR.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits


@@ -1120,3 +1120,19 @@
 // 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: %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-LD32-NO-SANITIZER %s 
+// CHECK-LD32-NO-SANITIZER-NOT: "-latomic"
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
+// 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 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: %}
+// CHECK-LD32-ASAN: "-latomic"

hubert-reinterpretcast wrote:

Okay, I am willing to buy that testing both values for the "sanitizer" part on 
AIX is to establish that
1. the `-latomic` is present and
2. it is present _because_ a sanitizer is involved.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Honey Goyal via cfe-commits


@@ -1120,3 +1120,19 @@
 // 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: %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-LD32-NO-SANITIZER %s 
+// CHECK-LD32-NO-SANITIZER-NOT: "-latomic"
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
+// 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 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: %}
+// CHECK-LD32-ASAN: "-latomic"

honeygoyal wrote:

Hi @hubert-reinterpretcast,

Our focus on the 32‑bit AIX tests is intentional since the requirement to add 
`-latomic` applies exclusively to that configuration. For non‑32‑bit (e.g. 
64‑bit) targets, the flag isn’t needed—and its absence is verified by our 
broader sanitizer test suite (like in sanitizer‑ld.c) covering general 
sanitizer runtime behavior on non‑AIX platforms.

Thus, while a dedicated “sanitizer AND NOT 32‑bit” test might seem useful, it 
would duplicate coverage already ensured by our existing tests.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Honey Goyal via cfe-commits

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 
Date: Sun, 2 Feb 2025 14:27:01 +0530
Subject: [PATCH 01/18] 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 
Date: Sun, 2 Feb 2025 14:37:11 +0530
Subject: [PATCH 02/18] 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(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal 
Date: Sun, 2 Feb 2025 14:38:49 +0530
Subject: [PATCH 03/18] 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 
Date: Mon, 3 Feb 2025 14:06:24 +0530
Subject: [PATCH 04/18] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 
Date: Mon, 3 Feb 2025 14:06:35 +0530
Subject: [PATCH 05/18] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Honey Goyal via cfe-commits


@@ -338,6 +338,13 @@ 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");

honeygoyal wrote:

while I appreciate the suggestion and understand the merits of aligning with 
IBM’s downstream practices, I believe that maintaining the target-specific 
logic in `AIX.cpp` is the best course for now. This decision is based on 
ensuring clarity, minimizing risk, and preserving consistency with the 
community’s expected behavior.

Please let me know if there are additional points to consider.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Honey Goyal via cfe-commits


@@ -338,6 +338,13 @@ 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");

honeygoyal wrote:

**3. Testing and Maintainability:** The tests in clang/test/Driver/aix-ld.c are 
designed around this implementation. Moving the logic would complicate our test 
setup and risk unintended side effects.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Honey Goyal via cfe-commits


@@ -338,6 +338,13 @@ 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");

honeygoyal wrote:

**2. Consistency with Community LLVM Behavior:**
Our implementation in AIX.cpp follows the established behavior in the LLVM 
community codebase. While IBM’s downstream has opted to centralize similar 
logic in clang::tools::driver::linkSanitizerRuntimeDeps, our approach isolates 
the AIX-specific behavior. This minimizes the risk of inadvertently impacting 
sanitizer handling on non-AIX targets.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Honey Goyal via cfe-commits


@@ -338,6 +338,13 @@ 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");

honeygoyal wrote:

Thank you for the suggestion, @hubert-reinterpretcast. After careful 
consideration, I believe that keeping the -latomic handling directly in AIX.cpp 
is the more appropriate approach for the following reasons:

1. Target-Specific Clarity:
The logic for appending -latomic is very specific to the 32-bit AIX 
environment. By keeping it in AIX.cpp, we maintain a clear separation between 
platform-specific behavior and the more general sanitizer runtime dependency 
logic. This makes it immediately obvious to developers reviewing AIX-specific 
code that this flag is required solely for this target.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast requested changes to this pull 
request.


https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits


@@ -1120,3 +1120,19 @@
 // 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: %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-LD32-NO-SANITIZER %s 
+// CHECK-LD32-NO-SANITIZER-NOT: "-latomic"
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
+// 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 enable AddressSanitizer on 32-bit AIX

hubert-reinterpretcast wrote:

At this point in time, I suggest removing the driver changes from this PR and 
only dealing with the `CMakeLists.txt` here.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits


@@ -1120,3 +1120,19 @@
 // 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: %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-LD32-NO-SANITIZER %s 
+// CHECK-LD32-NO-SANITIZER-NOT: "-latomic"
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
+// 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 enable AddressSanitizer on 32-bit AIX

hubert-reinterpretcast wrote:

AFAICT, the `LLVM ERROR` message text is present only 
`clang::driver::tools::addSanitizerRuntimes` in the IBM downstream code at this 
time. @honeygoyal, have you checked the behaviour of these tests on AIX using 
the LLVM community code?

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits


@@ -1120,3 +1120,19 @@
 // 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: %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-LD32-NO-SANITIZER %s 
+// CHECK-LD32-NO-SANITIZER-NOT: "-latomic"
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
+// 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 enable AddressSanitizer on 32-bit AIX

hubert-reinterpretcast wrote:

```suggestion
// Check enable AddressSanitizer on 32-bit AIX
// FIXME: Running this test on non-AIX hosts will result in the following error:
// LLVM ERROR: Sanitizer interface functions must be exported by export files 
on AIX
```

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits


@@ -1120,3 +1120,19 @@
 // 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: %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-LD32-NO-SANITIZER %s 
+// CHECK-LD32-NO-SANITIZER-NOT: "-latomic"
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 

hubert-reinterpretcast wrote:

```suggestion
// Check No Sanitizer on 32-bit AIX
// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
// RUN: %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LD32-NO-SANITIZER %s 
// CHECK-LD32-NO-SANITIZER-NOT: "-latomic"

```

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Hubert Tong via cfe-commits


@@ -1120,3 +1120,19 @@
 // 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: %clang -target powerpc-ibm-aix -m32 %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-LD32-NO-SANITIZER %s 
+// CHECK-LD32-NO-SANITIZER-NOT: "-latomic"
+
+// This test verifies that the linker doesn't include '-latomic' when no 
sanitizers are enabled 
+// 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 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: %}
+// CHECK-LD32-ASAN: "-latomic"

hubert-reinterpretcast wrote:

Because we are testing both values for the "sanitizer" part of the "sanitizer 
AND 32-bit" condition, it seems odd that we are only testing one value for the 
"32-bit" part. Consider covering the "sanitizer AND NOT 32-bit" case.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Honey Goyal via cfe-commits


@@ -1120,3 +1120,23 @@
 // RUN:-c \
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
+
+
+// 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

honeygoyal wrote:

done

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Honey Goyal via cfe-commits

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 
Date: Sun, 2 Feb 2025 14:27:01 +0530
Subject: [PATCH 01/17] 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 
Date: Sun, 2 Feb 2025 14:37:11 +0530
Subject: [PATCH 02/17] 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(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal 
Date: Sun, 2 Feb 2025 14:38:49 +0530
Subject: [PATCH 03/17] 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 
Date: Mon, 3 Feb 2025 14:06:24 +0530
Subject: [PATCH 04/17] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 
Date: Mon, 3 Feb 2025 14:06:35 +0530
Subject: [PATCH 05/17] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-06 Thread Honey Goyal via cfe-commits

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 
Date: Sun, 2 Feb 2025 14:27:01 +0530
Subject: [PATCH 01/16] 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 
Date: Sun, 2 Feb 2025 14:37:11 +0530
Subject: [PATCH 02/16] 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(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal 
Date: Sun, 2 Feb 2025 14:38:49 +0530
Subject: [PATCH 03/16] 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 
Date: Mon, 3 Feb 2025 14:06:24 +0530
Subject: [PATCH 04/16] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 
Date: Mon, 3 Feb 2025 14:06:35 +0530
Subject: [PATCH 05/16] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Honey Goyal via cfe-commits

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 
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 
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(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal 
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 
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 
---
 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 
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 
---
 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] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits


@@ -1120,3 +1120,23 @@
 // RUN:-c \
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
+
+
+// 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

w2yehia wrote:

I tried the 2nd test on powerpcle and I see the error message:
`LLVM ERROR: Sanitizer interface functions must be exported by export files on 
AIX.`
I suggest reformatting the comment to make it clear that the FIXME is related 
to the "unrelated error". See above suggestion.


https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits


@@ -1120,3 +1120,23 @@
 // RUN:-c \
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
+
+
+// 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

w2yehia wrote:

The 1st test doesn't crash though. The error occurs when you have -m32 and 
-fsanitize=address, so technically you don't need to make the first test aix 
specific.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits


@@ -1120,3 +1120,23 @@
 // RUN:-c \
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
+
+
+// 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

w2yehia wrote:

```suggestion
// 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
```

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia deleted 
https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-05 Thread Wael Yehia via cfe-commits


@@ -1120,3 +1120,23 @@
 // RUN:-c \
 // RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
 // CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
+
+
+// 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

w2yehia wrote:

why do we have this FIXME here? Do you expect separate tests in the future for 
the FIXME or does the FIXME apply specifically to the test below?

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-04 Thread Honey Goyal via cfe-commits

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 
Date: Sun, 2 Feb 2025 14:27:01 +0530
Subject: [PATCH 01/13] 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 7e0f2bf91e06ee..de65597bcf5d91 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 
Date: Sun, 2 Feb 2025 14:37:11 +0530
Subject: [PATCH 02/13] 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 09a8dc2f4fa5dd..493983468b0bcf 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(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal 
Date: Sun, 2 Feb 2025 14:38:49 +0530
Subject: [PATCH 03/13] 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 09391e4f5f3704..79eeb31c035a28 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 
Date: Mon, 3 Feb 2025 14:06:24 +0530
Subject: [PATCH 04/13] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 de65597bcf5d91..85e8ea1aded3e0 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 
Date: Mon, 3 Feb 2025 14:06:35 +0530
Subject: [PATCH 05/13] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 85e8ea1aded3e0..d18279e009c63e 100644
--- a/clang/tes

[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Honey Goyal via cfe-commits

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 
Date: Sun, 2 Feb 2025 14:27:01 +0530
Subject: [PATCH 01/10] 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 7e0f2bf91e06ee..de65597bcf5d91 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 
Date: Sun, 2 Feb 2025 14:37:11 +0530
Subject: [PATCH 02/10] 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 09a8dc2f4fa5dd..493983468b0bcf 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(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal 
Date: Sun, 2 Feb 2025 14:38:49 +0530
Subject: [PATCH 03/10] 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 09391e4f5f3704..79eeb31c035a28 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 
Date: Mon, 3 Feb 2025 14:06:24 +0530
Subject: [PATCH 04/10] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 de65597bcf5d91..85e8ea1aded3e0 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 
Date: Mon, 3 Feb 2025 14:06:35 +0530
Subject: [PATCH 05/10] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 85e8ea1aded3e0..d18279e009c63e 100644
--- a/clang/tes

[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka approved this pull request.

for compiler-rt/lib/sanitizer_common/CMakeLists.txt

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast edited 
https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Hubert Tong via cfe-commits


@@ -1121,20 +1121,24 @@
 // 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 

hubert-reinterpretcast wrote:

I don't think that having _this_ test (32-bit with no sanitizer) fail when with 
non-AIX environments/configurations is acceptable. This is basically the same 
as the first test in the file (`CHECK-LD32`). If _this_ test is indeed failing, 
then please identify what the key difference is between this and the 
`CHECK-LD32` test.

Additionally, "on non-AIX targets" is not correct. Is it "on non-AIX hosts" or 
"with non-AIX target configurations"?

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Hubert Tong via cfe-commits


@@ -1121,20 +1121,24 @@
 // 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.

hubert-reinterpretcast wrote:

Remove unclear reference to "this bug" from the code comment in the test.
```suggestion
// (e.g., missing atomic support on certain architectures).
// FIXME: Address issues with non-AIX environments/configurations.
```

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Honey Goyal via cfe-commits


@@ -239,6 +239,11 @@ 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
+if (CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_NAME STREQUAL "AIX")

honeygoyal wrote:

Yes, more generalized pattern matching approach.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Honey Goyal via cfe-commits

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 
Date: Sun, 2 Feb 2025 14:27:01 +0530
Subject: [PATCH 1/9] 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 7e0f2bf91e06ee..de65597bcf5d91 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 
Date: Sun, 2 Feb 2025 14:37:11 +0530
Subject: [PATCH 2/9] 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 09a8dc2f4fa5dd..493983468b0bcf 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(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal 
Date: Sun, 2 Feb 2025 14:38:49 +0530
Subject: [PATCH 3/9] 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 09391e4f5f3704..79eeb31c035a28 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 
Date: Mon, 3 Feb 2025 14:06:24 +0530
Subject: [PATCH 4/9] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 de65597bcf5d91..85e8ea1aded3e0 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 
Date: Mon, 3 Feb 2025 14:06:35 +0530
Subject: [PATCH 5/9] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 85e8ea1aded3e0..d18279e009c63e 100644
--- a/clang/test/Driver/a

[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Vitaly Buka via cfe-commits


@@ -239,6 +239,11 @@ 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
+if (CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_NAME STREQUAL "AIX")

vitalybuka wrote:

Usually we do (OS_NAME MATCHES "Linux")

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Honey Goyal via cfe-commits


@@ -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

honeygoyal wrote:

added

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Honey Goyal via cfe-commits

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 
Date: Sun, 2 Feb 2025 14:27:01 +0530
Subject: [PATCH 1/8] 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 7e0f2bf91e06ee..de65597bcf5d91 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 
Date: Sun, 2 Feb 2025 14:37:11 +0530
Subject: [PATCH 2/8] 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 09a8dc2f4fa5dd..493983468b0bcf 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(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal 
Date: Sun, 2 Feb 2025 14:38:49 +0530
Subject: [PATCH 3/8] 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 09391e4f5f3704..79eeb31c035a28 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 
Date: Mon, 3 Feb 2025 14:06:24 +0530
Subject: [PATCH 4/8] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 de65597bcf5d91..85e8ea1aded3e0 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 
Date: Mon, 3 Feb 2025 14:06:35 +0530
Subject: [PATCH 5/8] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 85e8ea1aded3e0..d18279e009c63e 100644
--- a/clang/test/Driver/a

[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Honey Goyal via cfe-commits


@@ -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: %}

honeygoyal wrote:

Added Comments

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Honey Goyal via cfe-commits


@@ -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) {

honeygoyal wrote:

Added Comments

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Honey Goyal via cfe-commits

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 
Date: Sun, 2 Feb 2025 14:27:01 +0530
Subject: [PATCH 1/7] 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 7e0f2bf91e06ee..de65597bcf5d91 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 
Date: Sun, 2 Feb 2025 14:37:11 +0530
Subject: [PATCH 2/7] 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 09a8dc2f4fa5dd..493983468b0bcf 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(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal 
Date: Sun, 2 Feb 2025 14:38:49 +0530
Subject: [PATCH 3/7] 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 09391e4f5f3704..79eeb31c035a28 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 
Date: Mon, 3 Feb 2025 14:06:24 +0530
Subject: [PATCH 4/7] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 de65597bcf5d91..85e8ea1aded3e0 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 
Date: Mon, 3 Feb 2025 14:06:35 +0530
Subject: [PATCH 5/7] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 85e8ea1aded3e0..d18279e009c63e 100644
--- a/clang/test/Driver/a

[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Honey Goyal via cfe-commits

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 
Date: Sun, 2 Feb 2025 14:27:01 +0530
Subject: [PATCH 1/5] 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 
Date: Sun, 2 Feb 2025 14:37:11 +0530
Subject: [PATCH 2/5] 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(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal 
Date: Sun, 2 Feb 2025 14:38:49 +0530
Subject: [PATCH 3/5] 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 
Date: Mon, 3 Feb 2025 14:06:24 +0530
Subject: [PATCH 4/5] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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 
Date: Mon, 3 Feb 2025 14:06:35 +0530
Subject: [PATCH 5/5] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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/tes

[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Honey Goyal via cfe-commits

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 
Date: Sun, 2 Feb 2025 14:27:01 +0530
Subject: [PATCH 1/4] 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 
Date: Sun, 2 Feb 2025 14:37:11 +0530
Subject: [PATCH 2/4] 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(JA, *this, 
ResponseFileSupport::None(),
  Exec, CmdArgs, Inputs, Output));
 }

>From 84d973a841ce1069c941b26f7466330e813797e3 Mon Sep 17 00:00:00 2001
From: Honey Goyal 
Date: Sun, 2 Feb 2025 14:38:49 +0530
Subject: [PATCH 3/4] 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 
Date: Mon, 3 Feb 2025 14:06:24 +0530
Subject: [PATCH 4/4] Update clang/test/Driver/aix-ld.c

Co-authored-by: Hubert Tong 
---
 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.*}} %{ \

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


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Hubert Tong via cfe-commits


@@ -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"
+// %}

hubert-reinterpretcast wrote:

```suggestion
// CHECK-LD32-ASAN: "-latomic"
```

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Hubert Tong via cfe-commits


@@ -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"
+// %}

hubert-reinterpretcast wrote:

`FileCheck` uses the `-check-prefix` to handle the selection here. The LIT 
syntax has no effect.
```suggestion
// CHECK-LD32-NO-SANITIZER-NOT: "-latomic"
```

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-03 Thread Hubert Tong via cfe-commits


@@ -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: %}

hubert-reinterpretcast wrote:

Can you explain why this cannot be run when the default target is not 
configured to be AIX?
This is inconsistent with the other tests in this file (including ones that 
check link commands).

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-02 Thread Wael Yehia via cfe-commits


@@ -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) {

w2yehia wrote:

a comment on why we need -latomic here. 
For example:
```
// Some code in the sanitizer libs requires 64-bit atomics.
```

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-02 Thread Wael Yehia via cfe-commits


@@ -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

w2yehia wrote:

also, for other conditional additions to `CFLAGS` (like the ones above) a 
variable is defined in `compiler-rt/CMakeLists.txt` and checked here (see 
`SANITIZER_LIMIT_FRAME_SIZE` for example). Not sure if yours has to be done 
similarly.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-02 Thread Wael Yehia via cfe-commits


@@ -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

w2yehia wrote:

Adding the -Wno-error should only be needed in 32-bit mode, and probably AIX 
only for now.

https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)

2025-02-02 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia edited 
https://github.com/llvm/llvm-project/pull/125388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits