Skip to content

Commit

Permalink
Tweaks to support building the cpp-client in older linux distros/GCC …
Browse files Browse the repository at this point in the history
…versions. (deephaven#4481)

* Tweaks to support building the cpp-client in older linux distros/GCC versions.

* Update cpp-client-base image version and link to build dependencies in cpp client README.md.

* Indentation fix.

* Followup to review comments from Corey.
  • Loading branch information
jcferretti authored Sep 13, 2023
1 parent 0caa2c7 commit 2bf5958
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 40 deletions.
34 changes: 27 additions & 7 deletions cpp-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ C++ compiler and tool suite (cmake etc).
3. Get build tools
```
sudo apt update
sudo apt install curl git g++ cmake make build-essential zlib1g-dev libssl-dev pkg-config
sudo apt install curl git g++ cmake make build-essential zlib1g-dev libbz2-dev libssl-dev pkg-config
```

4. Make a new directory for the Deephaven source code and assign that directory
Expand All @@ -33,17 +33,17 @@ C++ compiler and tool suite (cmake etc).
Get the `build-dependencies.sh` script from Deephaven's base images repository
at the correct version.
You can download it directly from the link
https://raw.githubusercontent.com/deephaven/deephaven-base-images/53081b141aebea4c43238ddae233be49db28cf7b/cpp-client/build-dependencies.sh
https://raw.githubusercontent.com/deephaven/deephaven-base-images/166befad816acbc9dff55d2d8354d60612cd9a8a/cpp-client/build-dependencies.sh
(this script is also used from our automated tools, to generate a docker image to
support tests runs; that's why it lives in a separate repo).
The script downloads, builds and installs the dependent libraries
(Protobuf, re2, gflags, absl, flatbuffers, c-ares, zlib, gRPC, and Arrow).
Decide on a directory for the dependencies to live (eg, "$HOME/dhcpp").
Create that directory and save the script there.

The two main build types of a standard cmake build are supported,
`Release` and `Debug`. By default. `build-dependencies.sh`
creates a `Debug` build. To create a `Release` build, set the
The three main build types of a standard cmake build are supported,
`Release`, `Debug` and `RelWithDebInfo`. By default. `build-dependencies.sh`
creates a `RelWithDebInfo` build. To create a `Release` build, set the
environment variable `BUILD_TYPE=Release` (1)

Edit your local copy of the script if necessary to reflect your selection
Expand All @@ -60,7 +60,7 @@ C++ compiler and tool suite (cmake etc).
# If the directory already exists from a previous attempt, ensure is clean/empty
mkdir -p $DHCPP
cd $DHCPP
wget https://raw.githubusercontent.com/deephaven/deephaven-base-images/53081b141aebea4c43238ddae233be49db28cf7b/cpp-client/build-dependencies.sh
wget https://raw.githubusercontent.com/deephaven/deephaven-base-images/166befad816acbc9dff55d2d8354d60612cd9a8a/cpp-client/build-dependencies.sh
chmod +x ./build-dependencies.sh
# Maybe edit build-dependencies.sh to reflect choices of build tools and build target, if you
# want anything different than defaults; defaults are tested to work,
Expand Down Expand Up @@ -102,7 +102,7 @@ C++ compiler and tool suite (cmake etc).
cd $DHSRC/deephaven-core/cpp-client/deephaven/
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=${DHCPP}/local \
-DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON .. && \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON .. && \
make -j$NCPUS install
```

Expand All @@ -126,6 +126,26 @@ C++ compiler and tool suite (cmake etc).
./tests
```
10. Building in different distributions or with older toolchains.
While we don't support other linux distributions or GCC versions earlier
than 11, this section provides some notes that may help you
in that situation.
* GCC 8 mixed with older versions of GNU as/binutils may fail to compile
`roaring.c` with an error similar to:
```
/tmp/cczCvQKd.s: Assembler messages:
/tmp/cczCvQKd.s:45826: Error: no such instruction: `vpcompressb %zmm0,%zmm1{%k2}'
/tmp/cczCvQKd.s:46092: Error: no such instruction: `vpcompressb %zmm0,%zmm1{%k1}'
```
In that case, add `-DCMAKE_C_FLAGS=-DCROARING_COMPILER_SUPPORTS_AVX512=0`
to the list of arguments to `cmake`.
* Some platforms combining old versions of GCC and cmake may fail
to set the cmake C++ standard to 17 without explicitly adding
`-DCMAKE_CXX_STANDARD=17` to the list of arguments to `cmake`.
Note the default mode for C++ is `-std=gnu++17` for GCC 11.
Notes
(1) The standard assumptions for `Debug` and `Release` apply here.
With a `Debug` build you get debug information which is useful during
Expand Down
2 changes: 1 addition & 1 deletion cpp-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def testCppClient = Docker.registerDockerTask(project, 'testCppClient') {
cd /cpp-client/deephaven/build; \\
. /cpp-client/deps/env.sh; \\
cmake -DCMAKE_INSTALL_PREFIX=/cpp-client/install \\
-DCMAKE_BUILD_TYPE=Debug \\
-DCMAKE_BUILD_TYPE=Release \\
-DBUILD_SHARED_LIBS=ON \\
.. ; \\
make -j\$NCPUS install
Expand Down
2 changes: 1 addition & 1 deletion cpp-client/deephaven/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.14)

if(TARGET client)
# The library has already been built (i.e. through some
Expand Down
2 changes: 1 addition & 1 deletion cpp-client/deephaven/dhclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.14)
project(dhclient)

set(CMAKE_CXX_STANDARD 17)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,10 @@ class TableHandleManager {
* Constructor. Used internally.
*/
explicit TableHandleManager(std::shared_ptr<impl::TableHandleManagerImpl> impl);
/**
* Copy constructor
*/
TableHandleManager(const TableHandleManager &other) noexcept;
/**
* Move constructor
*/
TableHandleManager(TableHandleManager &&other) noexcept;
/**
* Copy assigment operator.
*/
TableHandleManager &operator=(const TableHandleManager &other) noexcept;
/**
* Move assigment operator.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ class ClientOptions {
*/
ClientOptions();
/**
* Copy constructor
*/
ClientOptions(const ClientOptions &other) noexcept;
* Copy constructor
*/
ClientOptions(const ClientOptions &other);
/**
* Move constructor
*/
ClientOptions(ClientOptions &&other) noexcept;
/**
* Copy assigment operator.
*/
ClientOptions &operator=(const ClientOptions &other) noexcept;
ClientOptions &operator=(const ClientOptions &other);
/**
* Move assigment operator.
*/
Expand Down
2 changes: 0 additions & 2 deletions cpp-client/deephaven/dhclient/src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ bool Client::RemoveOnCloseCallback(OnCloseCbId cb_id) {

TableHandleManager::TableHandleManager() = default;
TableHandleManager::TableHandleManager(std::shared_ptr<impl::TableHandleManagerImpl> impl) : impl_(std::move(impl)) {}
TableHandleManager::TableHandleManager(const TableHandleManager &other) noexcept = default;
TableHandleManager::TableHandleManager(TableHandleManager &&other) noexcept = default;
TableHandleManager &TableHandleManager::operator=(const TableHandleManager &other) noexcept = default;
TableHandleManager &TableHandleManager::operator=(TableHandleManager &&other) noexcept = default;
TableHandleManager::~TableHandleManager() = default;

Expand Down
5 changes: 3 additions & 2 deletions cpp-client/deephaven/dhclient/src/client_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ ClientOptions::ClientOptions() {
SetSessionType("python");
}

ClientOptions::ClientOptions(const ClientOptions &other) noexcept = default;
ClientOptions::ClientOptions(const ClientOptions &other) = default;
ClientOptions::ClientOptions(ClientOptions &&other) noexcept = default;
ClientOptions &ClientOptions::operator=(const ClientOptions &other) noexcept = default;
ClientOptions &ClientOptions::operator=(const ClientOptions &other) = default;
ClientOptions &ClientOptions::operator=(ClientOptions &&other) noexcept = default;

ClientOptions::~ClientOptions() = default;

ClientOptions &ClientOptions::SetDefaultAuthentication() {
Expand Down
2 changes: 1 addition & 1 deletion cpp-client/deephaven/dhcore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.14)
project(dhcore)

set(CMAKE_CXX_STANDARD 17)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ bool DumpFormat(std::ostream &s, const char **fmt, bool placeholder_expected);
std::ostream &Streamf(std::ostream &s, const char *fmt);

template<typename HEAD, typename... REST>
std::ostream &Streamf(std::ostream &s, const char *fmt, const HEAD &head, REST &&... rest) {
(void) deephaven::dhcore::utility::internal::DumpFormat(s, &fmt, true);
s << head;
std::ostream &Streamf(std::ostream &s, const char *fmt, HEAD &&head, REST &&... rest) {
if (!deephaven::dhcore::utility::internal::DumpFormat(s, &fmt, true)) {
return s;
}
s << std::forward<HEAD>(head);
return Streamf(s, fmt, std::forward<REST>(rest)...);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 3.16)
project(create_table_with_arrow_flight)

set(CMAKE_CXX_STANDARD 17)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 3.16)
project(create_table_with_table_maker)

set(CMAKE_CXX_STANDARD 17)
Expand Down
1 change: 0 additions & 1 deletion cpp-client/deephaven/examples/demos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 3.16)
project(demos)

set(CMAKE_CXX_STANDARD 17)
Expand Down
1 change: 0 additions & 1 deletion cpp-client/deephaven/examples/hello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 3.16)
project(hello_world)

set(CMAKE_CXX_STANDARD 17)
Expand Down
1 change: 0 additions & 1 deletion cpp-client/deephaven/examples/read_csv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 3.16)
project(read_csv)

set(CMAKE_CXX_STANDARD 17)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 3.16)
project(read_table_with_arrow_flight)

set(CMAKE_CXX_STANDARD 17)
Expand Down
2 changes: 1 addition & 1 deletion cpp-client/deephaven/examples/table_cleanup/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.14)
project(table_cleanup)

set(CMAKE_CXX_STANDARD 17)
Expand Down
2 changes: 1 addition & 1 deletion cpp-client/deephaven/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.14)
project(tests)

set(CMAKE_CXX_STANDARD 17)
Expand Down
2 changes: 1 addition & 1 deletion cpp-client/deephaven/tests/select_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TEST_CASE("Support all types", "[select]") {
byte_data.push_back(i * 11);
short_data.push_back(i * 1000);
int_data.push_back(i * 1'000'000);
long_data.push_back(i * 1'000'000'000);
long_data.push_back(static_cast<long>(i) * 1'000'000'000);
float_data.push_back(i * 123.456F);
doubleData.push_back(i * 987654.321);
stringData.push_back(Stringf("test %o", i));
Expand Down
2 changes: 1 addition & 1 deletion docker/registry/cpp-client-base/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ deephaven.registry.imageName=ghcr.io/deephaven/cpp-client-base:latest
# It is in two different parts of the file (text and command examples).
# If you have the image sha for this file, you can get the commit sha for the README using:
# docker buildx imagetools inspect ghcr.io/deephaven/cpp-client-base@sha256:$IMAGESHA --format '{{ $metadata := index .Provenance.SLSA.metadata "https://mobyproject.org/buildkit@v1#metadata" }} {{ $metadata.vcs.revision }}'
deephaven.registry.imageId=ghcr.io/deephaven/cpp-client-base@sha256:105b358c20bd004daa67a5a947e0da1190568854da07adf7b2ac66e2c78f9287
deephaven.registry.imageId=ghcr.io/deephaven/cpp-client-base@sha256:74034b2c26a26033258a8d0808f45d6a010300c07a9135260fcb0c1691de04dd
# TODO(deephaven-base-images#54): arm64 native image for cpp-client-base
deephaven.registry.platform=linux/amd64

0 comments on commit 2bf5958

Please sign in to comment.