Skip to content

Commit 66b5b0d

Browse files
majetideepakfacebook-github-bot
authored andcommitted
Improve dependency install and build (facebookincubator#10920)
Summary: https://github.com/facebookincubator/velox/pull/10422/files added additional packages to be installed via brew. When the package versions are updated via brew, it can cause a build failure. See facebookincubator#10886 We must install or bundle fixed/supported versions to avoid this. Allow installed package headers to be picked up before brew/system package headers Add support for DEPENDENCY_DIR and INSTALL_PREFIX. Pull Request resolved: facebookincubator#10920 Reviewed By: kgpai Differential Revision: D62989022 Pulled By: Yuhta fbshipit-source-id: a10faa3212c32d6f9c0e301921a750e3b7142220
1 parent a8a21a4 commit 66b5b0d

10 files changed

+191
-124
lines changed

.github/workflows/macos.yml

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
CCACHE_DIR: '${{ github.workspace }}/.ccache'
5555
# The arm runners have only 7GB RAM
5656
BUILD_TYPE: "${{ matrix.os == 'macos-14' && 'Release' || 'Debug' }}"
57+
INSTALL_PREFIX: "/tmp/deps-install"
5758
steps:
5859
- name: Checkout
5960
uses: actions/checkout@v4
@@ -66,6 +67,7 @@ jobs:
6667
source scripts/setup-macos.sh
6768
install_build_prerequisites
6869
install_velox_deps_from_brew
70+
install_double_conversion
6971
7072
echo "NJOBS=`sysctl -n hw.ncpu`" >> $GITHUB_ENV
7173
brew unlink protobuf || echo "protobuf not installed"

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ projects/*
4949
!projects/*.*
5050
!projects/Makefile
5151
.venv
52+
deps-install
53+
deps-download
5254

5355
#==============================================================================#
5456
# Autotools artifacts

CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ if(DEFINED ENV{CONDA_PREFIX})
4545
endif()
4646
endif()
4747

48+
if(DEFINED ENV{INSTALL_PREFIX})
49+
message(STATUS "Dependency install directory set to: $ENV{INSTALL_PREFIX}")
50+
list(APPEND CMAKE_PREFIX_PATH "$ENV{INSTALL_PREFIX}")
51+
# Allow installed package headers to be picked up before brew/system package
52+
# headers
53+
include_directories(BEFORE "$ENV{INSTALL_PREFIX}/include")
54+
endif()
55+
4856
list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake"
4957
"${PROJECT_SOURCE_DIR}/CMake/third-party")
5058

README.md

+16-8
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,27 @@ dependencies for a given platform.
8585
### Setting up dependencies
8686

8787
The following setup scripts use the `DEPENDENCY_DIR` environment variable to set the
88-
location of the build packages. If you do not set this variable, it will default to
89-
the current working directory.
88+
location to download and build packages. This defaults to `deps-download` in the current
89+
working directory.
9090

91-
```shell
92-
$ export DEPENDENCY_DIR=/path/to/your/dependencies
93-
```
91+
Use `INSTALL_PREFIX` to set the install directory of the packages. This defaults to
92+
`deps-install` in the current working directory on macOS and to the default install
93+
location (eg. `/usr/local`) on linux.
94+
Using the default install location `/usr/local` on macOS is discouraged since this
95+
location is used by certain Homebrew versions.
96+
97+
Manually add the `INSTALL_PREFIX` value in the IDE or bash environment,
98+
say `export INSTALL_PREFIX=/Users/$USERNAME/velox/deps-install` to `~/.zshrc` so that
99+
subsequent Velox builds can use the installed packages.
100+
101+
*You can reuse `DEPENDENCY_INSTALL` and `INSTALL_PREFIX` for Velox clients such as Prestissimo
102+
by specifying a common shared directory.`*
94103

95104
### Setting up on macOS
96105

97-
On a MacOS machine (either Intel or Apple silicon) you can setup and then build like so:
106+
On a macOS machine (either Intel or Apple silicon) you can setup and then build like so:
98107

99108
```shell
100-
$ export INSTALL_PREFIX=/Users/$USERNAME/velox/velox_dependency_install
101109
$ ./scripts/setup-macos.sh
102110
$ make
103111
```
@@ -136,7 +144,7 @@ $ ./scripts/setup-adapters.sh
136144
$ make
137145
```
138146

139-
Note that `setup-adapters.sh` supports MacOS and Ubuntu 20.04 or later.
147+
Note that `setup-adapters.sh` supports macOS and Ubuntu 20.04 or later.
140148

141149
### Using Clang on Linux
142150

scripts/adapters.dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
ARG image=ghcr.io/facebookincubator/velox-dev:centos9
1616
FROM $image
1717

18+
COPY scripts/setup-helper-functions.sh /
1819
COPY scripts/setup-adapters.sh /
1920
RUN mkdir build && ( cd build && source /opt/rh/gcc-toolset-12/enable && \
2021
bash /setup-adapters.sh ) && rm -rf build && dnf remove -y conda && dnf clean all

scripts/setup-adapters.sh

+38-22
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ set -eufx -o pipefail
2121

2222
SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}")
2323
source $SCRIPTDIR/setup-helper-functions.sh
24-
DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)}
24+
DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)/deps-download}
2525
CMAKE_BUILD_TYPE="${BUILD_TYPE:-Release}"
2626
MACHINE=$(uname -m)
2727

28+
if [[ "$OSTYPE" == darwin* ]]; then
29+
export INSTALL_PREFIX=${INSTALL_PREFIX:-"$(pwd)/deps-install"}
30+
fi
31+
2832
function install_aws_deps {
2933
local AWS_REPO_NAME="aws/aws-sdk-cpp"
3034
local AWS_SDK_VERSION="1.11.321"
@@ -40,14 +44,16 @@ function install_aws_deps {
4044
MINIO_ARCH="amd64"
4145
fi
4246
local MINIO_BINARY="minio-2022-05-26"
43-
local MINIO_OS="linux"
44-
if [[ "$OSTYPE" == darwin* ]]; then
45-
# minio will have to approved under the Privacy & Security on MacOS on first use.
46-
MINIO_OS="darwin"
47+
if [[! -f /usr/local/bin/${MINIO_BINARY} ]]; then
48+
local MINIO_OS="linux"
49+
if [[ "$OSTYPE" == darwin* ]]; then
50+
# minio will have to approved under the Privacy & Security on MacOS on first use.
51+
MINIO_OS="darwin"
52+
fi
53+
wget https://dl.min.io/server/minio/release/${MINIO_OS}-${MINIO_ARCH}/archive/minio.RELEASE.2022-05-26T05-48-41Z -O ${MINIO_BINARY}
54+
chmod +x ./${MINIO_BINARY}
55+
mv ./${MINIO_BINARY} /usr/local/bin/
4756
fi
48-
wget https://dl.min.io/server/minio/release/${MINIO_OS}-${MINIO_ARCH}/archive/minio.RELEASE.2022-05-26T05-48-41Z -O ${MINIO_BINARY}
49-
chmod +x ./${MINIO_BINARY}
50-
mv ./${MINIO_BINARY} /usr/local/bin/
5157
}
5258

5359
function install_gcs-sdk-cpp {
@@ -117,41 +123,51 @@ function install_azure-storage-sdk-cpp {
117123
sed -i "s/\"version-string\"/\"builtin-baseline\": \"$vcpkg_commit_id\",\"version-string\"/" $azure_core_dir/vcpkg.json
118124
sed -i "s/\"version-string\"/\"overrides\": [{ \"name\": \"openssl\", \"version-string\": \"$openssl_version\" }],\"version-string\"/" $azure_core_dir/vcpkg.json
119125
fi
120-
cmake_install $azure_core_dir -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF
121-
126+
(
127+
cd $azure_core_dir
128+
cmake_install -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF
129+
)
122130
# install azure-storage-common
123-
cmake_install sdk/storage/azure-storage-common -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF
131+
(
132+
cd sdk/storage/azure-storage-common
133+
cmake_install -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF
134+
)
124135

125136
# install azure-storage-blobs
126-
cmake_install sdk/storage/azure-storage-blobs -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF
127-
137+
(
138+
cd sdk/storage/azure-storage-blobs
139+
cmake_install -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF
140+
)
128141
# install azure-storage-files-datalake
129-
cmake_install sdk/storage/azure-storage-files-datalake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF
142+
(
143+
cd sdk/storage/azure-storage-files-datalake
144+
cmake_install -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF
145+
)
130146
}
131147

132148
function install_hdfs_deps {
133149
github_checkout apache/hawq master
134-
libhdfs3_dir=$DEPENDENCY_DIR/hawq/depends/libhdfs3
150+
libhdfs3_dir=hawq/depends/libhdfs3
135151
if [[ "$OSTYPE" == darwin* ]]; then
136-
sed -i '' -e "/FIND_PACKAGE(GoogleTest REQUIRED)/d" $libhdfs3_dir/CMakeLists.txt
137-
sed -i '' -e "s/dumpversion/dumpfullversion/" $libhdfs3_dir/CMakeLists.txt
152+
sed -i '' -e "/FIND_PACKAGE(GoogleTest REQUIRED)/d" $DEPENDENCY_DIR/$libhdfs3_dir/CMakeLists.txt
153+
sed -i '' -e "s/dumpversion/dumpfullversion/" $DEPENDENCY_DIR/$libhdfs3_dir/CMakeLists.txt
138154
fi
139155

140156
if [[ "$OSTYPE" == linux-gnu* ]]; then
141-
sed -i "/FIND_PACKAGE(GoogleTest REQUIRED)/d" $libhdfs3_dir/CMakeLists.txt
142-
sed -i "s/dumpversion/dumpfullversion/" $libhdfs3_dir/CMake/Platform.cmake
157+
sed -i "/FIND_PACKAGE(GoogleTest REQUIRED)/d" $DEPENDENCY_DIR/$libhdfs3_dir/CMakeLists.txt
158+
sed -i "s/dumpversion/dumpfullversion/" $DEPENDENCY_DIR/$libhdfs3_dir/CMake/Platform.cmake
143159
# Dependencies for Hadoop testing
144160
wget_and_untar https://archive.apache.org/dist/hadoop/common/hadoop-3.3.0/hadoop-3.3.0.tar.gz hadoop
145-
cp -a hadoop /usr/local/
161+
cp -a ${DEPENDENCY_DIR}/hadoop /usr/local/
146162
wget -P /usr/local/hadoop/share/hadoop/common/lib/ https://repo1.maven.org/maven2/junit/junit/4.11/junit-4.11.jar
147163

148164
yum install -y java-1.8.0-openjdk-devel
149165

150166
fi
151-
cmake_install $libhdfs3_dir
167+
cmake_install_dir $libhdfs3_dir
152168
}
153169

154-
cd "${DEPENDENCY_DIR}" || exit
170+
(mkdir -p "${DEPENDENCY_DIR}") || exit
155171
# aws-sdk-cpp missing dependencies
156172

157173
if [[ "$OSTYPE" == "linux-gnu"* ]]; then

scripts/setup-centos9.sh

+38-37
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export CFLAGS=${CXXFLAGS//"-std=c++17"/} # Used by LZO.
3636
CMAKE_BUILD_TYPE="${BUILD_TYPE:-Release}"
3737
BUILD_DUCKDB="${BUILD_DUCKDB:-true}"
3838
USE_CLANG="${USE_CLANG:-false}"
39+
export INSTALL_PREFIX=${INSTALL_PREFIX:-"/usr/local"}
40+
DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)/deps-download}
3941

4042
FB_OS_VERSION="v2024.05.20.00"
4143
FMT_VERSION="10.1.1"
@@ -85,19 +87,19 @@ function install_gflags {
8587
# Remove an older version if present.
8688
dnf remove -y gflags
8789
wget_and_untar https://github.com/gflags/gflags/archive/v2.2.2.tar.gz gflags
88-
cmake_install gflags -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_LIB=ON -DLIB_SUFFIX=64
90+
cmake_install_dir gflags -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_LIB=ON -DLIB_SUFFIX=64
8991
}
9092

9193
function install_glog {
9294
wget_and_untar https://github.com/google/glog/archive/v0.6.0.tar.gz glog
93-
cmake_install glog -DBUILD_SHARED_LIBS=ON
95+
cmake_install_dir glog -DBUILD_SHARED_LIBS=ON
9496
}
9597

9698
function install_lzo {
9799
wget_and_untar http://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz lzo
98100
(
99-
cd lzo
100-
./configure --prefix=/usr --enable-shared --disable-static --docdir=/usr/share/doc/lzo-2.10
101+
cd ${DEPENDENCY_DIR}/lzo
102+
./configure --prefix=${INSTALL_PREFIX} --enable-shared --disable-static --docdir=/usr/share/doc/lzo-2.10
101103
make "-j$(nproc)"
102104
make install
103105
)
@@ -106,36 +108,36 @@ function install_lzo {
106108
function install_boost {
107109
wget_and_untar https://github.com/boostorg/boost/releases/download/${BOOST_VERSION}/${BOOST_VERSION}.tar.gz boost
108110
(
109-
cd boost
111+
cd ${DEPENDENCY_DIR}/boost
110112
if [[ ${USE_CLANG} != "false" ]]; then
111-
./bootstrap.sh --prefix=/usr/local --with-toolset="clang-15"
113+
./bootstrap.sh --prefix=${INSTALL_PREFIX} --with-toolset="clang-15"
112114
# Switch the compiler from the clang-15 toolset which doesn't exist (clang-15.jam) to
113115
# clang of version 15 when toolset clang-15 is used.
114116
# This reconciles the project-config.jam generation with what the b2 build system allows for customization.
115117
sed -i 's/using clang-15/using clang : 15/g' project-config.jam
116118
${SUDO} ./b2 "-j$(nproc)" -d0 install threading=multi toolset=clang-15 --without-python
117119
else
118-
./bootstrap.sh --prefix=/usr/local
120+
./bootstrap.sh --prefix=${INSTALL_PREFIX}
119121
${SUDO} ./b2 "-j$(nproc)" -d0 install threading=multi --without-python
120122
fi
121123
)
122124
}
123125

124126
function install_snappy {
125127
wget_and_untar https://github.com/google/snappy/archive/1.1.8.tar.gz snappy
126-
cmake_install snappy -DSNAPPY_BUILD_TESTS=OFF
128+
cmake_install_dir snappy -DSNAPPY_BUILD_TESTS=OFF
127129
}
128130

129131
function install_fmt {
130132
wget_and_untar https://github.com/fmtlib/fmt/archive/${FMT_VERSION}.tar.gz fmt
131-
cmake_install fmt -DFMT_TEST=OFF
133+
cmake_install_dir fmt -DFMT_TEST=OFF
132134
}
133135

134136
function install_protobuf {
135137
wget_and_untar https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protobuf-all-21.8.tar.gz protobuf
136138
(
137-
cd protobuf
138-
./configure --prefix=/usr
139+
cd ${DEPENDENCY_DIR}/protobuf
140+
./configure --prefix=${INSTALL_PREFIX}
139141
make "-j${NPROC}"
140142
make install
141143
ldconfig
@@ -144,61 +146,60 @@ function install_protobuf {
144146

145147
function install_fizz {
146148
wget_and_untar https://github.com/facebookincubator/fizz/archive/refs/tags/${FB_OS_VERSION}.tar.gz fizz
147-
cmake_install fizz/fizz -DBUILD_TESTS=OFF
149+
cmake_install_dir fizz/fizz -DBUILD_TESTS=OFF
148150
}
149151

150152
function install_folly {
151153
wget_and_untar https://github.com/facebook/folly/archive/refs/tags/${FB_OS_VERSION}.tar.gz folly
152-
cmake_install folly -DBUILD_TESTS=OFF -DFOLLY_HAVE_INT128_T=ON
154+
cmake_install_dir folly -DBUILD_TESTS=OFF -DFOLLY_HAVE_INT128_T=ON
153155
}
154156

155157
function install_wangle {
156158
wget_and_untar https://github.com/facebook/wangle/archive/refs/tags/${FB_OS_VERSION}.tar.gz wangle
157-
cmake_install wangle/wangle -DBUILD_TESTS=OFF
159+
cmake_install_dir wangle/wangle -DBUILD_TESTS=OFF
158160
}
159161

160162
function install_fbthrift {
161163
wget_and_untar https://github.com/facebook/fbthrift/archive/refs/tags/${FB_OS_VERSION}.tar.gz fbthrift
162-
cmake_install fbthrift -Denable_tests=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF
164+
cmake_install_dir fbthrift -Denable_tests=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF
163165
}
164166

165167
function install_mvfst {
166168
wget_and_untar https://github.com/facebook/mvfst/archive/refs/tags/${FB_OS_VERSION}.tar.gz mvfst
167-
cmake_install mvfst -DBUILD_TESTS=OFF
169+
cmake_install_dir mvfst -DBUILD_TESTS=OFF
168170
}
169171

170172
function install_duckdb {
171173
if $BUILD_DUCKDB ; then
172174
echo 'Building DuckDB'
173175
wget_and_untar https://github.com/duckdb/duckdb/archive/refs/tags/v0.8.1.tar.gz duckdb
174-
cmake_install duckdb -DBUILD_UNITTESTS=OFF -DENABLE_SANITIZER=OFF -DENABLE_UBSAN=OFF -DBUILD_SHELL=OFF -DEXPORT_DLL_SYMBOLS=OFF -DCMAKE_BUILD_TYPE=Release
176+
cmake_install_dir duckdb -DBUILD_UNITTESTS=OFF -DENABLE_SANITIZER=OFF -DENABLE_UBSAN=OFF -DBUILD_SHELL=OFF -DEXPORT_DLL_SYMBOLS=OFF -DCMAKE_BUILD_TYPE=Release
175177
fi
176178
}
177179

178180
function install_arrow {
179181
wget_and_untar https://archive.apache.org/dist/arrow/arrow-${ARROW_VERSION}/apache-arrow-${ARROW_VERSION}.tar.gz arrow
180-
(
181-
cd arrow/cpp
182-
cmake_install \
183-
-DARROW_PARQUET=OFF \
184-
-DARROW_WITH_THRIFT=ON \
185-
-DARROW_WITH_LZ4=ON \
186-
-DARROW_WITH_SNAPPY=ON \
187-
-DARROW_WITH_ZLIB=ON \
188-
-DARROW_WITH_ZSTD=ON \
189-
-DARROW_JEMALLOC=OFF \
190-
-DARROW_SIMD_LEVEL=NONE \
191-
-DARROW_RUNTIME_SIMD_LEVEL=NONE \
192-
-DARROW_WITH_UTF8PROC=OFF \
193-
-DARROW_TESTING=ON \
194-
-DCMAKE_INSTALL_PREFIX=/usr/local \
195-
-DCMAKE_BUILD_TYPE=Release \
196-
-DARROW_BUILD_STATIC=ON \
197-
-DThrift_SOURCE=BUNDLED
182+
cmake_install_dir arrow/cpp \
183+
-DARROW_PARQUET=OFF \
184+
-DARROW_WITH_THRIFT=ON \
185+
-DARROW_WITH_LZ4=ON \
186+
-DARROW_WITH_SNAPPY=ON \
187+
-DARROW_WITH_ZLIB=ON \
188+
-DARROW_WITH_ZSTD=ON \
189+
-DARROW_JEMALLOC=OFF \
190+
-DARROW_SIMD_LEVEL=NONE \
191+
-DARROW_RUNTIME_SIMD_LEVEL=NONE \
192+
-DARROW_WITH_UTF8PROC=OFF \
193+
-DARROW_TESTING=ON \
194+
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
195+
-DCMAKE_BUILD_TYPE=Release \
196+
-DARROW_BUILD_STATIC=ON \
197+
-DThrift_SOURCE=BUNDLED
198198

199+
(
199200
# Install thrift.
200-
cd _build/thrift_ep-prefix/src/thrift_ep-build
201-
cmake --install ./ --prefix /usr/local/
201+
cd ${DEPENDENCY_DIR}/arrow/cpp/_build/thrift_ep-prefix/src/thrift_ep-build
202+
cmake --install ./ --prefix ${INSTALL_PREFIX}
202203
)
203204
}
204205

0 commit comments

Comments
 (0)