Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build bolt #276

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
1 change: 0 additions & 1 deletion .scripts/build_steps.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cmake -G "Ninja" ^
-DLLVM_USE_INTEL_JITEVENTS=ON ^
-DLLVM_ENABLE_DUMP=ON ^
-DLLVM_ENABLE_LIBXML2=FORCE_ON ^
-DLLVM_ENABLE_PROJECTS="bolt" ^
-DLLVM_ENABLE_RTTI=ON ^
-DLLVM_ENABLE_ZLIB=FORCE_ON ^
-DLLVM_ENABLE_ZSTD=FORCE_ON ^
Expand All @@ -25,6 +26,7 @@ cmake -G "Ninja" ^
-DLLVM_INCLUDE_TESTS=ON ^
-DLLVM_INCLUDE_UTILS=ON ^
-DLLVM_INSTALL_UTILS=ON ^
-DLLVM_TARGETS_TO_BUILD="X86;AArch64" ^
-DLLVM_USE_SYMLINKS=OFF ^
-DLLVM_UTILS_INSTALL_DIR=libexec\llvm ^
-DLLVM_BUILD_LLVM_C_DYLIB=ON ^
Expand All @@ -39,5 +41,7 @@ if %ERRORLEVEL% neq 0 exit 1
REM bin\opt -S -vector-library=SVML -mcpu=haswell -O3 %RECIPE_DIR%\numba-3016.ll | bin\FileCheck %RECIPE_DIR%\numba-3016.ll
REM if %ERRORLEVEL% neq 0 exit 1

cd ..\llvm\test
python ..\..\build\bin\llvm-lit.py -vv Transforms ExecutionEngine Analysis CodeGen/X86
:: :: takes ~30min; disabled due to timeouts
:: cd ..\llvm\test
:: python ..\..\build\bin\llvm-lit.py -vv Transforms ExecutionEngine Analysis CodeGen/X86
:: if %ERRORLEVEL% neq 0 exit 1
14 changes: 7 additions & 7 deletions recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set -x
#!/bin/bash
set -ex

# Make osx work like linux.
sed -i.bak "s/NOT APPLE AND ARG_SONAME/ARG_SONAME/g" llvm/cmake/modules/AddLLVM.cmake
Expand All @@ -14,7 +15,7 @@ elif [[ "$target_platform" == osx-* ]]; then
# https://github.com/llvm/llvm-project/blob/llvmorg-16.0.6/llvm/tools/llvm-shlib/CMakeLists.txt#L82-L85
# currently off though, because it doesn't build yet
# CMAKE_ARGS="${CMAKE_ARGS} -DLLVM_BUILD_LLVM_C_DYLIB=ON"
true
CMAKE_ARGS="${CMAKE_ARGS} -DLLVM_TARGETS_TO_BUILD=X86;AArch64"
fi

if [[ "$CC_FOR_BUILD" != "" && "$CC_FOR_BUILD" != "$CC" ]]; then
Expand All @@ -38,6 +39,7 @@ cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" \
-DLLVM_ENABLE_DUMP=ON \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_LIBXML2=FORCE_ON \
-DLLVM_ENABLE_PROJECTS="bolt" \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_ZLIB=FORCE_ON \
Expand Down Expand Up @@ -67,17 +69,15 @@ else
export TEST_CPU_FLAG=""
fi

# should be [[ "$CONDA_BUILD_CROSS_COMPILATION" != "1" ]],
# but osx builds time out when building & running test suite
if [[ "$target_platform" == "linux-64" ]]; then
if [[ "$CONDA_BUILD_CROSS_COMPILATION" != "1" ]]; then
# bin/opt -S -vector-library=SVML $TEST_CPU_FLAG -O3 $RECIPE_DIR/numba-3016.ll | bin/FileCheck $RECIPE_DIR/numba-3016.ll || exit $?

if [[ "$target_platform" == linux* ]]; then
ln -s $(which $CC) $BUILD_PREFIX/bin/gcc
# check-llvm takes >1.5h to build & run on osx
ninja -j${CPU_COUNT} check-llvm
fi

ninja -j${CPU_COUNT} check-llvm

cd ../llvm/test
python ../../build/bin/llvm-lit -vv Transforms ExecutionEngine Analysis CodeGen/X86
fi
13 changes: 13 additions & 0 deletions recipe/install_llvm.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ if "%PKG_NAME%" == "libllvm-c%PKG_VERSION:~0,2%" (
REM only libLLVM-C
move .\temp_prefix\bin\LLVM-C.dll %LIBRARY_BIN%
move .\temp_prefix\lib\LLVM-C.lib %LIBRARY_LIB%
) else if "%PKG_NAME%" == "libbolt" (
cmake --install ./build --prefix=./temp_prefix
if %ERRORLEVEL% neq 0 exit 1
REM only bolt libraries
mkdir %LIBRARY_LIB%
move .\temp_prefix\lib\LLVMBOLT*.lib %LIBRARY_LIB%
) else if "%PKG_NAME%" == "bolt" (
cmake --install ./build --prefix=./temp_prefix
if %ERRORLEVEL% neq 0 exit 1
REM only bolt binaries
mkdir %LIBRARY_BIN%
move .\temp_prefix\bin\llvm-bolt*.exe %LIBRARY_BIN%
move .\temp_prefix\bin\perf2bolt.exe %LIBRARY_BIN%
) else if "%PKG_NAME%" == "llvm-tools" (
cmake --install ./build --prefix=./temp_prefix
if %ERRORLEVEL% neq 0 exit 1
Expand Down
13 changes: 13 additions & 0 deletions recipe/install_llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ elif [[ "${PKG_NAME}" == libllvm* ]]; then
mv ./temp_prefix/lib/libLLVM-${MAJOR_EXT}${SHLIB_EXT} $PREFIX/lib
mv ./temp_prefix/lib/lib*.so.${SOVER_EXT} $PREFIX/lib || true
mv ./temp_prefix/lib/lib*.${SOVER_EXT}.dylib $PREFIX/lib || true
elif [[ "${PKG_NAME}" == "libbolt" ]]; then
cmake --install ./build --prefix=./temp_prefix
# only bolt libraries
mkdir -p $PREFIX/lib
mv ./temp_prefix/lib/libLLVMBOLT* $PREFIX/lib
# only on linux
mv ./temp_prefix/lib/libbolt* $PREFIX/lib || true
elif [[ "${PKG_NAME}" == "bolt" ]]; then
cmake --install ./build --prefix=./temp_prefix
# only bolt binaries
mkdir -p $PREFIX/bin
mv ./temp_prefix/bin/llvm-bolt* $PREFIX/bin
mv ./temp_prefix/bin/perf2bolt $PREFIX/bin
elif [[ "${PKG_NAME}" == "llvm-tools" ]]; then
cmake --install ./build --prefix=./temp_prefix
# everything in /bin & /share
Expand Down
89 changes: 81 additions & 8 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ source:
- patches/0002-lljit-respect-codemodel.patch

build:
number: 1
number: 2
merge_build_host: false

requirements:
Expand Down Expand Up @@ -62,13 +62,17 @@ outputs:
- {{ pin_subpackage("libllvm" + major_ver, exact=True) }}
- {{ pin_subpackage("libllvm-c" + major_ver, exact=True) }} # [win]
- {{ pin_subpackage("llvm-tools", exact=True) }}
- libxml2
- zlib
- zstd
# only here to avoid picking up the files twice
- {{ pin_subpackage("libbolt", exact=True) }}
- {{ pin_subpackage("bolt", exact=True) }}
run:
# bolt is built in this feedstock, but intentionally not part of llvmdev
- {{ pin_subpackage("libllvm" + major_ver, exact=True) }}
- {{ pin_subpackage("libllvm-c" + major_ver, exact=True) }} # [win]
- {{ pin_subpackage("llvm-tools", exact=True) }}
# we need to do this manually because clang_bootstrap has no run-export
- libcxx >={{ cxx_compiler_version }} # [osx]
run_constrained:
- llvm {{ version }}
Expand Down Expand Up @@ -111,10 +115,11 @@ outputs:
- libcxx {{ cxx_compiler_version }} # [osx]
host:
- libcxx {{ cxx_compiler_version }} # [osx]
- libxml2
- libxml2 # [unix]
- zlib
- zstd
run:
# we need to do this manually because clang_bootstrap has no run-export
- libcxx >={{ cxx_compiler_version }} # [osx]
test:
commands:
Expand Down Expand Up @@ -149,6 +154,70 @@ outputs:
commands:
- echo "Hello World!"

# Contains bolt support libraries
- name: libbolt
script: install_llvm.sh # [unix]
script: install_llvm.bat # [win]
build:
activate_in_script: true
requirements:
build:
- {{ stdlib('c') }}
- {{ compiler('cxx') }}
- cmake
- ninja
- libcxx {{ cxx_compiler_version }} # [osx]
run_constrained:
- llvm {{ version }}
- llvmdev {{ version }}
- clang {{ version }}
- clang-tools {{ version }}
test:
commands:
{% for each_lib in [
"Core", "Passes", "Profile", "Rewrite", "RuntimeLibs",
"TargetAArch64", "TargetX86", "Utils"
] %}
- test -f $PREFIX/lib/libLLVMBOLT{{ each_lib }}.a # [unix]
h-vetinari marked this conversation as resolved.
Show resolved Hide resolved
- if not exist %LIBRARY_LIB%\LLVMBOLT{{ each_lib }}.lib exit 1 # [win]
{% endfor %}
# only on linux-64
- test -f $PREFIX/lib/libbolt_rt_hugify.a # [linux64]
- test -f $PREFIX/lib/libbolt_rt_instr.a # [linux64]

# Contains bolt
- name: bolt
script: install_llvm.sh # [unix]
script: install_llvm.bat # [win]
build:
activate_in_script: true
requirements:
build:
- {{ stdlib('c') }}
- {{ compiler('cxx') }}
- cmake
- ninja
- libcxx {{ cxx_compiler_version }} # [osx]
host:
- libcxx {{ cxx_compiler_version }} # [osx]
- zlib
- zstd
run:
- {{ pin_subpackage("libbolt", exact=True) }}
# we need to do this manually because clang_bootstrap has no run-export
- libcxx >={{ cxx_compiler_version }} # [osx]
run_constrained:
- llvm {{ version }}
- llvmdev {{ version }}
- clang {{ version }}
- clang-tools {{ version }}
test:
commands:
- llvm-bolt -version
- llvm-boltdiff -version
- llvm-bolt-heatmap -version
- perf2bolt -version

# Contains LLVM tools
- name: llvm-tools
script: install_llvm.sh # [unix]
Expand All @@ -166,21 +235,26 @@ outputs:
host:
- libcxx {{ cxx_compiler_version }} # [osx]
- {{ pin_subpackage("libllvm" + major_ver, exact=True) }}
- libxml2
# bolt is only in host to avoid picking up the binary again in llvm-tools
- {{ pin_subpackage("bolt", exact=True) }}
- libxml2 # [win]
- zlib
- zstd
run:
- {{ pin_subpackage("libllvm" + major_ver, exact=True) }}
# we need to do this manually because clang_bootstrap has no run-export
- libcxx >={{ cxx_compiler_version }} # [osx]
run_constrained:
- llvm {{ version }}
- llvmdev {{ version }}
- clang {{ version }}
- clang-tools {{ version }}
test:
commands:
- $PREFIX/bin/llc -version # [not win]
- if not exist "%LIBRARY_BIN%"\\llc.exe exit 1 # [win]
- llc -version # [win]
- llc -version
# absence of bolt
- test ! -f $PREFIX/bin/llvm-bolt # [unix]
- if exist %LIBRARY_BIN%\llvm-bolt.exe exit 1 # [win]

# Contains LLVM-C shared library
- name: libllvm-c{{ major_ver }}
Expand All @@ -204,7 +278,6 @@ outputs:
host:
- libcxx {{ cxx_compiler_version }} # [osx]
- {{ pin_subpackage("libllvm" + major_ver, exact=True) }}
- libxml2
- zlib
- zstd
run_constrained:
Expand Down