[compiler-rt] [compiler-rt] Fix building on OpenBSD/amd64 (PR #165086)

Brad Smith via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 25 00:42:54 PDT 2025


https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/165086

>From 56feddbda7778489f6fa25d64dd285ad0423d79e Mon Sep 17 00:00:00 2001
From: Brad Smith <brad at comstyle.com>
Date: Sat, 25 Oct 2025 03:24:15 -0400
Subject: [PATCH] [compiler-rt] Fix building on OpenBSD/amd64

OpenBSD/amd64 does not use multi-lib. Enabling the CET support on amd64
exposed that CMake was using a multi-lib build on amd64.

OpenBSD 64-bit platforms do not support multi-lib.
---
 compiler-rt/cmake/base-config-ix.cmake | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake
index d92bc0e71fa1a..cf2715e4cc0f0 100644
--- a/compiler-rt/cmake/base-config-ix.cmake
+++ b/compiler-rt/cmake/base-config-ix.cmake
@@ -213,7 +213,7 @@ macro(test_targets)
     if(COMPILER_RT_DEFAULT_TARGET_ONLY)
       add_default_target_arch(${COMPILER_RT_DEFAULT_TARGET_ARCH})
     elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "i[2-6]86|x86|amd64")
-      if(NOT MSVC)
+      if(NOT MSVC AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
         test_target_arch(x86_64 "" "-m64")
         test_target_arch(i386 __i386__ "-m32")
       else()
@@ -234,13 +234,29 @@ macro(test_targets)
     elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc64le|ppc64le")
       test_target_arch(powerpc64le "" "-m64")
     elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
-      test_target_arch(powerpc "" "-m32")
-      test_target_arch(powerpc64 "" "-m64")
+      if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
+        test_target_arch(powerpc "" "-m32")
+        test_target_arch(powerpc64 "" "-m64")
+      else()
+        if (CMAKE_SIZEOF_VOID_P EQUAL 4)
+          test_target_arch(powerpc "" "-m32")
+        else()
+          test_target_arch(powerpc64 "" "-m64")
+        endif()
+      endif()
     elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "s390x")
       test_target_arch(s390x "" "")
     elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "sparc")
-      test_target_arch(sparc "" "-m32")
-      test_target_arch(sparcv9 "" "-m64")
+      if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
+        test_target_arch(sparc "" "-m32")
+        test_target_arch(sparcv9 "" "-m64")
+      else()
+        if (CMAKE_SIZEOF_VOID_P EQUAL 4)
+          test_target_arch(sparc "" "-m32")
+        else()
+          test_target_arch(sparcv9 "" "-m64")
+        endif()
+      endif()
     elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "mips")
       CHECK_SYMBOL_EXISTS (_MIPS_ARCH_MIPS32R6 "" COMPILER_RT_MIPS32R6)
       CHECK_SYMBOL_EXISTS (_MIPS_ARCH_MIPS64R6 "" COMPILER_RT_MIPS64R6)



More information about the llvm-commits mailing list