From 219f28627e555b723c3981e77b359c933d2b03de Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam <1929845+sklam@users.noreply.github.com> Date: Wed, 13 Nov 2024 10:15:56 -0600 Subject: [PATCH 1/4] Fix manylinux llvmdev build --- .../{manylinux_2_17 => manylinux}/README.md | 21 ++-- buildscripts/manylinux/build_llvmdev.sh | 8 ++ .../build_llvmlite.sh | 4 +- .../docker_run.sh | 3 +- .../docker_run_aarch64.sh} | 5 +- .../docker_run_x64.sh | 4 +- buildscripts/manylinux/prepare_miniconda.sh | 11 ++ buildscripts/manylinux_2_17/build_llvmdev.sh | 10 -- .../manylinux_2_17/configure_conda.sh | 6 - .../manylinux_2_17/docker_run_aarch64.sh | 4 - .../manylinux_2_17/prepare_miniconda.sh | 9 -- conda-recipes/llvmdev_manylinux/build.sh | 116 ++++++++++++++++++ conda-recipes/llvmdev_manylinux/meta.yaml | 74 +++++++++++ conda-recipes/llvmdev_manylinux2014/build.sh | 95 -------------- conda-recipes/llvmdev_manylinux2014/meta.yaml | 77 ------------ 15 files changed, 228 insertions(+), 219 deletions(-) rename buildscripts/{manylinux_2_17 => manylinux}/README.md (53%) create mode 100755 buildscripts/manylinux/build_llvmdev.sh rename buildscripts/{manylinux_2_17 => manylinux}/build_llvmlite.sh (86%) rename buildscripts/{manylinux_2_17 => manylinux}/docker_run.sh (52%) rename buildscripts/{manylinux_2_17/docker_run_x32.sh => manylinux/docker_run_aarch64.sh} (54%) rename buildscripts/{manylinux_2_17 => manylinux}/docker_run_x64.sh (55%) create mode 100755 buildscripts/manylinux/prepare_miniconda.sh delete mode 100755 buildscripts/manylinux_2_17/build_llvmdev.sh delete mode 100755 buildscripts/manylinux_2_17/configure_conda.sh delete mode 100755 buildscripts/manylinux_2_17/docker_run_aarch64.sh delete mode 100755 buildscripts/manylinux_2_17/prepare_miniconda.sh create mode 100644 conda-recipes/llvmdev_manylinux/build.sh create mode 100644 conda-recipes/llvmdev_manylinux/meta.yaml delete mode 100644 conda-recipes/llvmdev_manylinux2014/build.sh delete mode 100644 conda-recipes/llvmdev_manylinux2014/meta.yaml diff --git a/buildscripts/manylinux_2_17/README.md b/buildscripts/manylinux/README.md similarity index 53% rename from buildscripts/manylinux_2_17/README.md rename to buildscripts/manylinux/README.md index 31381a62d..a696a4023 100644 --- a/buildscripts/manylinux_2_17/README.md +++ b/buildscripts/manylinux/README.md @@ -1,29 +1,30 @@ -# README: Building manylinux_2_17 Wheels +# README: Building manylinux Wheels -## Build llvmdev packages for manylinux_2_17 +## Build llvmdev packages for manylinux Run the script below to start docker off building `llvmdev` base from the current state of the source tree: -- 32-bit linux: `./buildscripts/manylinux_2_17/docker_run_x32.sh build_llvmdev.sh` -- 64-bit linux: `./buildscripts/manylinux_2_17/docker_run_x64.sh build_llvmdev.sh` -- aarch64 linux: `./buildscripts/manylinux_2_17/docker_run_aaarch64.sh build_llvmdev.sh` +- 64-bit linux: `./buildscripts/manylinux/docker_run_x64.sh build_llvmdev.sh` + - uses manylinux2014 image for glibc 2.17+ +- aarch64 linux: `./buildscripts/manylinux/docker_run_aarch64.sh build_llvmdev.sh` + - uses manylinux_2_28 image for glibc 2.28+ The conda packages will be stored into `/docker_output` Note: the `docker_output` location can be used as a local conda channel. -Finally, upload the conda package to the numba channel under the "manylinux_2_17" label: +Finally, upload the conda package to the numba channel under the "manylinux_x_y" label: -`anaconda upload -u numba -l manylinux_2_17 ` +`anaconda upload -u numba -l manylinux_x_y ` -## Build llvmlite wheel for manylinux_2_17 +## Build llvmlite wheel for manylinux Run the script below to start docker off building `llvmlite` base from the current state of the source tree: -- 32-bit linux: `./buildscripts/manylinux_2_17/docker_run_x32.sh build_llvmlite.sh ` -- 64-bit linux: `./buildscripts/manylinux_2_17/docker_run_x64.sh build_llvmlite.sh ` +- 32-bit linux: `./buildscripts/manylinux/docker_run_x32.sh build_llvmlite.sh ` +- 64-bit linux: `./buildscripts/manylinux/docker_run_x64.sh build_llvmlite.sh ` The conda packages will be stored into `/docker_output/dist__` diff --git a/buildscripts/manylinux/build_llvmdev.sh b/buildscripts/manylinux/build_llvmdev.sh new file mode 100755 index 000000000..f3bb39d96 --- /dev/null +++ b/buildscripts/manylinux/build_llvmdev.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -xe +cd $(dirname $0) +source ./prepare_miniconda.sh $1 +conda activate buildenv +conda list +echo "BUILD_CHANNELS: $BUILD_CHANNELS" +conda-build $BUILD_CHANNELS /root/llvmlite/conda-recipes/llvmdev_manylinux --output-folder=/root/llvmlite/docker_output diff --git a/buildscripts/manylinux_2_17/build_llvmlite.sh b/buildscripts/manylinux/build_llvmlite.sh similarity index 86% rename from buildscripts/manylinux_2_17/build_llvmlite.sh rename to buildscripts/manylinux/build_llvmlite.sh index 970df7c25..86607fb79 100755 --- a/buildscripts/manylinux_2_17/build_llvmlite.sh +++ b/buildscripts/manylinux/build_llvmlite.sh @@ -21,9 +21,9 @@ source activate $envname # Install llvmdev if [[ $ARCH == "aarch64" ]] ; then - conda install -y numba/label/manylinux2014::llvmdev --no-deps + conda install -y numba/label/manylinux_2_28::llvmdev else - conda install -y -c numba/label/manylinux2014 llvmdev + conda install -y numba/label/manylinux_2_17::llvmdev fi # Prepend builtin Python Path diff --git a/buildscripts/manylinux_2_17/docker_run.sh b/buildscripts/manylinux/docker_run.sh similarity index 52% rename from buildscripts/manylinux_2_17/docker_run.sh rename to buildscripts/manylinux/docker_run.sh index beb0233ab..d6c67fcdf 100755 --- a/buildscripts/manylinux_2_17/docker_run.sh +++ b/buildscripts/manylinux/docker_run.sh @@ -1,7 +1,8 @@ #!/bin/bash +set -xe # Use this to make the llvmdev packages that are manylinux2010 compatible srcdir=$( cd "$(dirname $0)/../.." && pwd ) echo "srcdir=$srcdir" echo "MINICONDA_FILE=$MINICONDA_FILE" -docker run -it -e "ARCH=$ARCH" -v $srcdir:/root/llvmlite quay.io/pypa/manylinux2014_${ARCH} ${PRECMD} /root/llvmlite/buildscripts/manylinux_2_17/$1 ${MINICONDA_FILE} $2 +docker run --rm -it -e "ARCH=$ARCH" -v $srcdir:/root/llvmlite quay.io/pypa/${MANYLINUX_IMAGE} ${PRECMD} /root/llvmlite/buildscripts/manylinux/$1 ${MINICONDA_FILE} $2 diff --git a/buildscripts/manylinux_2_17/docker_run_x32.sh b/buildscripts/manylinux/docker_run_aarch64.sh similarity index 54% rename from buildscripts/manylinux_2_17/docker_run_x32.sh rename to buildscripts/manylinux/docker_run_aarch64.sh index a107f40a9..26536a563 100755 --- a/buildscripts/manylinux_2_17/docker_run_x32.sh +++ b/buildscripts/manylinux/docker_run_aarch64.sh @@ -1,5 +1,4 @@ -export ARCH="i686" -export PRECMD="linux32" -export MINICONDA_FILE="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86.sh" +export MANYLINUX_IMAGE="manylinux_2_28_aarch64" +export MINICONDA_FILE="https://repo.anaconda.com/miniconda/Miniconda3-py311_24.9.2-0-Linux-aarch64.sh" cd $(dirname $0) ./docker_run.sh $1 $2 diff --git a/buildscripts/manylinux_2_17/docker_run_x64.sh b/buildscripts/manylinux/docker_run_x64.sh similarity index 55% rename from buildscripts/manylinux_2_17/docker_run_x64.sh rename to buildscripts/manylinux/docker_run_x64.sh index 1731d1647..a6d57aafd 100755 --- a/buildscripts/manylinux_2_17/docker_run_x64.sh +++ b/buildscripts/manylinux/docker_run_x64.sh @@ -1,4 +1,4 @@ -export ARCH="x86_64" -export MINICONDA_FILE="https://repo.anaconda.com/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh" +export MANYLINUX_IMAGE="manylinux2014_x86_64" +export MINICONDA_FILE="https://repo.anaconda.com/miniconda/Miniconda3-py311_24.9.2-0-Linux-x86_64.sh" cd $(dirname $0) ./docker_run.sh $1 $2 diff --git a/buildscripts/manylinux/prepare_miniconda.sh b/buildscripts/manylinux/prepare_miniconda.sh new file mode 100755 index 000000000..ecf082f21 --- /dev/null +++ b/buildscripts/manylinux/prepare_miniconda.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +cd /root +curl -L -o mini3.sh $1 +bash mini3.sh -b -f -p $HOME/miniconda3 +echo "Miniconda installed" +source $HOME/miniconda3/bin/activate base +echo "Env activated" +cd /root/llvmlite/buildscripts/manylinux +conda create -n buildenv -y conda conda-build + diff --git a/buildscripts/manylinux_2_17/build_llvmdev.sh b/buildscripts/manylinux_2_17/build_llvmdev.sh deleted file mode 100755 index e32469e9f..000000000 --- a/buildscripts/manylinux_2_17/build_llvmdev.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -cd $(dirname $0) -source ./prepare_miniconda.sh $1 -source /root/miniconda3/bin/activate buildenv -if [[ $ARCH == "aarch64" ]] ; then - export BUILD_CHANNELS="-c conda-forge" -fi -echo "BUILD_CHANNELS: $BUILD_CHANNELS" -conda-build $BUILD_CHANNELS /root/llvmlite/conda-recipes/llvmdev_manylinux2014 --output-folder=/root/llvmlite/docker_output diff --git a/buildscripts/manylinux_2_17/configure_conda.sh b/buildscripts/manylinux_2_17/configure_conda.sh deleted file mode 100755 index 82c8d497c..000000000 --- a/buildscripts/manylinux_2_17/configure_conda.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# Setup miniconda environment that is compatible with manylinux2014 docker image -conda create -n buildenv -y conda conda-build anaconda-client -source /root/miniconda3/bin/activate buildenv -conda env list -conda install -y conda-build anaconda-client diff --git a/buildscripts/manylinux_2_17/docker_run_aarch64.sh b/buildscripts/manylinux_2_17/docker_run_aarch64.sh deleted file mode 100755 index 03f4a4701..000000000 --- a/buildscripts/manylinux_2_17/docker_run_aarch64.sh +++ /dev/null @@ -1,4 +0,0 @@ -export ARCH="aarch64" -export MINICONDA_FILE="https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh" -cd $(dirname $0) -./docker_run.sh $1 $2 diff --git a/buildscripts/manylinux_2_17/prepare_miniconda.sh b/buildscripts/manylinux_2_17/prepare_miniconda.sh deleted file mode 100755 index 369354b8e..000000000 --- a/buildscripts/manylinux_2_17/prepare_miniconda.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -e -cd /root -curl -L $1 > mini3.sh -bash mini3.sh -b -f -p $HOME/miniconda3 -source /root/miniconda3/bin/activate root - -cd /root/llvmlite/buildscripts/manylinux_2_17 -./configure_conda.sh diff --git a/conda-recipes/llvmdev_manylinux/build.sh b/conda-recipes/llvmdev_manylinux/build.sh new file mode 100644 index 000000000..fcccc8361 --- /dev/null +++ b/conda-recipes/llvmdev_manylinux/build.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +# based on https://github.com/AnacondaRecipes/llvmdev-feedstock/blob/master/recipe/build.sh + +set -x + +# Make osx work like linux. +sed -i.bak "s/NOT APPLE AND ARG_SONAME/ARG_SONAME/g" llvm/cmake/modules/AddLLVM.cmake +sed -i.bak "s/NOT APPLE AND NOT ARG_SONAME/NOT ARG_SONAME/g" llvm/cmake/modules/AddLLVM.cmake + +mkdir build +cd build + +export CPU_COUNT=4 + +CMAKE_ARGS="${CMAKE_ARGS} -DLLVM_ENABLE_PROJECTS=lld;libunwind;compiler-rt" + +if [[ "$target_platform" == "linux-64" ]]; then + CMAKE_ARGS="${CMAKE_ARGS} -DLLVM_USE_INTEL_JITEVENTS=ON" +fi + +if [[ "$CC_FOR_BUILD" != "" && "$CC_FOR_BUILD" != "$CC" ]]; then + CMAKE_ARGS="${CMAKE_ARGS} -DCROSS_TOOLCHAIN_FLAGS_NATIVE=-DCMAKE_C_COMPILER=$CC_FOR_BUILD;-DCMAKE_CXX_COMPILER=$CXX_FOR_BUILD;-DCMAKE_C_FLAGS=-O2;-DCMAKE_CXX_FLAGS=-O2;-DCMAKE_EXE_LINKER_FLAGS=-Wl,-rpath,${BUILD_PREFIX}/lib;-DCMAKE_MODULE_LINKER_FLAGS=;-DCMAKE_SHARED_LINKER_FLAGS=;-DCMAKE_STATIC_LINKER_FLAGS=;-DLLVM_INCLUDE_BENCHMARKS=OFF;" + CMAKE_ARGS="${CMAKE_ARGS} -DLLVM_HOST_TRIPLE=$(echo $HOST | sed s/conda/unknown/g) -DLLVM_DEFAULT_TARGET_TRIPLE=$(echo $HOST | sed s/conda/unknown/g)" +fi + +# disable -fno-plt due to https://bugs.llvm.org/show_bug.cgi?id=51863 due to some GCC bug +if [[ "$target_platform" == "linux-ppc64le" ]]; then + CFLAGS="$(echo $CFLAGS | sed 's/-fno-plt //g')" + CXXFLAGS="$(echo $CXXFLAGS | sed 's/-fno-plt //g')" + CMAKE_ARGS="${CMAKE_ARGS} -DFFI_INCLUDE_DIR=$PREFIX/include" + CMAKE_ARGS="${CMAKE_ARGS} -DFFI_LIBRARY_DIR=$PREFIX/lib" +fi + +if [[ $target_platform == osx-arm64 ]]; then + CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_ENABLE_WERROR=FALSE" +fi + +cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_LIBRARY_PATH="${PREFIX}" \ + -DLLVM_ENABLE_ZSTD=OFF \ + -DLLVM_ENABLE_LIBEDIT=OFF \ + -DLLVM_ENABLE_LIBXML2=OFF \ + -DLLVM_ENABLE_RTTI=ON \ + -DLLVM_ENABLE_TERMINFO=OFF \ + -DLLVM_INCLUDE_BENCHMARKS=OFF \ + -DLLVM_INCLUDE_DOCS=OFF \ + -DLLVM_INCLUDE_EXAMPLES=OFF \ + -DLLVM_INCLUDE_GO_TESTS=OFF \ + -DLLVM_INCLUDE_TESTS=ON \ + -DLLVM_INCLUDE_UTILS=ON \ + -DLLVM_INSTALL_UTILS=ON \ + -DLLVM_UTILS_INSTALL_DIR=libexec/llvm \ + -DLLVM_BUILD_LLVM_DYLIB=OFF \ + -DLLVM_LINK_LLVM_DYLIB=OFF \ + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly \ + -DLLVM_ENABLE_FFI=ON \ + -DLLVM_ENABLE_Z3_SOLVER=OFF \ + -DLLVM_OPTIMIZED_TABLEGEN=ON \ + -DCMAKE_POLICY_DEFAULT_CMP0111=NEW \ + -DCOMPILER_RT_BUILD_BUILTINS=ON \ + -DCOMPILER_RT_BUILTINS_HIDE_SYMBOLS=OFF \ + -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \ + -DCOMPILER_RT_BUILD_CRT=OFF \ + -DCOMPILER_RT_BUILD_MEMPROF=OFF \ + -DCOMPILER_RT_BUILD_PROFILE=OFF \ + -DCOMPILER_RT_BUILD_SANITIZERS=OFF \ + -DCOMPILER_RT_BUILD_XRAY=OFF \ + -DCOMPILER_RT_BUILD_GWP_ASAN=OFF \ + -DCOMPILER_RT_BUILD_ORC=OFF \ + -DCOMPILER_RT_INCLUDE_TESTS=OFF \ + ${CMAKE_ARGS} \ + -GNinja \ + ../llvm + + +ninja -j${CPU_COUNT} + +ninja install + +if [[ "${target_platform}" == "linux-64" || "${target_platform}" == "osx-64" ]]; then + export TEST_CPU_FLAG="-mcpu=haswell" +else + export TEST_CPU_FLAG="" +fi + +if [[ "$CONDA_BUILD_CROSS_COMPILATION" != "1" ]]; then + + echo "Testing on ${target_platform}" + # 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 + + # These tests tests permission-based behaviour and probably fail because of some + # filesystem-related reason. They are sporadic failures and don't seem serious so they're excluded. + # Note that indents would introduce spaces into the environment variable + export LIT_FILTER_OUT='tools/llvm-ar/error-opening-permission.test|'\ +'tools/llvm-dwarfdump/X86/output.s|'\ +'tools/llvm-ifs/fail-file-write.test|'\ +'tools/llvm-ranlib/error-opening-permission.test|'\ +'ExecutionEngine/Interpreter/intrinsics.ll' + fi + + if [[ "$target_platform" == osx-* ]]; then + # This failure seems like something to do with the output format of ls -lu + # and looks harmless + export LIT_FILTER_OUT='tools/llvm-objcopy/ELF/strip-preserve-atime.test|'\ +'ExecutionEngine/Interpreter/intrinsics.ll' + fi + + cd ../llvm/test + ${PYTHON} ../../build/bin/llvm-lit -vv --ignore-fail Transforms ExecutionEngine Analysis CodeGen/X86 +fi + diff --git a/conda-recipes/llvmdev_manylinux/meta.yaml b/conda-recipes/llvmdev_manylinux/meta.yaml new file mode 100644 index 000000000..661ececee --- /dev/null +++ b/conda-recipes/llvmdev_manylinux/meta.yaml @@ -0,0 +1,74 @@ +{% set shortversion = "15.0" %} +{% set version = "15.0.7" %} +{% set sha256_llvm = "8b5fcb24b4128cf04df1b0b9410ce8b1a729cb3c544e6da885d234280dedeac6" %} +{% set build_number = "0" %} + +package: + name: llvmdev + version: {{ version }} + +source: + - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ version.replace(".rc", "-rc") }}/llvm-project-{{ version.replace(".rc", "rc") }}.src.tar.xz + sha256: {{ sha256_llvm }} + patches: + - ../llvm15-clear-gotoffsetmap.patch + - ../llvm15-remove-use-of-clonefile.patch + - ../llvm15-svml.patch + - ../compiler-rt-cfi-startproc-war.patch + - ../compiler-rt-macos-build.patch + +build: + number: {{ build_number }} + string: "manylinux" + script_env: + - CFLAGS + - CXXFLAGS + - PY_VCRUNTIME_REDIST + ignore_run_exports: + # Is static-linked + - xar + +requirements: + build: + # Do not use the compiler + # - {{ compiler('cxx') }} + - cmake + - ninja + - python >=3 + # - libcxx # it is not defined{{ cxx_compiler_version }} # [osx] + - patch # [not win] + - m2-patch # [win] + - git # [(linux and x86_64)] + + host: + #- libcxx # it is not defined{{ cxx_compiler_version }} # [osx] + - libffi # [unix] + # libxml2 supports a windows-only feature, see https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/llvm/include/llvm/WindowsManifest/WindowsManifestMerger.h + - libxml2 # [win] + - zlib + +test: + files: + - numba-3016.ll + commands: + - $PREFIX/bin/llvm-config --libs # [not win] + - $PREFIX/bin/llc -version # [not win] + + - if not exist %LIBRARY_INC%\\llvm\\Pass.h exit 1 # [win] + - if not exist %LIBRARY_LIB%\\LLVMSupport.lib exit 1 # [win] + + - test -f $PREFIX/include/llvm/Pass.h # [unix] + - test -f $PREFIX/lib/libLLVMSupport.a # [unix] + + - test -f $PREFIX/lib/libLLVMCore.a # [not win] + + # LLD tests + - ld.lld --version # [unix] + - lld-link /? # [win] + +about: + home: http://llvm.org/ + dev_url: https://github.com/llvm-mirror/llvm + license: NCSA + license_file: llvm/LICENSE.TXT + summary: Development headers and libraries for LLVM diff --git a/conda-recipes/llvmdev_manylinux2014/build.sh b/conda-recipes/llvmdev_manylinux2014/build.sh deleted file mode 100644 index 3955c1e5b..000000000 --- a/conda-recipes/llvmdev_manylinux2014/build.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash - -# based on https://github.com/AnacondaRecipes/llvmdev-feedstock/blob/master/recipe/build.sh - -set -x - -# allow setting the targets to build as an environment variable -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 -else - DARWIN_TARGET=x86_64-apple-darwin13.4.0 -fi - -mv llvm-*.src llvm -mv lld-*.src lld -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") -# 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) -_cmake_config+=(-DLINK_POLLY_INTO_TOOLS:BOOL=ON) -# Don't really require libxml2. Turn it off explicitly to avoid accidentally linking to system libs -_cmake_config+=(-DLLVM_ENABLE_LIBXML2:BOOL=OFF) -# Urgh, llvm *really* wants to link to ncurses / terminfo and we *really* do not want it to. -_cmake_config+=(-DHAVE_TERMINFO_CURSES=OFF) -_cmake_config+=(-DLLVM_ENABLE_TERMINFO=OFF) -# Sometimes these are reported as unused. Whatever. -_cmake_config+=(-DHAVE_TERMINFO_NCURSES=OFF) -_cmake_config+=(-DHAVE_TERMINFO_NCURSESW=OFF) -_cmake_config+=(-DHAVE_TERMINFO_TERMINFO=OFF) -_cmake_config+=(-DHAVE_TERMINFO_TINFO=OFF) -_cmake_config+=(-DHAVE_TERMIOS_H=OFF) -_cmake_config+=(-DCLANG_ENABLE_LIBXML=OFF) -_cmake_config+=(-DLIBOMP_INSTALL_ALIASES=OFF) -_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+=(-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. -if [[ ${CONDA_FORGE} == yes ]]; then - _cmake_config+=(-DLLVM_INCLUDE_DOCS=OFF) - _cmake_config+=(-DLLVM_INCLUDE_EXAMPLES=OFF) -fi -# Only valid when using the Ninja Generator AFAICT -# _cmake_config+=(-DLLVM_PARALLEL_LINK_JOBS:STRING=1) -# What about cross-compiling targetting Darwin here? Are any of these needed? -if [[ $(uname) == Darwin ]]; then - _cmake_config+=(-DCMAKE_OSX_SYSROOT=${SYSROOT_DIR}) - _cmake_config+=(-DDARWIN_macosx_CACHED_SYSROOT=${SYSROOT_DIR}) - _cmake_config+=(-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}) - _cmake_config+=(-DCMAKE_LIBTOOL=$(which ${DARWIN_TARGET}-libtool)) - _cmake_config+=(-DLD64_EXECUTABLE=$(which ${DARWIN_TARGET}-ld)) - _cmake_config+=(-DCMAKE_INSTALL_NAME_TOOL=$(which ${DARWIN_TARGET}-install_name_tool)) - # 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) -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) -fi - -# For when the going gets tough: -# _cmake_config+=(-Wdev) -# _cmake_config+=(--debug-output) -# _cmake_config+=(--trace-expand) -# CPU_COUNT=1 - -mkdir build -cd build - -cmake -G'Unix Makefiles' \ - "${_cmake_config[@]}" \ - ../llvm - -ARCH=`uname -m` -if [ $ARCH == 'armv7l' ]; then # RPi need thread count throttling - make -j2 VERBOSE=1 -else - make -j${CPU_COUNT} VERBOSE=1 -fi - -make check-llvm-unit || exit $? - -# From: https://github.com/conda-forge/llvmdev-feedstock/pull/53 -make install || exit $? diff --git a/conda-recipes/llvmdev_manylinux2014/meta.yaml b/conda-recipes/llvmdev_manylinux2014/meta.yaml deleted file mode 100644 index bcc1ca39a..000000000 --- a/conda-recipes/llvmdev_manylinux2014/meta.yaml +++ /dev/null @@ -1,77 +0,0 @@ -{% set shortversion = "14.0" %} -{% set version = "14.0.6" %} -{% set sha256_llvm = "050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a" %} -{% set sha256_lld = "0c28ce0496934d37d20fec96591032dd66af8d10178a45762e0e75e85cf95ad3" %} -{% set sha256_libunwind = "3bbe9c23c73259fe39c045dc87d0b283236ba6e00750a226b2c2aeac4a51d86b" %} -{% set build_number = "1" %} - -package: - name: llvmdev - version: {{ version }} - -source: - - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ version }}/llvm-{{ version }}.src.tar.xz - fn: llvm-{{ version }}.src.tar.xz - sha256: {{ sha256_llvm }} - patches: - - ../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 }} - - - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ version }}/libunwind-{{ version }}.src.tar.xz - fn: libunwind-{{ version }}.src.tar.xz - sha256: {{ sha256_libunwind }} - folder: unwind - -build: - number: {{ build_number }} - string: "manylinux2014h{{ PKG_HASH }}" - script_env: - - CFLAGS - - CXXFLAGS - - PY_VCRUNTIME_REDIST - ignore_run_exports: - # Is static-linked - - xar - -requirements: - build: - - cmake - - make - # Needed to unpack the source tarball - - m2w64-xz # [win] - # Needed to build LLVM - - python >=3 - host: - # needed for llc at runtime - - zlib # [not win] - - xar # [osx and x86_64] - # llvm-lit testing needs *a* python - - python # [not (armv6l or armv7l or aarch64 or win)] - -test: - commands: - - $PREFIX/bin/llvm-config --libs # [not win] - - $PREFIX/bin/llc -version # [not win] - - - if not exist %LIBRARY_INC%\\llvm\\Pass.h exit 1 # [win] - - if not exist %LIBRARY_LIB%\\LLVMSupport.lib exit 1 # [win] - - - test -f $PREFIX/include/llvm/Pass.h # [unix] - - test -f $PREFIX/lib/libLLVMSupport.a # [unix] - - - test -f $PREFIX/lib/libLLVMCore.a # [not win] - - # LLD tests - - ld.lld --version # [unix] - - lld-link /? # [win] - -about: - home: http://llvm.org/ - dev_url: https://github.com/llvm-mirror/llvm - license: NCSA - license_file: llvm/LICENSE.TXT - summary: Development headers and libraries for LLVM From 49d0b4a62842882956e62965be4be5eefa0b2b1f Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam <1929845+sklam@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:02:15 -0600 Subject: [PATCH 2/4] Fixes llvmlite wheel builds --- buildscripts/manylinux/README.md | 6 +++--- buildscripts/manylinux/build_llvmdev.sh | 2 ++ buildscripts/manylinux/build_llvmlite.sh | 12 +++++++----- buildscripts/manylinux/docker_run.sh | 5 ++++- buildscripts/manylinux/prepare_miniconda.sh | 2 -- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/buildscripts/manylinux/README.md b/buildscripts/manylinux/README.md index a696a4023..b49cb447e 100644 --- a/buildscripts/manylinux/README.md +++ b/buildscripts/manylinux/README.md @@ -5,7 +5,7 @@ Run the script below to start docker off building `llvmdev` base from the current state of the source tree: -- 64-bit linux: `./buildscripts/manylinux/docker_run_x64.sh build_llvmdev.sh` +- x86_64 linux: `./buildscripts/manylinux/docker_run_x64.sh build_llvmdev.sh` - uses manylinux2014 image for glibc 2.17+ - aarch64 linux: `./buildscripts/manylinux/docker_run_aarch64.sh build_llvmdev.sh` - uses manylinux_2_28 image for glibc 2.28+ @@ -23,8 +23,8 @@ Finally, upload the conda package to the numba channel under the "manylinux_x_y" Run the script below to start docker off building `llvmlite` base from the current state of the source tree: -- 32-bit linux: `./buildscripts/manylinux/docker_run_x32.sh build_llvmlite.sh ` -- 64-bit linux: `./buildscripts/manylinux/docker_run_x64.sh build_llvmlite.sh ` +- x86_64 linux: `./buildscripts/manylinux/docker_run_x64.sh build_llvmlite.sh ` +- aarch64 linux: `./buildscripts/manylinux/docker_run_aarch64.sh build_llvmlite.sh ` The conda packages will be stored into `/docker_output/dist__` diff --git a/buildscripts/manylinux/build_llvmdev.sh b/buildscripts/manylinux/build_llvmdev.sh index f3bb39d96..8af68ab25 100755 --- a/buildscripts/manylinux/build_llvmdev.sh +++ b/buildscripts/manylinux/build_llvmdev.sh @@ -2,6 +2,8 @@ set -xe cd $(dirname $0) source ./prepare_miniconda.sh $1 +# make conda-build env t +conda create -n buildenv -y conda conda-build conda activate buildenv conda list echo "BUILD_CHANNELS: $BUILD_CHANNELS" diff --git a/buildscripts/manylinux/build_llvmlite.sh b/buildscripts/manylinux/build_llvmlite.sh index 86607fb79..23103822c 100755 --- a/buildscripts/manylinux/build_llvmlite.sh +++ b/buildscripts/manylinux/build_llvmlite.sh @@ -17,13 +17,13 @@ outputdir="/root/llvmlite/docker_output" ls -l /opt/python/$pyver/bin conda create -y -n $envname -source activate $envname +conda activate $envname # Install llvmdev -if [[ $ARCH == "aarch64" ]] ; then - conda install -y numba/label/manylinux_2_28::llvmdev +if [[ $MANYLINUX_IMAGE == "manylinux_2_28_aarch64" ]] ; then + conda install -y numba/label/manylinux_2_28::llvmdev --no-deps else - conda install -y numba/label/manylinux_2_17::llvmdev + conda install -y numba/label/manylinux_2_17::llvmdev --no-deps fi # Prepend builtin Python Path @@ -31,8 +31,10 @@ export PATH=/opt/python/$pyver/bin:$PATH echo "Using python: $(which python)" +# Python 3.12+ won't have setuptools pre-installed +pip install setuptools + # Clean up -git clean -xdf llvmlite build python setup.py clean # Build wheel diff --git a/buildscripts/manylinux/docker_run.sh b/buildscripts/manylinux/docker_run.sh index d6c67fcdf..99852c82e 100755 --- a/buildscripts/manylinux/docker_run.sh +++ b/buildscripts/manylinux/docker_run.sh @@ -5,4 +5,7 @@ srcdir=$( cd "$(dirname $0)/../.." && pwd ) echo "srcdir=$srcdir" echo "MINICONDA_FILE=$MINICONDA_FILE" -docker run --rm -it -e "ARCH=$ARCH" -v $srcdir:/root/llvmlite quay.io/pypa/${MANYLINUX_IMAGE} ${PRECMD} /root/llvmlite/buildscripts/manylinux/$1 ${MINICONDA_FILE} $2 +# Ensure the latest docker image +image="quay.io/pypa/${MANYLINUX_IMAGE}:latest" +docker pull $image +docker run --rm -it -e MANYLINUX_IMAGE=$MANYLINUX_IMAGE -v $srcdir:/root/llvmlite $image ${PRECMD} /root/llvmlite/buildscripts/manylinux/$1 ${MINICONDA_FILE} $2 diff --git a/buildscripts/manylinux/prepare_miniconda.sh b/buildscripts/manylinux/prepare_miniconda.sh index ecf082f21..4e3e5db35 100755 --- a/buildscripts/manylinux/prepare_miniconda.sh +++ b/buildscripts/manylinux/prepare_miniconda.sh @@ -7,5 +7,3 @@ echo "Miniconda installed" source $HOME/miniconda3/bin/activate base echo "Env activated" cd /root/llvmlite/buildscripts/manylinux -conda create -n buildenv -y conda conda-build - From fdfbb4f6a21d91e300585250f6190a65c26597b5 Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam <1929845+sklam@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:38:52 -0600 Subject: [PATCH 3/4] Simplify --- buildscripts/manylinux/build_llvmlite.sh | 2 +- buildscripts/manylinux/docker_run.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/buildscripts/manylinux/build_llvmlite.sh b/buildscripts/manylinux/build_llvmlite.sh index 23103822c..fe4363ec4 100755 --- a/buildscripts/manylinux/build_llvmlite.sh +++ b/buildscripts/manylinux/build_llvmlite.sh @@ -20,7 +20,7 @@ conda create -y -n $envname conda activate $envname # Install llvmdev -if [[ $MANYLINUX_IMAGE == "manylinux_2_28_aarch64" ]] ; then +if [[ $(uname -m) == "aarch64" ]] ; then conda install -y numba/label/manylinux_2_28::llvmdev --no-deps else conda install -y numba/label/manylinux_2_17::llvmdev --no-deps diff --git a/buildscripts/manylinux/docker_run.sh b/buildscripts/manylinux/docker_run.sh index 99852c82e..53da2cddf 100755 --- a/buildscripts/manylinux/docker_run.sh +++ b/buildscripts/manylinux/docker_run.sh @@ -8,4 +8,4 @@ echo "MINICONDA_FILE=$MINICONDA_FILE" # Ensure the latest docker image image="quay.io/pypa/${MANYLINUX_IMAGE}:latest" docker pull $image -docker run --rm -it -e MANYLINUX_IMAGE=$MANYLINUX_IMAGE -v $srcdir:/root/llvmlite $image ${PRECMD} /root/llvmlite/buildscripts/manylinux/$1 ${MINICONDA_FILE} $2 +docker run --rm -it -v $srcdir:/root/llvmlite $image ${PRECMD} /root/llvmlite/buildscripts/manylinux/$1 ${MINICONDA_FILE} $2 From 7ba4e73e2ce5fe1a36238ab5a7452f7944adaa0f Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam <1929845+sklam@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:06:05 -0600 Subject: [PATCH 4/4] Address review. Main changes are improving error handling, documentation --- buildscripts/manylinux/README.md | 7 ++++--- buildscripts/manylinux/build_llvmdev.sh | 9 ++++++--- buildscripts/manylinux/build_llvmlite.sh | 5 ++++- buildscripts/manylinux/docker_run.sh | 22 +++++++++++++++------ buildscripts/manylinux/prepare_miniconda.sh | 6 +++--- conda-recipes/llvmdev_manylinux/build.sh | 3 +++ conda-recipes/llvmdev_manylinux/meta.yaml | 13 ++++++------ 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/buildscripts/manylinux/README.md b/buildscripts/manylinux/README.md index b49cb447e..2b01e9954 100644 --- a/buildscripts/manylinux/README.md +++ b/buildscripts/manylinux/README.md @@ -6,15 +6,16 @@ Run the script below to start docker off building `llvmdev` base from the current state of the source tree: - x86_64 linux: `./buildscripts/manylinux/docker_run_x64.sh build_llvmdev.sh` - - uses manylinux2014 image for glibc 2.17+ + - uses manylinux2014 image for glibc 2.17+: `pypa.io/pypa/manylinux2014_x86_64` - aarch64 linux: `./buildscripts/manylinux/docker_run_aarch64.sh build_llvmdev.sh` - - uses manylinux_2_28 image for glibc 2.28+ + - uses manylinux_2_28 image for glibc 2.28+: `pypa.io/pypa/manylinux_2_28_aarch64` The conda packages will be stored into `/docker_output` Note: the `docker_output` location can be used as a local conda channel. -Finally, upload the conda package to the numba channel under the "manylinux_x_y" label: +Finally, upload the conda package to the numba channel under the "manylinux_x_y" +label (`x` and `y` are glibc major and minor version numbers, respectively): `anaconda upload -u numba -l manylinux_x_y ` diff --git a/buildscripts/manylinux/build_llvmdev.sh b/buildscripts/manylinux/build_llvmdev.sh index 8af68ab25..7fbfb7065 100755 --- a/buildscripts/manylinux/build_llvmdev.sh +++ b/buildscripts/manylinux/build_llvmdev.sh @@ -1,10 +1,13 @@ #!/bin/bash +# $1 is the miniconda download link +if [ -z "$1" ]; then + echo "Error: Miniconda download link argument is required" + exit 1 +fi set -xe cd $(dirname $0) source ./prepare_miniconda.sh $1 -# make conda-build env t conda create -n buildenv -y conda conda-build conda activate buildenv conda list -echo "BUILD_CHANNELS: $BUILD_CHANNELS" -conda-build $BUILD_CHANNELS /root/llvmlite/conda-recipes/llvmdev_manylinux --output-folder=/root/llvmlite/docker_output +conda-build /root/llvmlite/conda-recipes/llvmdev_manylinux --output-folder=/root/llvmlite/docker_output diff --git a/buildscripts/manylinux/build_llvmlite.sh b/buildscripts/manylinux/build_llvmlite.sh index fe4363ec4..582b35c99 100755 --- a/buildscripts/manylinux/build_llvmlite.sh +++ b/buildscripts/manylinux/build_llvmlite.sh @@ -22,8 +22,11 @@ conda activate $envname if [[ $(uname -m) == "aarch64" ]] ; then conda install -y numba/label/manylinux_2_28::llvmdev --no-deps -else +elif [[ $(uname -m) == "x86_64" ]] ; then conda install -y numba/label/manylinux_2_17::llvmdev --no-deps +else + echo "Error: Unsupported architecture: $(uname -m)" + exit 1 fi # Prepend builtin Python Path diff --git a/buildscripts/manylinux/docker_run.sh b/buildscripts/manylinux/docker_run.sh index 53da2cddf..e9f81f933 100755 --- a/buildscripts/manylinux/docker_run.sh +++ b/buildscripts/manylinux/docker_run.sh @@ -1,11 +1,21 @@ #!/bin/bash +# $1 is the filename of the script to run inside docker. +# The file must exist in buildscripts/manylinux/. +# $2 is the python version name in /opt/python of the manylinux docker image. +# Only used for build_llvmlite.sh. +# Check if required parameters are provided +if [ -z "$1" ] ; then + echo "Error: Missing required parameters" + echo "Usage: $0 []" + exit 1 +fi set -xe -# Use this to make the llvmdev packages that are manylinux2010 compatible -srcdir=$( cd "$(dirname $0)/../.." && pwd ) -echo "srcdir=$srcdir" +# Use this to make the llvmdev packages that are manylinux compatible +SRCDIR=$( cd "$(dirname $0)/../.." && pwd ) +echo "SRCDIR=$SRCDIR" echo "MINICONDA_FILE=$MINICONDA_FILE" # Ensure the latest docker image -image="quay.io/pypa/${MANYLINUX_IMAGE}:latest" -docker pull $image -docker run --rm -it -v $srcdir:/root/llvmlite $image ${PRECMD} /root/llvmlite/buildscripts/manylinux/$1 ${MINICONDA_FILE} $2 +IMAGE_URI="quay.io/pypa/${MANYLINUX_IMAGE}:latest" +docker pull $IMAGE_URI +docker run --rm -it -v $SRCDIR:/root/llvmlite $IMAGE_URI ${PRECMD} /root/llvmlite/buildscripts/manylinux/$1 ${MINICONDA_FILE} $2 diff --git a/buildscripts/manylinux/prepare_miniconda.sh b/buildscripts/manylinux/prepare_miniconda.sh index 4e3e5db35..15aeba3a2 100755 --- a/buildscripts/manylinux/prepare_miniconda.sh +++ b/buildscripts/manylinux/prepare_miniconda.sh @@ -2,8 +2,8 @@ set -e cd /root curl -L -o mini3.sh $1 -bash mini3.sh -b -f -p $HOME/miniconda3 +bash mini3.sh -b -f -p /root/miniconda3 echo "Miniconda installed" -source $HOME/miniconda3/bin/activate base +source /root/miniconda3/bin/activate base echo "Env activated" -cd /root/llvmlite/buildscripts/manylinux +cd - diff --git a/conda-recipes/llvmdev_manylinux/build.sh b/conda-recipes/llvmdev_manylinux/build.sh index fcccc8361..9484cf9ff 100644 --- a/conda-recipes/llvmdev_manylinux/build.sh +++ b/conda-recipes/llvmdev_manylinux/build.sh @@ -1,4 +1,7 @@ #!/bin/bash +# File is a copy of ../llvmdev/build.sh with changes to: +# - disable ZSTD + # based on https://github.com/AnacondaRecipes/llvmdev-feedstock/blob/master/recipe/build.sh diff --git a/conda-recipes/llvmdev_manylinux/meta.yaml b/conda-recipes/llvmdev_manylinux/meta.yaml index 661ececee..cc7868d4c 100644 --- a/conda-recipes/llvmdev_manylinux/meta.yaml +++ b/conda-recipes/llvmdev_manylinux/meta.yaml @@ -1,3 +1,4 @@ +# This file is a copy of ../llvmdev/meta.yaml with minor changes for manylinux {% set shortversion = "15.0" %} {% set version = "15.0.7" %} {% set sha256_llvm = "8b5fcb24b4128cf04df1b0b9410ce8b1a729cb3c544e6da885d234280dedeac6" %} @@ -37,14 +38,14 @@ requirements: - python >=3 # - libcxx # it is not defined{{ cxx_compiler_version }} # [osx] - patch # [not win] - - m2-patch # [win] + # - m2-patch # [win] - git # [(linux and x86_64)] host: #- libcxx # it is not defined{{ cxx_compiler_version }} # [osx] - libffi # [unix] - # libxml2 supports a windows-only feature, see https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/llvm/include/llvm/WindowsManifest/WindowsManifestMerger.h - - libxml2 # [win] + # # libxml2 supports a windows-only feature, see https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/llvm/include/llvm/WindowsManifest/WindowsManifestMerger.h + # - libxml2 # [win] - zlib test: @@ -54,8 +55,8 @@ test: - $PREFIX/bin/llvm-config --libs # [not win] - $PREFIX/bin/llc -version # [not win] - - if not exist %LIBRARY_INC%\\llvm\\Pass.h exit 1 # [win] - - if not exist %LIBRARY_LIB%\\LLVMSupport.lib exit 1 # [win] + # - if not exist %LIBRARY_INC%\\llvm\\Pass.h exit 1 # [win] + # - if not exist %LIBRARY_LIB%\\LLVMSupport.lib exit 1 # [win] - test -f $PREFIX/include/llvm/Pass.h # [unix] - test -f $PREFIX/lib/libLLVMSupport.a # [unix] @@ -64,7 +65,7 @@ test: # LLD tests - ld.lld --version # [unix] - - lld-link /? # [win] + # - lld-link /? # [win] about: home: http://llvm.org/