[Mlir-commits] [mlir] [mlir] enable APFloatWrappers on MacOS (PR #172070)

Maksim Levental llvmlistbot at llvm.org
Fri Dec 12 11:04:17 PST 2025


https://github.com/makslevental created https://github.com/llvm/llvm-project/pull/172070

None

>From 01540dca3e3779c35e2038bafce1476d93ecee61 Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Fri, 12 Dec 2025 11:03:35 -0800
Subject: [PATCH] [mlir] enable APFloatWrappers on MacOS

---
 mlir/lib/ExecutionEngine/CMakeLists.txt                | 10 +++++-----
 .../Arith/CPU/test-apfloat-emulation-vector.mlir       |  2 +-
 .../Dialect/Arith/CPU/test-apfloat-emulation.mlir      |  2 +-
 mlir/test/lit.cfg.py                                   |  4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt
index a6153523a5e97..3ce4079f16644 100644
--- a/mlir/lib/ExecutionEngine/CMakeLists.txt
+++ b/mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -168,8 +168,8 @@ if(LLVM_ENABLE_PIC)
   set_property(TARGET mlir_float16_utils PROPERTY CXX_STANDARD 17)
   target_compile_definitions(mlir_float16_utils PRIVATE mlir_float16_utils_EXPORTS)
 
-  if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
-    # TODO: This support library is only used on Linux builds until we figure
+  if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    # TODO: This support library is only used on Linux and Mac builds until we figure
     # out how to hide LLVM symbols in a way that works for all platforms.
     add_mlir_library(mlir_apfloat_wrappers
       SHARED
@@ -185,7 +185,7 @@ if(LLVM_ENABLE_PIC)
     )
     target_compile_definitions(mlir_apfloat_wrappers PRIVATE mlir_apfloat_wrappers_EXPORTS)
     # Hide LLVM symbols to avoid ODR violations.
-    target_link_options(mlir_apfloat_wrappers PRIVATE "-Wl,--exclude-libs,ALL")
+    target_link_options(mlir_apfloat_wrappers PRIVATE $<$<PLATFORM_ID:Linux>:LINKER:--exclude-libs,ALL>)
   endif()
 
   add_subdirectory(SparseTensor)
@@ -205,8 +205,8 @@ if(LLVM_ENABLE_PIC)
   set_property(TARGET mlir_c_runner_utils PROPERTY CXX_STANDARD 17)
   target_compile_definitions(mlir_c_runner_utils PRIVATE mlir_c_runner_utils_EXPORTS)
 
-  # Conditionally link apfloat wrappers only on Linux.
-  if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+  # Conditionally link apfloat wrappers only on Linux and Mac.
+  if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     target_link_libraries(mlir_c_runner_utils PUBLIC mlir_apfloat_wrappers)
   endif()
 
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/test-apfloat-emulation-vector.mlir b/mlir/test/Integration/Dialect/Arith/CPU/test-apfloat-emulation-vector.mlir
index 5f8b2f4efcf24..dfd9e7c4aaa14 100644
--- a/mlir/test/Integration/Dialect/Arith/CPU/test-apfloat-emulation-vector.mlir
+++ b/mlir/test/Integration/Dialect/Arith/CPU/test-apfloat-emulation-vector.mlir
@@ -1,4 +1,4 @@
-// REQUIRES: system-linux
+// REQUIRES: system-linux || system-darwin
 // TODO: Run only on Linux until we figure out how to build
 // mlir_apfloat_wrappers in a platform-independent way.
 
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/test-apfloat-emulation.mlir b/mlir/test/Integration/Dialect/Arith/CPU/test-apfloat-emulation.mlir
index 7f72dd5931488..e6c60001e5aee 100644
--- a/mlir/test/Integration/Dialect/Arith/CPU/test-apfloat-emulation.mlir
+++ b/mlir/test/Integration/Dialect/Arith/CPU/test-apfloat-emulation.mlir
@@ -1,4 +1,4 @@
-// REQUIRES: system-linux
+// REQUIRES: system-linux || system-darwin
 // TODO: Run only on Linux until we figure out how to build
 // mlir_apfloat_wrappers in a platform-independent way.
 
diff --git a/mlir/test/lit.cfg.py b/mlir/test/lit.cfg.py
index 675ded35d98f3..9c5bee169efe0 100644
--- a/mlir/test/lit.cfg.py
+++ b/mlir/test/lit.cfg.py
@@ -214,8 +214,8 @@ def find_real_python_interpreter():
     "not",
 ]
 
-if "Linux" in config.host_os:
-    # TODO: Run only on Linux until we figure out how to build
+if "Linux" in config.host_os or "Darwin" in config.host_os:
+    # TODO: Run only on Linux and Mac until we figure out how to build
     # mlir_apfloat_wrappers in a platform-independent way.
     tools.extend([add_runtime("mlir_apfloat_wrappers")])
 



More information about the Mlir-commits mailing list