Skip to content

Commit

Permalink
resync arrow-cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Jul 24, 2023
1 parent 95effab commit 1bdaefa
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 75 deletions.
71 changes: 54 additions & 17 deletions dev/tasks/conda-recipes/arrow-cpp/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,70 @@
# doesn't come with a deactivate script, because the symlink
# is benign and doesn't need to be deleted.

_la_log() {
if [ "${CF_LIBARROW_ACTIVATE_LOGGING:-}" = "1" ]; then
# The following loop is necessary to handle multi-line strings
# like for the output of `ls -al`.
printf '%s\n' "$*" | while IFS= read -r line
do
echo "$CONDA_PREFIX/etc/conda/activate.d/libarrow_activate.sh DEBUG: $line"
done
fi
}

_la_log "Beginning libarrow activation."

# where the GDB wrappers get installed
GDB_PREFIX="$CONDA_PREFIX/share/gdb/auto-load"
_la_gdb_prefix="$CONDA_PREFIX/share/gdb/auto-load"

# this needs to be in sync with ARROW_GDB_INSTALL_DIR in build.sh
PLACEHOLDER="replace_this_section_with_absolute_slashed_path_to_CONDA_PREFIX"
_la_placeholder="replace_this_section_with_absolute_slashed_path_to_CONDA_PREFIX"
# the paths here are intentionally stacked, see #935, resp.
# https://github.com/apache/arrow/blob/master/docs/source/cpp/gdb.rst#manual-loading
WRAPPER_DIR="$GDB_PREFIX/$CONDA_PREFIX/lib"
_la_symlink_dir="$_la_gdb_prefix/$CONDA_PREFIX/lib"
_la_orig_install_dir="$_la_gdb_prefix/$_la_placeholder/lib"

mkdir -p "$WRAPPER_DIR" || true
# If the directory is not writable, nothing can be done
if [ ! -w "$WRAPPER_DIR" ]; then
return
fi
_la_log " _la_gdb_prefix: $_la_gdb_prefix"
_la_log " _la_placeholder: $_la_placeholder"
_la_log " _la_symlink_dir: $_la_symlink_dir"
_la_log " _la_orig_install_dir: $_la_orig_install_dir"
_la_log " content of that folder:"
_la_log "$(ls -al "$_la_orig_install_dir" | sed 's/^/ /')"

# there's only one lib in that folder, but the libname changes
# there's only one lib in the _la_orig_install_dir folder, but the libname changes
# based on the version so use a loop instead of hardcoding it.
for f in "$GDB_PREFIX/$PLACEHOLDER/lib/"*.py; do
if [ ! -e "$f" ]; then
for _la_target in "$_la_orig_install_dir/"*.py; do
if [ ! -e "$_la_target" ]; then
# If the file doesn't exist, skip this iteration of the loop.
# (This happens when no files are found, in which case the
# loop runs with f equal to the pattern itself.)
# loop runs with target equal to the pattern itself.)
_la_log 'Folder $_la_orig_install_dir seems to not contain .py files, skipping'
continue
fi
_la_symlink="$_la_symlink_dir/$(basename "$_la_target")"
_la_log " _la_target: $_la_target"
_la_log " _la_symlink: $_la_symlink"
if [ -L "$_la_symlink" ] && [ "$(readlink "$_la_symlink")" = "$_la_target" ]; then
_la_log 'symlink $_la_symlink already exists and points to $_la_target, skipping.'
continue
fi
_la_log 'Creating symlink $_la_symlink pointing to $_la_target'
mkdir -p "$_la_symlink_dir" || true
# this check also creates the symlink; if it fails, we enter the if-branch.
if ! ln -sf "$_la_target" "$_la_symlink"; then
echo -n "${BASH_SOURCE[0]} ERROR: Failed to create symlink from "
echo -n "'$_la_target' to '$_la_symlink'"
echo
continue
fi
target="$WRAPPER_DIR/$(basename "$f")"
# We have write permissions to WRAPPER_DIR but not necessarily target.
# Thus it's safest to delete the target in case it already exists.
rm -f "$target"
ln -s "$f" "$WRAPPER_DIR/$(basename "$f")"
done

_la_log "Libarrow activation complete."

unset _la_gdb_prefix
unset _la_log
unset _la_orig_install_dir
unset _la_placeholder
unset _la_symlink
unset _la_symlink_dir
unset _la_target
11 changes: 5 additions & 6 deletions dev/tasks/conda-recipes/arrow-cpp/build-arrow.bat
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
@echo on

mkdir "%SRC_DIR%"\cpp\build
pushd "%SRC_DIR%"\cpp\build
mkdir cpp\build
pushd cpp\build

:: Enable CUDA support
if "%cuda_compiler_version%"=="None" (
set "EXTRA_CMAKE_ARGS=-DARROW_CUDA=OFF"
) else (
REM this should move to nvcc-feedstock
set "CUDA_PATH=%CUDA_PATH:\=/%"
set "CUDA_HOME=%CUDA_HOME:\=/%"

set "EXTRA_CMAKE_ARGS=-DARROW_CUDA=ON"
)

Expand Down Expand Up @@ -70,3 +66,6 @@ cmake --build . --target install --config Release
if %ERRORLEVEL% neq 0 exit 1

popd

:: clean up between builds (and to save space)
rmdir /s /q cpp\build
23 changes: 7 additions & 16 deletions dev/tasks/conda-recipes/arrow-cpp/build-arrow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ fi
# Enable CUDA support
if [[ ! -z "${cuda_compiler_version+x}" && "${cuda_compiler_version}" != "None" ]]
then
if [[ -z "${CUDA_HOME+x}" ]]
then
echo "cuda_compiler_version=${cuda_compiler_version} CUDA_HOME=$CUDA_HOME"
CUDA_GDB_EXECUTABLE=$(which cuda-gdb || exit 0)
if [[ -n "$CUDA_GDB_EXECUTABLE" ]]
then
CUDA_HOME=$(dirname $(dirname $CUDA_GDB_EXECUTABLE))
else
echo "Cannot determine CUDA_HOME: cuda-gdb not in PATH"
return 1
fi
fi
EXTRA_CMAKE_ARGS=" ${EXTRA_CMAKE_ARGS} -DARROW_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_HOME} -DCMAKE_LIBRARY_PATH=${CONDA_BUILD_SYSROOT}/lib"
else
EXTRA_CMAKE_ARGS=" ${EXTRA_CMAKE_ARGS} -DARROW_CUDA=OFF"
Expand All @@ -56,7 +44,7 @@ if [[ "${build_platform}" != "${target_platform}" ]]; then
EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS} -DCLANG_EXECUTABLE=${BUILD_PREFIX}/bin/${CONDA_TOOLCHAIN_HOST}-clang"
EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS} -DLLVM_LINK_EXECUTABLE=${BUILD_PREFIX}/bin/llvm-link"
sed -ie "s;protoc-gen-grpc.*$;protoc-gen-grpc=${BUILD_PREFIX}/bin/grpc_cpp_plugin\";g" ../src/arrow/flight/CMakeLists.txt
sed -ie 's;"--with-jemalloc-prefix\=je_arrow_";"--with-jemalloc-prefix\=je_arrow_" "--with-lg-page\=14";g' ../cmake_modules/ThirdpartyToolchain.cmake
sed -ie 's;"--with-jemalloc-prefix\=je_arrow_";"--with-jemalloc-prefix\=je_arrow_" "--with-lg-page\=16";g' ../cmake_modules/ThirdpartyToolchain.cmake
fi

# disable -fno-plt, which causes problems with GCC on PPC
Expand All @@ -65,17 +53,17 @@ if [[ "$target_platform" == "linux-ppc64le" ]]; then
CXXFLAGS="$(echo $CXXFLAGS | sed 's/-fno-plt //g')"
fi

# Limit number of threads used to avoid hardware oversubscription
if [[ "${target_platform}" == "linux-aarch64" ]] || [[ "${target_platform}" == "linux-ppc64le" ]]; then
export CMAKE_BUILD_PARALLEL_LEVEL=3
# Limit number of threads used to avoid hardware oversubscription
export CMAKE_BUILD_PARALLEL_LEVEL=3
fi

# reusable variable for dependencies we cannot yet unvendor
export READ_RECIPE_META_YAML_WHY_NOT=OFF

# for available switches see
# https://github.com/apache/arrow/blame/apache-arrow-12.0.0/cpp/cmake_modules/DefineOptions.cmake
# placeholder in ARROW_GDB_INSTALL_DIR must match what's used for replacement in activate.sh
# placeholder in ARROW_GDB_INSTALL_DIR must match _la_placeholder in activate.sh
cmake -GNinja \
-DARROW_ACERO=ON \
-DARROW_BOOST_USE_SHARED=ON \
Expand Down Expand Up @@ -131,3 +119,6 @@ cmake -GNinja \
cmake --build . --target install --config Release

popd

# clean up between builds (and to save space)
rm -rf cpp/build
4 changes: 2 additions & 2 deletions dev/tasks/conda-recipes/arrow-cpp/build-pyarrow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ if [[ "${target_platform}" == osx-* ]]; then
CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY"
fi

# Limit number of threads used to avoid hardware oversubscription
if [[ "${target_platform}" == "linux-aarch64" ]] || [[ "${target_platform}" == "linux-ppc64le" ]]; then
export CMAKE_BUILD_PARALLEL_LEVEL=4
# Limit number of threads used to avoid hardware oversubscription
export CMAKE_BUILD_PARALLEL_LEVEL=4
fi

cd python
Expand Down
Loading

0 comments on commit 1bdaefa

Please sign in to comment.