Skip to content

Commit

Permalink
Fix symbol visiblility for compiler-rt builtins on MacOS
Browse files Browse the repository at this point in the history
The symbols in the compiler-rt builtins library are private external by
default on MacOS. We need them to be visible so we can link against them
(e.g. when building libllvmlite.so). This patch makes the symbols
visible when the CMake option `COMPILER_RT_BUILTINS_HIDE_SYMBOLS` is
off. Note that this is an existing option for the compiler-rt build, and
the flags requiring modification in this patch appear to be an
oversight.

References:

- https://discourse.llvm.org/t/lld-automatically-hide-symbols-with-prefix/73192
- numba#986 (comment)
  • Loading branch information
gmarkall committed Apr 15, 2024
1 parent 8af5294 commit 4cdf2b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions conda-recipes/compiler-rt-macos-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index 640c7e7124c9..7bd3edb86eb1 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -399,7 +399,9 @@ endfunction()
macro(darwin_add_builtin_libraries)
set(DARWIN_EXCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Darwin-excludes)

- set(CFLAGS -fPIC -O3 -fvisibility=hidden -DVISIBILITY_HIDDEN -Wall -fomit-frame-pointer)
+ set(CFLAGS -fPIC -O3 -Wall -fomit-frame-pointer)
+ append_list_if(COMPILER_RT_BUILTINS_HIDE_SYMBOLS -fvisibility=hidden CFLAGS)
+ append_list_if(COMPILER_RT_BUILTINS_HIDE_SYMBOLS -DVISIBILITY_HIDDEN CFLAGS)
set(CMAKE_C_FLAGS "")
set(CMAKE_CXX_FLAGS "")
set(CMAKE_ASM_FLAGS "")
3 changes: 2 additions & 1 deletion conda-recipes/llvmdev_llvm15/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% set shortversion = "15.0" %}
{% set version = "15.0.7" %}
{% set sha256_llvm = "8b5fcb24b4128cf04df1b0b9410ce8b1a729cb3c544e6da885d234280dedeac6" %}
{% set build_number = "0" %}
{% set build_number = "1" %}

package:
name: llvmdev
Expand All @@ -15,6 +15,7 @@ source:
- ../llvm15-remove-use-of-clonefile.patch
- ../llvm15-svml.patch
- ../compiler-rt-cfi-startproc-war.patch
- ../compiler-rt-macos-build.patch

# Patches from conda-forge needed for windows to build
# backport of zlib patches, can be dropped for vs15.0.3, see
Expand Down

0 comments on commit 4cdf2b4

Please sign in to comment.