Skip to content

Commit

Permalink
cpp_stl/{clang3.4,gcc4.8}: build latest Boost 1.84 from source
Browse files Browse the repository at this point in the history
See
kaitai-io/kaitai_struct_tests#105 (comment)
- Boost 1.54 is too old for our purposes. Fortunately, it's quite easy
to build Boost from source (according to the documentation at
https://www.boost.org/doc/libs/1_84_0/more/getting_started/unix-variants.html)
and it doesn't take long if we only need to build the Boost.Test
library. It's much faster than building CMake which is already being
done (on my machine, downloading and building Boost.Test takes 2
minutes, whereas building CMake takes 21 minutes).
  • Loading branch information
generalmimon committed Mar 22, 2024
1 parent ef0ad6e commit 1ca846d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/cpp_stl/_common/print_boost_ver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <iostream>
#include <boost/version.hpp>

int main() {
std::cout << "Boost " << BOOST_LIB_VERSION << std::endl;
return 0;
}
4 changes: 4 additions & 0 deletions src/cpp_stl/_common/validate-boost
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh -ef

c++ -O2 -Wall -Wextra -Wpedantic -o print_boost_ver print_boost_ver.cpp
./validate-version Boost "$(./print_boost_ver)" "$@"
13 changes: 11 additions & 2 deletions src/cpp_stl/clang3.4-linux-x86_64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,30 @@ RUN apt-get update
RUN apt-get install -y --no-install-recommends \
g++ \
make \
libboost-test-dev \
zlib1g-dev \
valgrind \
curl \
libssl-dev \
ruby

# Build and install cmake
RUN curl -fsSL https://github.com/Kitware/CMake/releases/download/v3.27.7/cmake-3.27.7.tar.gz -o cmake-3.27.7.tar.gz
RUN curl -fsSLO https://github.com/Kitware/CMake/releases/download/v3.27.7/cmake-3.27.7.tar.gz
RUN tar -xf cmake-3.27.7.tar.gz && \
cd cmake-3.27.7 && \
./bootstrap && \
make && \
make install && \
cmake --version

# Build Boost.Test from source - see
# https://www.boost.org/doc/libs/1_84_0/libs/test/doc/html/boost_test/adv_scenarios/build_utf.html

RUN curl -fsSLO https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_1_84_0.tar.bz2
RUN tar --bzip2 -xf boost_1_84_0.tar.bz2 && \
cd boost_1_84_0 && \
./bootstrap.sh --with-libraries=test && \
./b2 --with-test variant=debug link=shared install

# Remove gcc and install clang instead
RUN \
apt-get remove -y g++ gcc && \
Expand All @@ -47,3 +55,4 @@ RUN \
# Thread model: posix

RUN ./validate-clang 'clang version 3\.4-'
RUN ./validate-boost '^Boost 1_84$'
13 changes: 11 additions & 2 deletions src/cpp_stl/gcc4.8-linux-x86_64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ RUN apt-get update
RUN apt-get install -y --no-install-recommends \
g++ \
make \
libboost-test-dev \
zlib1g-dev \
valgrind \
curl \
Expand All @@ -23,14 +22,23 @@ RUN apt-get install -y --no-install-recommends \
# from using ancient cmake. Also, it's quite trivial to just build fresh
# cmake from sources, so we do that.

RUN curl -fsSL https://github.com/Kitware/CMake/releases/download/v3.27.7/cmake-3.27.7.tar.gz -o cmake-3.27.7.tar.gz
RUN curl -fsSLO https://github.com/Kitware/CMake/releases/download/v3.27.7/cmake-3.27.7.tar.gz
RUN tar -xf cmake-3.27.7.tar.gz && \
cd cmake-3.27.7 && \
./bootstrap && \
make && \
make install && \
cmake --version

# Build Boost.Test from source - see
# https://www.boost.org/doc/libs/1_84_0/libs/test/doc/html/boost_test/adv_scenarios/build_utf.html

RUN curl -fsSLO https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_1_84_0.tar.bz2
RUN tar --bzip2 -xf boost_1_84_0.tar.bz2 && \
cd boost_1_84_0 && \
./bootstrap.sh --with-libraries=test && \
./b2 --with-test variant=debug link=shared install

# Validate that we've got correct version, e.g. something like this:
#
# $ gcc --version
Expand All @@ -40,3 +48,4 @@ RUN tar -xf cmake-3.27.7.tar.gz && \
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

RUN ./validate-gcc '^gcc \(.*\) 4\.8\.'
RUN ./validate-boost '^Boost 1_84$'

0 comments on commit 1ca846d

Please sign in to comment.