Skip to content

Commit ab48926

Browse files
committed
CDRIVER-3863 add Evergreen task that builds with the new toolchain
1 parent 7b143c6 commit ab48926

File tree

6 files changed

+105
-4
lines changed

6 files changed

+105
-4
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/sh
2+
set -o xtrace # Write all commands first to stderr
3+
set -o errexit # Exit the script with error if any of the commands fail
4+
5+
echo "BUILDING WITH TOOLCHAIN"
6+
7+
# Configure environment with toolchain components
8+
[ -d /opt/mongo-c-toolchain ] && sudo rm -r /opt/mongo-c-toolchain
9+
sudo mkdir /opt/mongo-c-toolchain
10+
TOOLCHAIN_TAR_GZ=$(readlink -f ../mongo-c-toolchain.tar.gz)
11+
sudo tar -xvf "${TOOLCHAIN_TAR_GZ}" -C /opt/mongo-c-toolchain
12+
echo "--- TOOLCHAIN MANIFEST ---"
13+
cat /opt/mongo-c-toolchain/MANIFEST.txt
14+
OLD_PATH=${PATH}
15+
ADDL_PATH=$(readlink -f /opt/mongo-c-toolchain/bin):${PATH}
16+
export CMAKE=$(readlink -f /opt/mongo-c-toolchain/bin/cmake)
17+
[ -x "${CMAKE}" ] || (echo "CMake (${CMAKE}) does not exist or is not executable"; exit 1)
18+
TOOLCHAIN_BASE_DIR=$(readlink -f /opt/mongo-c-toolchain)
19+
TOOLCHAIN_LIB_DIR=${TOOLCHAIN_BASE_DIR}/lib
20+
21+
for ssl_ver in libressl-2.5 libressl-3.0 openssl-0.9.8 openssl-1.0.0 openssl-1.0.1 openssl-1.0.1-fips openssl-1.0.2 openssl-1.1.0; do
22+
23+
cd ..
24+
cp -a mongoc mongoc-${ssl_ver}
25+
cd mongoc-${ssl_ver}
26+
export PATH=$(readlink -f /opt/mongo-c-toolchain/${ssl_ver}/bin):${ADDL_PATH}:${OLD_PATH}
27+
ssl_base_dir=$(readlink -f /opt/mongo-c-toolchain/${ssl_ver})
28+
ssl_lib_dir=${ssl_base_dir}/lib
29+
export EXTRA_CONFIGURE_FLAGS="-DCMAKE_VERBOSE_MAKEFILE=ON"
30+
export EXTRA_CMAKE_PREFIX_PATH="${ssl_base_dir};${TOOLCHAIN_BASE_DIR}"
31+
32+
# Output some information about our build environment
33+
"${CMAKE}" --version
34+
35+
# Run the build and tests
36+
export LD_LIBRARY_PATH="${ssl_lib_dir}:${TOOLCHAIN_LIB_DIR}"
37+
if [ "${ssl_ver#*libressl}" != "${ssl_ver}" ]; then
38+
SSL_TYPE=LIBRESSL
39+
else
40+
SSL_TYPE=OPENSSL
41+
fi
42+
output_file=$(mktemp)
43+
SSL=${SSL_TYPE} sh ./.evergreen/compile-unix.sh 2>&1 | tee -a "${output_file}"
44+
45+
# Verify that the toolchain components were used
46+
if grep -Ec "[-]I/opt/mongo-c-toolchain/include" "${output_file}" >/dev/null \
47+
&& grep -Ec "[-]I/opt/mongo-c-toolchain/${ssl_ver}/include" "${output_file}" >/dev/null \
48+
&& grep -Ec "[-]L/opt/mongo-c-toolchain/lib" "${output_file}" >/dev/null \
49+
&& grep -Ec "/opt/mongo-c-toolchain/${ssl_ver}/lib" "${output_file}" >/dev/null; then
50+
echo "Toolchain components for ${ssl_ver} were detected in build output...continuing."
51+
else
52+
echo "TOOLCHAIN COMPONENTS FOR ${ssl_ver} NOT DETECTED IN BUILD OUTPUT...ABORTING!"
53+
exit 1
54+
fi
55+
rm -f "${output_file}"
56+
57+
cd ../mongoc
58+
done

.evergreen/compile-unix.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set -o errexit # Exit the script with error if any of the commands fail
1818
# Options for CMake:
1919
# LIBBSON Build against bundled or external libbson
2020
# EXTRA_CONFIGURE_FLAGS Extra configure flags to use
21+
# EXTRA_CMAKE_PREFIX_PATH Extra directories to search for libraries/packages
2122
# ZLIB Build against bundled or external zlib, or none
2223
# SNAPPY Build against Snappy, or none
2324
# SSL Build against OpenSSL or native or none
@@ -71,6 +72,11 @@ fi
7172
# as an environment variable (e.g. to force 32bit)
7273
[ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
7374

75+
CMAKE_PREFIX_PATH="$INSTALL_DIR"
76+
if [ ! -z "$EXTRA_CMAKE_PREFIX_PATH" ]; then
77+
CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$EXTRA_CMAKE_PREFIX_PATH"
78+
fi
79+
7480
# Default CMake flags for debug builds and release builds.
7581
# CMAKE_SKIP_RPATH avoids hardcoding absolute paths to dependency libraries.
7682
DEBUG_AND_RELEASE_FLAGS="\
@@ -82,7 +88,7 @@ DEBUG_AND_RELEASE_FLAGS="\
8288
-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF \
8389
-DENABLE_TRACING=$TRACING \
8490
-DENABLE_RDTSCP=$RDTSCP \
85-
-DCMAKE_PREFIX_PATH=$INSTALL_DIR \
91+
-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
8692
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
8793
-DENABLE_SHM_COUNTERS=$ENABLE_SHM_COUNTERS \
8894
"
@@ -212,7 +218,7 @@ if [ "$COMPILE_LIBMONGOCRYPT" = "ON" ]; then
212218
git clone https://github.com/mongodb/libmongocrypt
213219
mkdir libmongocrypt/cmake-build
214220
cd libmongocrypt/cmake-build
215-
$CMAKE -DENABLE_SHARED_BSON=ON -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DCMAKE_PREFIX_PATH="$INSTALL_DIR" ../
221+
$CMAKE -DENABLE_SHARED_BSON=ON -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" ../
216222
make install
217223
cd ../../
218224
else

.evergreen/config.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,6 +2016,24 @@ tasks:
20162016
export SSL="OPENSSL"
20172017
CC='${CC}' MARCH='${MARCH}' sh .evergreen/compile.sh
20182018
- func: upload build
2019+
- name: build-and-test-with-toolchain
2020+
commands:
2021+
- command: s3.get
2022+
params:
2023+
aws_key: '${toolchain_aws_key}'
2024+
aws_secret: '${toolchain_aws_secret}'
2025+
remote_file: 'mongo-c-toolchain/${distro_id}/mongo-c-toolchain.tar.gz'
2026+
bucket: mongo-c-toolchain
2027+
local_file: mongo-c-toolchain.tar.gz
2028+
- command: shell.exec
2029+
type: test
2030+
params:
2031+
working_dir: mongoc
2032+
shell: bash
2033+
script: |-
2034+
set -o errexit
2035+
set -o xtrace
2036+
sh ./.evergreen/build-and-test-with-toolchain.sh
20192037
- name: test-valgrind-latest-server-auth-nosasl-openssl
20202038
tags:
20212039
- latest
@@ -22482,6 +22500,9 @@ buildvariants:
2248222500
distros:
2248322501
- windows-64-vs2017-test
2248422502
- debug-compile-with-warnings
22503+
- name: build-and-test-with-toolchain
22504+
distros:
22505+
- debian10-small
2248522506
- name: clang34ubuntu
2248622507
display_name: clang 3.4 (Ubuntu 14.04)
2248722508
expansions:

build/evergreen_config_lib/tasks.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,20 @@ def __init__(self, task_name, suffix_commands, orchestration=True, **kwargs):
436436
CFLAGS='-fsanitize=thread -fno-omit-frame-pointer',
437437
CHECK_LOG='ON',
438438
SSL='OPENSSL',
439-
EXTRA_CONFIGURE_FLAGS='-DENABLE_EXTRA_ALIGNMENT=OFF -DENABLE_SHM_COUNTERS=OFF')
439+
EXTRA_CONFIGURE_FLAGS='-DENABLE_EXTRA_ALIGNMENT=OFF -DENABLE_SHM_COUNTERS=OFF'),
440+
NamedTask('build-and-test-with-toolchain',
441+
commands=[
442+
OD([('command', 's3.get'),
443+
('params', OD([
444+
('aws_key', '${toolchain_aws_key}'),
445+
('aws_secret', '${toolchain_aws_secret}'),
446+
('remote_file',
447+
'mongo-c-toolchain/${distro_id}/mongo-c-toolchain.tar.gz'),
448+
('bucket', 'mongo-c-toolchain'),
449+
('local_file', 'mongo-c-toolchain.tar.gz'),
450+
]))]),
451+
shell_mongoc('sh ./.evergreen/build-and-test-with-toolchain.sh')
452+
])
440453
]
441454

442455
class IntegrationTask(MatrixTask):

build/evergreen_config_lib/variants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def days(n):
7979
('distros', ['windows-64-vs2017-test'])]),
8080
OD([('name', 'install-uninstall-check-msvc'),
8181
('distros', ['windows-64-vs2017-test'])]),
82-
'debug-compile-with-warnings']),
82+
'debug-compile-with-warnings',
83+
OD([('name', 'build-and-test-with-toolchain'),
84+
('distros', ['debian10-small'])]),]),
8385
Variant('clang34ubuntu',
8486
'clang 3.4 (Ubuntu 14.04)',
8587
'ubuntu1404-build',

src/libmongoc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ if (NOT ENABLE_ZSTD STREQUAL OFF)
122122
set (MONGOC_ENABLE_COMPRESSION_ZSTD 1)
123123

124124
include_directories (${ZSTD_INCLUDE_DIRS})
125+
link_directories (${ZSTD_LIBRARY_DIRS})
125126
if (${CMAKE_VERSION} VERSION_LESS "3.12.0")
126127
set (MONGOC_ZSTD_LIBRARIES ${ZSTD_LIBRARIES})
127128
else ()

0 commit comments

Comments
 (0)