Skip to content
54 changes: 53 additions & 1 deletion 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,13 +35,16 @@ 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 MAX_INDEX_CMAKE_GENERATOR=1

set "CMAKE_GENERATOR[0]=Visual Studio 16 2019"
set "CMAKE_GENERATOR[1]=Visual Studio 17 2022"

set "CMAKE_GENERATOR_ARCHITECTURE[0]=%GEN_ARCH%"
set "CMAKE_GENERATOR_ARCHITECTURE[1]=%GEN_ARCH%"

set "CMAKE_GENERATOR_TOOLSET[0]=v142"
set "CMAKE_GENERATOR_TOOLSET[1]=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
Expand All @@ -53,6 +58,8 @@ 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_ENABLE_LIBXML2:BOOL=OFF ^
-DCLANG_ENABLE_LIBXML=OFF ^
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly

REM try all compatible visual studio toolsets to find one that is installed
Expand Down Expand Up @@ -92,3 +99,48 @@ 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


REM Build compiler-rt separately, because it fails on Windows with LLVM 14.0.6
REM if built as an LLVM project.
REM See also: https://stackoverflow.com/questions/46108390/building-llvm-with-cmake-and-visual-stuidio-fails-to-install

cd "%SRC_DIR%\compiler-rt"
mkdir build
cd build

set CMAKE_CUSTOM=-DCOMPILER_RT_BUILD_BUILTINS:BOOL=ON ^
-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 ^
-DLLVM_CONFIG_PATH="%SRC_DIR%\build\%BUILD_CONFIG%\bin\llvm-config.exe"

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% ..
if not errorlevel 1 goto crt_configuration_successful
del CMakeCache.txt
)
if errorlevel 1 exit 1

:crt_configuration_successful
endlocal

cmake --build . --config "%BUILD_CONFIG%"
if errorlevel 1 exit 1

cmake --build . --config "%BUILD_CONFIG%" --target install
if errorlevel 1 exit 1
13 changes: 12 additions & 1 deletion conda-recipes/llvmdev/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ 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 +44,16 @@ _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+=(-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 Down
6 changes: 6 additions & 0 deletions conda-recipes/llvmdev/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% set sha256_llvm = "050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a" %}
{% set sha256_lld = "0c28ce0496934d37d20fec96591032dd66af8d10178a45762e0e75e85cf95ad3" %}
{% set sha256_libunwind = "3bbe9c23c73259fe39c045dc87d0b283236ba6e00750a226b2c2aeac4a51d86b" %}
{% set sha256_compiler_rt = "88df303840ca8fbff944e15e61c141226fe79f5d2b8e89fb024264d77841a02e" %}
{% set build_number = "3" %}

package:
Expand All @@ -26,6 +27,11 @@ 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

build:
number: {{ build_number }}
script_env:
Expand Down
42 changes: 42 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,44 @@ 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+=(-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
8 changes: 8 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,11 @@ 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

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