[llvm] [flang] Set compile defintions for flang-rt build on AIX (PR #127919)

Kelvin Li via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 19 15:09:40 PST 2025


https://github.com/kkwli created https://github.com/llvm/llvm-project/pull/127919

After https://github.com/llvm/llvm-project/commit/b55f7512a76f2358000139074c79d4c2521588de, the flang-rt build on AIX is missing `-D_LARGE_FILE_API -D_XOPEN_SOURCE=700` in compiling the source. This patch is to add the compile definitions.

>From 558bcc96b21fe21c0d04f6972b806aab64f5cd5f Mon Sep 17 00:00:00 2001
From: Kelvin Li <kli at ca.ibm.com>
Date: Wed, 19 Feb 2025 18:00:10 -0500
Subject: [PATCH] [flang] Set flang-rt build options for AIX

---
 flang-rt/CMakeLists.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 50d1a5cb2a591..999318a3ed3b9 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -227,6 +227,12 @@ if (WIN32)
   find_compiler_rt_library(builtins FLANG_RT_BUILTINS_LIBRARY)
 endif ()
 
+# Build with _XOPEN_SOURCE on AIX to avoid errors caused by _ALL_SOURCE.
+# We need to enable the large-file API as well.
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  add_compile_definitions(_XOPEN_SOURCE=700)
+  add_compile_definitions(_LARGE_FILE_API)
+endif ()
 
 # Check whether the compiler can undefine a macro using the "-U" flag.
 # Aternatively, we could use



More information about the llvm-commits mailing list