Skip to content
46 changes: 46 additions & 0 deletions conda-recipes/compiler-rt-14-fp-xstate-magic1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
From 6f095babc2b7d564168c7afc5bf6afb2188fd6b4 Mon Sep 17 00:00:00 2001
From: Tobias Burnus <[email protected]>
Date: Thu, 5 May 2022 10:30:10 +0100
Subject: [PATCH] sanitizer_common: Define FP_XSTATE_MAGIC1 for old glibc
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

D116208 (commit 1298273e8206a8fc2) added FP_XSTATE_MAGIC1.
However, when building with glibc < 2.16 for backward-dependency
compatibility, it is not defined - and the build breaks.

Note: The define comes from Linux's asm/sigcontext.h but the
file uses signal.h which includes glibc's bits/sigcontext.h - which
is synced from the kernel's file but lags behind.

Solution: For backward compatility with ancient systems, define
FP_XSTATE_MAGIC1 if undefined.

//For the old systems, we were building with Linux kernel 3.19 but to support really old glibc systems, we build with a sysroot of glibc 2.12. While our kernel (and the users' kernels) have FP_XSTATE_MAGIC1, glibc 2.12 is too old. – With this patch, building the sanitizer libs works again. This showed up for us today as GCC mainline/13 has now synced the sanitizer libs.//

Reviewed By: #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D124927
---
.../lib/sanitizer_common/sanitizer_platform_limits_posix.cpp | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/compiler-rt-14.0.6.src/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt-14.0.6.src/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
index e5cecaaaffc2..8ed3e92d2704 100644
--- a/compiler-rt-14.0.6.src/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+++ b/compiler-rt-14.0.6.src/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
@@ -218,6 +218,10 @@ namespace __sanitizer {

unsigned ucontext_t_sz(void *ctx) {
# if SANITIZER_GLIBC && SANITIZER_X64
+ // Added in Linux kernel 3.4.0, merged to glibc in 2.16
+# ifndef FP_XSTATE_MAGIC1
+# define FP_XSTATE_MAGIC1 0x46505853U
+# endif
// See kernel arch/x86/kernel/fpu/signal.c for details.
const auto *fpregs = static_cast<ucontext_t *>(ctx)->uc_mcontext.fpregs;
// The member names differ across header versions, but the actual layout
--
2.40.0

26 changes: 26 additions & 0 deletions conda-recipes/compiler-rt-windows-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From be79c54f618affc9c4797a5331486fc891d2a4a4 Mon Sep 17 00:00:00 2001
From: Graham Markall <[email protected]>
Date: Fri, 11 Aug 2023 11:31:08 +0100
Subject: [PATCH] Fix out-of-tree compiler-rt build on Windows

From:

https://stackoverflow.com/questions/46108390/building-llvm-with-cmake-and-visual-stuidio-fails-to-install
---
compiler-rt/cmake/Modules/AddCompilerRT.cmake | 1 +
1 file changed, 1 insertion(+)

diff --git a/compiler-rt-14.0.6.src/cmake/Modules/AddCompilerRT.cmake b/compiler-rt-14.0.6.src/cmake/Modules/AddCompilerRT.cmake
index 4a496fc18f65..2ace529a595d 100644
--- a/compiler-rt-14.0.6.src/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt-14.0.6.src/cmake/Modules/AddCompilerRT.cmake
@@ -9,6 +9,7 @@ function(set_target_output_directories target output_dir)
# set 'RUNTIME_OUTPUT_DIRECTORY_${CONF}':
# RUNTIME_OUTPUT_DIRECTORY_DEBUG, RUNTIME_OUTPUT_DIRECTORY_RELEASE, ...
if(CMAKE_CONFIGURATION_TYPES)
+ string(REGEX REPLACE "\\$\\(Configuration\\)" "$<CONFIG>" output_dir "${output_dir}")
foreach(build_mode ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${build_mode}" CONFIG_SUFFIX)
set_target_properties("${target}" PROPERTIES
--
2.40.0
52 changes: 25 additions & 27 deletions conda-recipes/llvmdev/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ FOR /D %%d IN (llvm-*.src) DO (MKLINK /J llvm %%d
if !errorlevel! neq 0 exit /b %errorlevel%)
FOR /D %%d IN (lld-*.src) DO (MKLINK /J lld %%d
if !errorlevel! neq 0 exit /b %errorlevel%)
FOR /D %%d IN (rt\compiler-rt-*.src) DO (MKLINK /J compiler-rt %%d
if !errorlevel! neq 0 exit /b %errorlevel%)
FOR /D %%d IN (unwind\libunwind-*.src) DO (MKLINK /J libunwind %%d
if !errorlevel! neq 0 exit /b %errorlevel%)

Expand Down Expand Up @@ -33,18 +35,14 @@ REM the 64bit linker anyway. This must be passed in to certain generators as
REM '-Thost x64'.
set PreferredToolArchitecture=x64

set MAX_INDEX_CMAKE_GENERATOR=0

set "CMAKE_GENERATOR[0]=Visual Studio 16 2019"

set "CMAKE_GENERATOR_ARCHITECTURE[0]=%GEN_ARCH%"

set "CMAKE_GENERATOR_TOOLSET[0]=v142"
set "CMAKE_GENERATOR=Visual Studio 16 2019"
set "CMAKE_GENERATOR_ARCHITECTURE=%GEN_ARCH%"
set "CMAKE_GENERATOR_TOOLSET=v142"

REM Reduce build times and package size by removing unused stuff
REM BENCHMARKS (new for llvm8) don't build under Visual Studio 14 2015
set CMAKE_CUSTOM=-DLLVM_TARGETS_TO_BUILD="%LLVM_TARGETS_TO_BUILD%" ^
-DLLVM_ENABLE_PROJECTS:STRING=lld ^
-DLLVM_ENABLE_PROJECTS:STRING=lld;compiler-rt ^
-DLLVM_ENABLE_ZLIB=OFF ^
-DLLVM_INCLUDE_UTILS=ON ^
-DLLVM_INCLUDE_DOCS=OFF ^
Expand All @@ -53,28 +51,28 @@ set CMAKE_CUSTOM=-DLLVM_TARGETS_TO_BUILD="%LLVM_TARGETS_TO_BUILD%" ^
-DLLVM_USE_INTEL_JITEVENTS=ON ^
-DLLVM_INCLUDE_BENCHMARKS=OFF ^
-DLLVM_ENABLE_DIA_SDK=OFF ^
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly

REM try all compatible visual studio toolsets to find one that is installed
setlocal enabledelayedexpansion
for /l %%n in (0,1,%MAX_INDEX_CMAKE_GENERATOR%) do (
cmake -G "!CMAKE_GENERATOR[%%n]!" ^
-A "!CMAKE_GENERATOR_ARCHITECTURE[%%n]!" ^
-T "!CMAKE_GENERATOR_TOOLSET[%%n]!" ^
-DCMAKE_BUILD_TYPE="%BUILD_CONFIG%" ^
-DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^
-DCMAKE_INSTALL_PREFIX:PATH="%LIBRARY_PREFIX%" ^
%CMAKE_CUSTOM% "%SRC_DIR%\llvm"
if not errorlevel 1 goto configuration_successful
del CMakeCache.txt
)
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly ^
-DCOMPILER_RT_BUILD_LIBFUZZER:BOOL=OFF ^
-DCOMPILER_RT_BUILD_CRT:BOOL=OFF ^
-DCOMPILER_RT_BUILD_MEMPROF:BOOL=OFF ^
-DCOMPILER_RT_BUILD_PROFILE:BOOL=OFF ^
-DCOMPILER_RT_BUILD_SANITIZERS:BOOL=OFF ^
-DCOMPILER_RT_BUILD_XRAY:BOOL=OFF ^
-DCOMPILER_RT_BUILD_GWP_ASAN:BOOL=OFF ^
-DCOMPILER_RT_BUILD_ORC:BOOL=OFF ^
-DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF

cmake -G "%CMAKE_GENERATOR%" ^
-A "%CMAKE_GENERATOR_ARCHITECTURE%" ^
-T "%CMAKE_GENERATOR_TOOLSET%" ^
-DCMAKE_BUILD_TYPE="%BUILD_CONFIG%" ^
-DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^
-DCMAKE_INSTALL_PREFIX:PATH="%LIBRARY_PREFIX%" ^
%CMAKE_CUSTOM% "%SRC_DIR%\llvm"

REM no compatible visual studio toolset was found
if errorlevel 1 exit 1

:configuration_successful
endlocal

REM === Build step ===
cmake --build . --config "%BUILD_CONFIG%"
if errorlevel 1 exit 1
Expand All @@ -91,4 +89,4 @@ REM This is technically how to run the suite, but it will only run in an
REM enhanced unix-like shell which has functions like `grep` available.
REM cd ..\test
REM "%PYTHON%" "..\build\%BUILD_CONFIG%\bin\llvm-lit.py" -vv Transforms ExecutionEngine Analysis CodeGen/X86
REM if errorlevel 1 exit 1
if errorlevel 1 exit 1
18 changes: 16 additions & 2 deletions conda-recipes/llvmdev/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ LLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD:-"all"}
# This is the clang compiler prefix
if [[ $build_platform == osx-arm64 ]]; then
DARWIN_TARGET=arm64-apple-darwin20.0.0
DARWIN_ARCH=arm64
else
DARWIN_TARGET=x86_64-apple-darwin13.4.0
DARWIN_ARCH=arm64
fi

mv llvm-*.src llvm
mv lld-*.src lld
mv rt/compiler-rt-*.src compiler-rt
mv unwind/libunwind-*.src libunwind

declare -a _cmake_config
_cmake_config+=(-DCMAKE_INSTALL_PREFIX:PATH=${PREFIX})
_cmake_config+=(-DCMAKE_BUILD_TYPE:STRING=Release)
_cmake_config+=(-DLLVM_ENABLE_PROJECTS:STRING="lld")
_cmake_config+=(-DLLVM_ENABLE_PROJECTS:STRING="lld;compiler-rt")
# The bootstrap clang I use was built with a static libLLVMObject.a and I trying to get the same here
# _cmake_config+=(-DBUILD_SHARED_LIBS:BOOL=ON)
_cmake_config+=(-DLLVM_ENABLE_ASSERTIONS:BOOL=ON)
Expand All @@ -43,6 +46,17 @@ _cmake_config+=(-DLLVM_ENABLE_RTTI=OFF)
_cmake_config+=(-DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD})
_cmake_config+=(-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly)
_cmake_config+=(-DLLVM_INCLUDE_UTILS=ON) # for llvm-lit
_cmake_config+=(-DCOMPILER_RT_BUILD_BUILTINS:BOOL=ON)
_cmake_config+=(-DCOMPILER_RT_BUILD_LIBFUZZER:BOOL=OFF)
_cmake_config+=(-DCOMPILER_RT_BUILD_CRT:BOOL=OFF)
_cmake_config+=(-DCOMPILER_RT_BUILD_MEMPROF:BOOL=OFF)
_cmake_config+=(-DCOMPILER_RT_BUILD_PROFILE:BOOL=OFF)
_cmake_config+=(-DCOMPILER_RT_BUILD_SANITIZERS:BOOL=OFF)
_cmake_config+=(-DCOMPILER_RT_BUILD_XRAY:BOOL=OFF)
_cmake_config+=(-DCOMPILER_RT_BUILD_GWP_ASAN:BOOL=OFF)
_cmake_config+=(-DCOMPILER_RT_BUILD_ORC:BOOL=OFF)
_cmake_config+=(-DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF)
_cmake_config+=(-DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF) # Requires clang to be built
_cmake_config+=(-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF) # doesn't build without the rest of LLVM project
# TODO :: It would be nice if we had a cross-ecosystem 'BUILD_TIME_LIMITED' env var we could use to
# disable these unnecessary but useful things.
Expand All @@ -63,7 +77,7 @@ if [[ $(uname) == Darwin ]]; then
# Once we are using our libc++ (not until llvm_build_final), it will be single-arch only and not setting
# this causes link failures building the santizers since they respect DARWIN_osx_ARCHS. We may as well
# save some compilation time by setting this for all of our llvm builds.
_cmake_config+=(-DDARWIN_osx_ARCHS=x86_64)
_cmake_config+=(-DDARWIN_osx_ARCHS=${DARWIN_ARCH})
elif [[ $(uname) == Linux ]]; then
_cmake_config+=(-DLLVM_USE_INTEL_JITEVENTS=ON)
# _cmake_config+=(-DLLVM_BINUTILS_INCDIR=${PREFIX}/lib/gcc/${cpu_arch}-${vendor}-linux-gnu/${compiler_ver}/plugin/include)
Expand Down
11 changes: 10 additions & 1 deletion conda-recipes/llvmdev/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{% set sha256_llvm = "050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a" %}
{% set sha256_lld = "0c28ce0496934d37d20fec96591032dd66af8d10178a45762e0e75e85cf95ad3" %}
{% set sha256_libunwind = "3bbe9c23c73259fe39c045dc87d0b283236ba6e00750a226b2c2aeac4a51d86b" %}
{% set build_number = "3" %}
{% set sha256_compiler_rt = "88df303840ca8fbff944e15e61c141226fe79f5d2b8e89fb024264d77841a02e" %}
{% set build_number = "4" %}

package:
name: llvmdev
Expand All @@ -26,6 +27,14 @@ source:
sha256: {{ sha256_libunwind }}
folder: unwind

- url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ version }}/compiler-rt-{{ version }}.src.tar.xz
fn: compiler-rt-{{ version }}.src.tar.xz
sha256: {{ sha256_compiler_rt }}
folder: rt
patches:
- ../compiler-rt-14-fp-xstate-magic1.patch
- ../compiler-rt-windows-build.patch

build:
number: {{ build_number }}
script_env:
Expand Down
43 changes: 43 additions & 0 deletions conda-recipes/llvmdev_manylinux2014/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fi

mv llvm-*.src llvm
mv lld-*.src lld
mv rt/compiler-rt-*.src compiler-rt
mv unwind/libunwind-*.src libunwind

declare -a _cmake_config
Expand Down Expand Up @@ -93,3 +94,45 @@ make check-llvm-unit || exit $?

# From: https://github.com/conda-forge/llvmdev-feedstock/pull/53
make install || exit $?

# run the tests, skip some on linux-32
cd ../test
if [[ $ARCH == 'i686' ]]; then
../build/bin/llvm-lit -vv Transforms Analysis CodeGen/X86
else
../build/bin/llvm-lit -vv Transforms ExecutionEngine Analysis CodeGen/X86
fi

# Next, build compiler-rt

declare -a _compiler_rt_cmake_config
_compiler_rt_cmake_config+=(-DCMAKE_INSTALL_PREFIX:PATH=${PREFIX})
_compiler_rt_cmake_config+=(-DCMAKE_BUILD_TYPE:STRING=Release)
_compiler_rt_cmake_config+=(-DCOMPILER_RT_BUILD_BUILTINS:BOOL=ON)
_compiler_rt_cmake_config+=(-DCOMPILER_RT_BUILD_LIBFUZZER:BOOL=OFF)
_compiler_rt_cmake_config+=(-DCOMPILER_RT_BUILD_CRT:BOOL=OFF)
_compiler_rt_cmake_config+=(-DCOMPILER_RT_BUILD_MEMPROF:BOOL=OFF)
_compiler_rt_cmake_config+=(-DCOMPILER_RT_BUILD_PROFILE:BOOL=OFF)
_compiler_rt_cmake_config+=(-DCOMPILER_RT_BUILD_SANITIZERS:BOOL=OFF)
_compiler_rt_cmake_config+=(-DCOMPILER_RT_BUILD_XRAY:BOOL=OFF)
_compiler_rt_cmake_config+=(-DCOMPILER_RT_BUILD_GWP_ASAN:BOOL=OFF)
_compiler_rt_cmake_config+=(-DCOMPILER_RT_BUILD_ORC:BOOL=OFF)
_compiler_rt_cmake_config+=(-DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF)
_compiler_rt_cmake_config+=(-DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF)
_compiler_rt_cmake_config+=(-DLLVM_CONFIG_PATH=../../llvm/build/bin/llvm-config)

cd ../../compiler-rt
mkdir build
cd build

cmake -G'Unix Makefiles' \
"${_compiler_rt_cmake_config[@]}" \
..

if [ $ARCH == 'armv7l' ]; then # RPi need thread count throttling
make -j2 VERBOSE=1
else
make -j${CPU_COUNT} VERBOSE=1
fi

make install
10 changes: 10 additions & 0 deletions conda-recipes/llvmdev_manylinux2014/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
{% set sha256_lld = "0c28ce0496934d37d20fec96591032dd66af8d10178a45762e0e75e85cf95ad3" %}
{% set sha256_libunwind = "3bbe9c23c73259fe39c045dc87d0b283236ba6e00750a226b2c2aeac4a51d86b" %}
{% set build_number = "1" %}
{% set sha256_compiler_rt = "88df303840ca8fbff944e15e61c141226fe79f5d2b8e89fb024264d77841a02e" %}
{% set build_number = "2" %}

package:
name: llvmdev
Expand All @@ -17,6 +19,7 @@ source:
- ../llvm14-clear-gotoffsetmap.patch
- ../llvm14-remove-use-of-clonefile.patch
- ../llvm14-svml.patch

- url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ version }}/lld-{{ version }}.src.tar.xz
fn: lld-{{ version }}.src.tar.xz
sha256: {{ sha256_lld }}
Expand All @@ -26,6 +29,13 @@ source:
sha256: {{ sha256_libunwind }}
folder: unwind

- url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ version }}/compiler-rt-{{ version }}.src.tar.xz
fn: compiler-rt-{{ version }}.src.tar.xz
sha256: {{ sha256_compiler_rt }}
folder: rt
patches:
- ../compiler-rt-14-fp-xstate-magic1.patch

build:
number: {{ build_number }}
string: "manylinux2014h{{ PKG_HASH }}"
Expand Down