Skip to content

Commit

Permalink
Merge branch 'numba:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
swap357 authored Nov 18, 2024
2 parents 2c8cfa9 + e9f12c6 commit 53921ac
Show file tree
Hide file tree
Showing 16 changed files with 263 additions and 228 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
# 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`
- x86_64 linux: `./buildscripts/manylinux/docker_run_x64.sh build_llvmdev.sh`
- 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+: `pypa.io/pypa/manylinux_2_28_aarch64`

The conda packages will be stored into `<llvmlite_source_root>/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 (`x` and `y` are glibc major and minor version numbers, respectively):

`anaconda upload -u numba -l manylinux_2_17 <filepath>`
`anaconda upload -u numba -l manylinux_x_y <filepath>`


## 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 <pyver>`
- 64-bit linux: `./buildscripts/manylinux_2_17/docker_run_x64.sh build_llvmlite.sh <pyver>`
- x86_64 linux: `./buildscripts/manylinux/docker_run_x64.sh build_llvmlite.sh <pyver>`
- aarch64 linux: `./buildscripts/manylinux/docker_run_aarch64.sh build_llvmlite.sh <pyver>`

The conda packages will be stored into `<llvmlite_source_root>/docker_output/dist_<arch>_<pyver>`

Expand Down
13 changes: 13 additions & 0 deletions buildscripts/manylinux/build_llvmdev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +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
conda create -n buildenv -y conda conda-build
conda activate buildenv
conda list
conda-build /root/llvmlite/conda-recipes/llvmdev_manylinux --output-folder=/root/llvmlite/docker_output
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,27 @@ 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/manylinux2014::llvmdev --no-deps
if [[ $(uname -m) == "aarch64" ]] ; then
conda install -y numba/label/manylinux_2_28::llvmdev --no-deps
elif [[ $(uname -m) == "x86_64" ]] ; then
conda install -y numba/label/manylinux_2_17::llvmdev --no-deps
else
conda install -y -c numba/label/manylinux2014 llvmdev
echo "Error: Unsupported architecture: $(uname -m)"
exit 1
fi

# Prepend builtin Python Path
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
Expand Down
21 changes: 21 additions & 0 deletions buildscripts/manylinux/docker_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +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 <script-filename> [<python-version>]"
exit 1
fi
set -xe
# 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_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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions buildscripts/manylinux/prepare_miniconda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e
cd /root
curl -L -o mini3.sh $1
bash mini3.sh -b -f -p /root/miniconda3
echo "Miniconda installed"
source /root/miniconda3/bin/activate base
echo "Env activated"
cd -
10 changes: 0 additions & 10 deletions buildscripts/manylinux_2_17/build_llvmdev.sh

This file was deleted.

6 changes: 0 additions & 6 deletions buildscripts/manylinux_2_17/configure_conda.sh

This file was deleted.

7 changes: 0 additions & 7 deletions buildscripts/manylinux_2_17/docker_run.sh

This file was deleted.

4 changes: 0 additions & 4 deletions buildscripts/manylinux_2_17/docker_run_aarch64.sh

This file was deleted.

9 changes: 0 additions & 9 deletions buildscripts/manylinux_2_17/prepare_miniconda.sh

This file was deleted.

119 changes: 119 additions & 0 deletions conda-recipes/llvmdev_manylinux/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/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

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

75 changes: 75 additions & 0 deletions conda-recipes/llvmdev_manylinux/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# 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" %}
{% 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
Loading

0 comments on commit 53921ac

Please sign in to comment.