From e931f27d3be6bba6a2260efbde863c5e57f53c54 Mon Sep 17 00:00:00 2001 From: Alex Kremer Date: Mon, 15 Apr 2024 12:09:34 +0100 Subject: [PATCH] Support clang 16 in docker CI (#1348) Fixes #1175 --- .clang-tidy | 6 +- .github/actions/restore_cache/action.yml | 7 +- .github/actions/save_cache/action.yml | 7 +- .github/actions/setup_conan/action.yml | 8 +- .github/workflows/build.yml | 38 +++++++++- .github/workflows/clang-tidy.yml | 3 + .github/workflows/nightly.yml | 2 + cmake/CheckCompiler.cmake | 14 ++-- docker/ci/dockerfile | 54 ++++++++++---- docker/compilers/clang-16/dockerfile | 19 +++++ docker/compilers/gcc-12/control.m4 | 6 ++ docker/compilers/gcc-12/dockerfile | 93 ++++++++++++++++-------- docker/compilers/gcc-12/ld.so.conf | 2 + src/etl/impl/LedgerLoader.hpp | 4 +- src/etl/impl/SubscriptionSource.cpp | 6 +- src/feed/impl/TransactionFeed.cpp | 2 +- src/main/CMakeLists.txt | 7 +- src/util/CMakeLists.txt | 10 +-- src/util/async/Error.hpp | 8 ++ 19 files changed, 217 insertions(+), 79 deletions(-) create mode 100644 docker/compilers/clang-16/dockerfile create mode 100644 docker/compilers/gcc-12/control.m4 create mode 100644 docker/compilers/gcc-12/ld.so.conf diff --git a/.clang-tidy b/.clang-tidy index 76303ce8..579fd735 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -124,11 +124,7 @@ CheckOptions: readability-braces-around-statements.ShortStatementLines: 2 bugprone-unsafe-functions.ReportMoreUnsafeFunctions: true bugprone-unused-return-value.CheckedReturnTypes: ::std::error_code;::std::error_condition;::std::errc;::std::expected - misc-include-cleaner.IgnoreHeaders: '.*/(detail|impl)/.*' + misc-include-cleaner.IgnoreHeaders: '.*/(detail|impl)/.*;.*(expected|unexpected).*' HeaderFilterRegex: '^.*/(src|unittests)/.*\.(h|hpp)$' WarningsAsErrors: '*' -ExtraArgs: - - -D__cpp_concepts=202002 - - -Wno-builtin-macro-redefined - diff --git a/.github/actions/restore_cache/action.yml b/.github/actions/restore_cache/action.yml index 43ef3ef5..fe2ebf35 100644 --- a/.github/actions/restore_cache/action.yml +++ b/.github/actions/restore_cache/action.yml @@ -4,6 +4,9 @@ inputs: conan_dir: description: Path to .conan directory required: true + conan_profile: + description: Conan profile name + required: true ccache_dir: description: Path to .ccache directory required: true @@ -48,7 +51,7 @@ runs: id: conan_cache with: path: ${{ inputs.conan_dir }}/data - key: clio-conan_data-${{ runner.os }}-${{ inputs.build_type }}-develop-${{ steps.conan_hash.outputs.hash }} + key: clio-conan_data-${{ runner.os }}-${{ inputs.build_type }}-${{ inputs.conan_profile }}-develop-${{ steps.conan_hash.outputs.hash }} - name: Restore ccache cache uses: actions/cache/restore@v4 @@ -56,4 +59,4 @@ runs: if: ${{ env.CCACHE_DISABLE != '1' }} with: path: ${{ inputs.ccache_dir }} - key: clio-ccache-${{ runner.os }}-${{ inputs.build_type }}${{ inputs.code_coverage == 'true' && '-code_coverage' || '' }}-develop-${{ steps.git_common_ancestor.outputs.commit }} + key: clio-ccache-${{ runner.os }}-${{ inputs.build_type }}${{ inputs.code_coverage == 'true' && '-code_coverage' || '' }}-${{ inputs.conan_profile }}-develop-${{ steps.git_common_ancestor.outputs.commit }} diff --git a/.github/actions/save_cache/action.yml b/.github/actions/save_cache/action.yml index 5d38015f..0511a763 100644 --- a/.github/actions/save_cache/action.yml +++ b/.github/actions/save_cache/action.yml @@ -4,6 +4,9 @@ inputs: conan_dir: description: Path to .conan directory required: true + conan_profile: + description: Conan profile name + required: true conan_hash: description: Hash to use as a part of conan cache key required: true @@ -44,13 +47,13 @@ runs: uses: actions/cache/save@v4 with: path: ${{ inputs.conan_dir }}/data - key: clio-conan_data-${{ runner.os }}-${{ inputs.build_type }}-develop-${{ inputs.conan_hash }} + key: clio-conan_data-${{ runner.os }}-${{ inputs.build_type }}-${{ inputs.conan_profile }}-develop-${{ inputs.conan_hash }} - name: Save ccache cache if: ${{ inputs.ccache_cache_hit != 'true' || inputs.ccache_cache_miss_rate == '100.0' }} uses: actions/cache/save@v4 with: path: ${{ inputs.ccache_dir }} - key: clio-ccache-${{ runner.os }}-${{ inputs.build_type }}${{ inputs.code_coverage == 'true' && '-code_coverage' || '' }}-develop-${{ steps.git_common_ancestor.outputs.commit }} + key: clio-ccache-${{ runner.os }}-${{ inputs.build_type }}${{ inputs.code_coverage == 'true' && '-code_coverage' || '' }}-${{ inputs.conan_profile }}-develop-${{ steps.git_common_ancestor.outputs.commit }} diff --git a/.github/actions/setup_conan/action.yml b/.github/actions/setup_conan/action.yml index d4541eec..c7aa3c8a 100644 --- a/.github/actions/setup_conan/action.yml +++ b/.github/actions/setup_conan/action.yml @@ -1,5 +1,9 @@ name: Setup conan description: Setup conan profile and artifactory +inputs: + conan_profile: + description: Conan profile name + required: true outputs: conan_profile: description: Created conan profile name @@ -11,7 +15,7 @@ runs: if: ${{ runner.os == 'macOS' }} shell: bash env: - CONAN_PROFILE: clio_apple_clang_15 + CONAN_PROFILE: apple_clang_15 id: conan_setup_mac run: | echo "Creating $CONAN_PROFILE conan profile"; @@ -27,7 +31,7 @@ runs: shell: bash id: conan_setup_linux run: | - echo "created_conan_profile=default" >> $GITHUB_OUTPUT + echo "created_conan_profile=${{ inputs.conan_profile }}" >> $GITHUB_OUTPUT - name: Export output variable shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41b09663..a1e5c50a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,12 +50,26 @@ jobs: container: image: rippleci/clio_ci:latest build_type: Release + conan_profile: gcc code_coverage: false - os: heavy container: image: rippleci/clio_ci:latest build_type: Debug + conan_profile: gcc code_coverage: true + - os: heavy + container: + image: rippleci/clio_ci:latest + build_type: Release + conan_profile: clang + code_coverage: false + - os: heavy + container: + image: rippleci/clio_ci:latest + build_type: Debug + conan_profile: clang + code_coverage: false - os: macos14 build_type: Release code_coverage: false @@ -88,12 +102,15 @@ jobs: - name: Setup conan uses: ./.github/actions/setup_conan id: conan + with: + conan_profile: ${{ matrix.conan_profile }} - name: Restore cache uses: ./.github/actions/restore_cache id: restore_cache with: conan_dir: ${{ env.CONAN_USER_HOME }}/.conan + conan_profile: ${{ steps.conan.outputs.conan_profile }} ccache_dir: ${{ env.CCACHE_DIR }} build_type: ${{ matrix.build_type }} code_coverage: ${{ matrix.code_coverage }} @@ -125,14 +142,14 @@ jobs: - name: Upload clio_server uses: actions/upload-artifact@v4 with: - name: clio_server_${{ runner.os }}_${{ matrix.build_type }} + name: clio_server_${{ runner.os }}_${{ matrix.build_type }}_${{ steps.conan.outputs.conan_profile }} path: build/clio_server - name: Upload clio_tests if: ${{ !matrix.code_coverage }} uses: actions/upload-artifact@v4 with: - name: clio_tests_${{ runner.os }} + name: clio_tests_${{ runner.os }}_${{ matrix.build_type }}_${{ steps.conan.outputs.conan_profile }} path: build/clio_tests - name: Save cache @@ -146,6 +163,7 @@ jobs: ccache_cache_miss_rate: ${{ steps.ccache_stats.outputs.miss_rate }} build_type: ${{ matrix.build_type }} code_coverage: ${{ matrix.code_coverage }} + conan_profile: ${{ steps.conan.outputs.conan_profile }} # TODO: This is not a part of build process but it is the easiest way to do it here. # It will be refactored in https://github.com/XRPLF/clio/issues/1075 @@ -170,7 +188,21 @@ jobs: - os: heavy container: image: rippleci/clio_ci:latest + conan_profile: gcc + build_type: Release + - os: heavy + container: + image: rippleci/clio_ci:latest + conan_profile: clang + build_type: Release + - os: heavy + container: + image: rippleci/clio_ci:latest + conan_profile: clang + build_type: Debug - os: macos14 + conan_profile: apple_clang_15 + build_type: Release runs-on: [self-hosted, "${{ matrix.os }}"] container: ${{ matrix.container }} @@ -181,7 +213,7 @@ jobs: - uses: actions/download-artifact@v4 with: - name: clio_tests_${{ runner.os }} + name: clio_tests_${{ runner.os }}_${{ matrix.build_type }}_${{ matrix.conan_profile }} - name: Run clio_tests run: | chmod +x ./clio_tests diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index df51f495..739ef1d1 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -33,6 +33,8 @@ jobs: - name: Setup conan uses: ./.github/actions/setup_conan id: conan + with: + conan_profile: clang - name: Restore cache uses: ./.github/actions/restore_cache @@ -40,6 +42,7 @@ jobs: with: conan_dir: ${{ env.CONAN_USER_HOME }}/.conan ccache_dir: ${{ env.CCACHE_DIR }} + conan_profile: ${{ steps.conan.outputs.conan_profile }} - name: Run conan and cmake uses: ./.github/actions/generate diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 8a5a9a38..ccd2d9b7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -41,6 +41,8 @@ jobs: - name: Setup conan uses: ./.github/actions/setup_conan id: conan + with: + conan_profile: gcc - name: Run conan and cmake uses: ./.github/actions/generate diff --git a/cmake/CheckCompiler.cmake b/cmake/CheckCompiler.cmake index a4d01862..30059de9 100644 --- a/cmake/CheckCompiler.cmake +++ b/cmake/CheckCompiler.cmake @@ -1,20 +1,20 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) - message(FATAL_ERROR "Clang 14+ required for building clio") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) + message(FATAL_ERROR "Clang 16+ required for building clio") endif () set(is_clang TRUE) elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) - message(FATAL_ERROR "AppleClang 14+ required for building clio") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15) + message(FATAL_ERROR "AppleClang 15+ required for building clio") endif () set(is_appleclang TRUE) elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11) - message(FATAL_ERROR "GCC 11+ required for building clio") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12) + message(FATAL_ERROR "GCC 12+ required for building clio") endif () set(is_gcc TRUE) else () - message(FATAL_ERROR "Supported compilers: AppleClang 14+, Clang 14+, GCC 11+") + message(FATAL_ERROR "Supported compilers: AppleClang 15+, Clang 16+, GCC 12+") endif () if (san) diff --git a/docker/ci/dockerfile b/docker/ci/dockerfile index 25f81494..a0f1dea6 100644 --- a/docker/ci/dockerfile +++ b/docker/ci/dockerfile @@ -1,4 +1,4 @@ -FROM rippleci/clio_gcc:12.3.0 +FROM rippleci/clio_clang:16 ARG DEBIAN_FRONTEND=noninteractive ARG TARGETARCH @@ -25,6 +25,23 @@ RUN apt update -qq \ && pip3 install -q --upgrade --no-cache-dir pip && pip3 install -q --no-cache-dir conan==1.62 gcovr cmake cmake-format \ && apt-get clean && apt remove -y software-properties-common +# Install gcc-12 and make ldconfig aware of the new libstdc++ location (for gcc) +# Note: Clang is using libc++ instead +COPY --from=rippleci/clio_gcc:12.3.0 /gcc12.deb / +RUN apt update && apt-get install -y binutils libc6-dev \ + && dpkg -i /gcc12.deb \ + && rm -rf /gcc12.deb \ + && ldconfig + +# Rewire to use gcc-12 as default compiler +RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 \ + && update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-12 100 \ + && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 \ + && update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-12 100 \ + && update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-12 100 \ + && update-alternatives --install /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-12 100 \ + && update-alternatives --install /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-12 100 + WORKDIR /tmp # Install ccache from source @@ -51,10 +68,6 @@ RUN wget https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VER && mv gh_${GH_VERSION}_linux_${TARGETARCH}/bin/gh /usr/bin/gh \ && rm -rf /tmp/* /var/tmp/* -# Libstdc++ from gcc-12 got lost, probably via apt update. Let's recover it -RUN update-alternatives --install /usr/bin/ccache ccache /usr/local/bin/ccache 100 \ - && update-alternatives --auto libstdc++.so.6 - WORKDIR /root # Using root by default is not very secure but github checkout action doesn't work with any other user # https://github.com/actions/checkout/issues/956 @@ -62,13 +75,26 @@ WORKDIR /root # https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#user # Setup conan +RUN conan remote add --insert 0 conan-non-prod http://18.143.149.228:8081/artifactory/api/conan/conan-non-prod + # Note: intentionally leaving cppstd=20 -RUN conan profile new default --detect \ - && conan profile update settings.compiler=gcc default \ - && conan profile update settings.compiler.version=12 default \ - && conan profile update settings.compiler.cppstd=20 default \ - && conan profile update settings.compiler.libcxx=libstdc++11 default \ - && conan profile update env.CC=/opt/bin/gcc default \ - && conan profile update env.CXX=/opt/bin/g++ default \ - && conan profile update "conf.tools.build:compiler_executables={\"c\": \"/opt/bin/gcc\", \"cpp\": \"/opt/bin/g++\"}" default \ - && conan remote add --insert 0 conan-non-prod http://18.143.149.228:8081/artifactory/api/conan/conan-non-prod +RUN conan profile new gcc --detect \ + && conan profile update settings.compiler=gcc gcc \ + && conan profile update settings.compiler.version=12 gcc \ + && conan profile update settings.compiler.cppstd=20 gcc \ + && conan profile update settings.compiler.libcxx=libstdc++11 gcc \ + && conan profile update env.CC=/usr/bin/gcc-12 gcc \ + && conan profile update env.CXX=/usr/bin/g++-12 gcc \ + && conan profile update "conf.tools.build:compiler_executables={\"c\": \"/usr/bin/gcc-12\", \"cpp\": \"/usr/bin/g++-12\"}" gcc + +RUN conan profile new clang --detect \ + && conan profile update settings.compiler=clang clang \ + && conan profile update settings.compiler.version=16 clang \ + && conan profile update settings.compiler.cppstd=20 clang \ + && conan profile update settings.compiler.libcxx=libc++ clang \ + && conan profile update env.CC=/usr/bin/clang-16 clang \ + && conan profile update env.CXX=/usr/bin/clang++-16 clang \ + && conan profile update env.CXXFLAGS="-DBOOST_ASIO_DISABLE_CONCEPTS" clang \ + && conan profile update "conf.tools.build:compiler_executables={\"c\": \"/usr/bin/clang-16\", \"cpp\": \"/usr/bin/clang++-16\"}" clang + +RUN echo "include(gcc)" >> .conan/profiles/default diff --git a/docker/compilers/clang-16/dockerfile b/docker/compilers/clang-16/dockerfile new file mode 100644 index 00000000..7972d60b --- /dev/null +++ b/docker/compilers/clang-16/dockerfile @@ -0,0 +1,19 @@ +FROM ubuntu:focal +ARG DEBIAN_FRONTEND=noninteractive +ARG TARGETARCH + +SHELL ["/bin/bash", "-c"] +USER root +WORKDIR /root + +ENV CLANG_VERSION=16 + +RUN apt update -qq \ + && apt install -qq -y --no-install-recommends --no-install-suggests \ + wget software-properties-common gnupg + +RUN wget https://apt.llvm.org/llvm.sh \ + && chmod +x llvm.sh \ + && ./llvm.sh ${CLANG_VERSION} \ + && rm -rf llvm.sh \ + && apt-get install -y libc++-16-dev libc++abi-16-dev diff --git a/docker/compilers/gcc-12/control.m4 b/docker/compilers/gcc-12/control.m4 new file mode 100644 index 00000000..878ea935 --- /dev/null +++ b/docker/compilers/gcc-12/control.m4 @@ -0,0 +1,6 @@ +Package: gcc-12-ubuntu-UBUNTUVERSION +Version: VERSION +Architecture: TARGETARCH +Maintainer: Alex Kremer +Description: Gcc VERSION build for ubuntu UBUNTUVERSION +Depends: binutils, libc6-dev diff --git a/docker/compilers/gcc-12/dockerfile b/docker/compilers/gcc-12/dockerfile index a811c55b..fc239585 100644 --- a/docker/compilers/gcc-12/dockerfile +++ b/docker/compilers/gcc-12/dockerfile @@ -1,41 +1,74 @@ FROM ubuntu:focal as build + ARG DEBIAN_FRONTEND=noninteractive ARG TARGETARCH +ARG UBUNTU_VERSION=20.04 +ARG GCC_VERSION=12.3.0 +ARG BUILD_VERSION=1 -SHELL ["/bin/bash", "-c"] -USER root -WORKDIR /root +RUN apt update && apt install -y wget build-essential file flex libz-dev libzstd-dev +RUN wget https://gcc.gnu.org/pub/gcc/releases/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.gz \ + && tar xf gcc-$GCC_VERSION.tar.gz \ + && cd /gcc-$GCC_VERSION && ./contrib/download_prerequisites -ENV GCC_VERSION=12.3.0 +RUN mkdir /${TARGETARCH}-gcc-12 +WORKDIR /${TARGETARCH}-gcc-12 +RUN /gcc-$GCC_VERSION/configure \ + --with-pkgversion="clio-build-$BUILD_VERSION https://github.com/XRPLF/clio" \ + --enable-languages=c,c++ \ + --prefix=/usr \ + --with-gcc-major-version-only \ + --program-suffix=-12 \ + --enable-shared \ + --enable-linker-build-id \ + --libexecdir=/usr/lib \ + --without-included-gettext \ + --enable-threads=posix \ + --libdir=/usr/lib \ + --disable-nls \ + --enable-clocale=gnu \ + --enable-libstdcxx-backtrace=yes \ + --enable-libstdcxx-debug \ + --enable-libstdcxx-time=yes \ + --with-default-libstdcxx-abi=new \ + --enable-gnu-unique-object \ + --disable-vtable-verify \ + --enable-plugin \ + --enable-default-pie \ + --with-system-zlib \ + --enable-libphobos-checking=release \ + --with-target-system-zlib=auto \ + --disable-werror \ + --enable-cet \ + --disable-multilib \ + --without-cuda-driver \ + --enable-checking=release \ + && make -j`nproc` \ + && make install-strip DESTDIR=/gcc-$GCC_VERSION-$BUILD_VERSION-ubuntu-$UBUNTU_VERSION \ + && mkdir -p /gcc-$GCC_VERSION-$BUILD_VERSION-ubuntu-$UBUNTU_VERSION/usr/share/gdb/auto-load/usr/lib64 \ + && mv /gcc-$GCC_VERSION-$BUILD_VERSION-ubuntu-$UBUNTU_VERSION/usr/lib64/libstdc++.so.6.0.30-gdb.py /gcc-$GCC_VERSION-$BUILD_VERSION-ubuntu-$UBUNTU_VERSION/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.30-gdb.py -RUN apt update -qq \ - && apt install -qq -y --no-install-recommends --no-install-suggests \ - gnupg wget software-properties-common build-essential +# Generate deb +WORKDIR / +COPY control.m4 / +COPY ld.so.conf /gcc-$GCC_VERSION-$BUILD_VERSION-ubuntu-$UBUNTU_VERSION/etc/ld.so.conf.d/1-gcc-12.conf -WORKDIR /root - -# Install gcc-12 from source -RUN wget "https://mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz" \ - && tar xf "gcc-${GCC_VERSION}.tar.gz" \ - && cd "gcc-${GCC_VERSION}" \ - && ./contrib/download_prerequisites \ - && mkdir build && cd build \ - && ../configure --enable-languages=c,c++ --disable-multilib --with-build-config='bootstrap-O3' --prefix='/opt' \ - && make -j$(nproc) profiledbootstrap && make install-strip \ - && rm -rf /root/* +RUN mkdir /gcc-$GCC_VERSION-$BUILD_VERSION-ubuntu-$UBUNTU_VERSION/DEBIAN \ + && m4 -P -DUBUNTU_VERSION=$UBUNTU_VERSION -DVERSION=$GCC_VERSION-$BUILD_VERSION -DTARGETARCH=$TARGETARCH control.m4 > /gcc-$GCC_VERSION-$BUILD_VERSION-ubuntu-$UBUNTU_VERSION/DEBIAN/control \ + && dpkg-deb --build --root-owner-group /gcc-$GCC_VERSION-$BUILD_VERSION-ubuntu-$UBUNTU_VERSION /gcc12.deb +# Create final image FROM ubuntu:focal as gcc -WORKDIR /root +COPY --from=build /gcc12.deb / -RUN apt update -qq && apt autoclean -y && apt autoremove -y -COPY --from=build /opt /opt +# Make gcc-12 available but also leave gcc12.deb for others to copy if needed +RUN apt update && apt-get install -y binutils libc6-dev \ + && dpkg -i /gcc12.deb -# Rewire to use gcc-12 -RUN update-alternatives --install /usr/bin/g++ g++ /opt/bin/g++ 100 \ - && update-alternatives --install /usr/bin/c++ c++ /opt/bin/g++ 100 \ - && update-alternatives --install /usr/bin/gcc gcc /opt/bin/gcc 100 \ - && update-alternatives --install /usr/bin/cc cc /opt/bin/gcc 100 \ - && update-alternatives --install /usr/bin/gcov gcov /opt/bin/gcov 100 \ - && update-alternatives --install /usr/bin/gcov-dump gcov-dump /opt/bin/gcov-dump 100 \ - && update-alternatives --install /usr/bin/gcov-tool gcov-tool /opt/bin/gcov-tool 100 \ - && update-alternatives --install /lib/*-linux-gnu/libstdc++.so.6 libstdc++.so.6 /opt/lib64/libstdc++.so.6 100 +RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 \ + && update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-12 100 \ + && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 \ + && update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-12 100 \ + && update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-12 100 \ + && update-alternatives --install /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-12 100 \ + && update-alternatives --install /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-12 100 diff --git a/docker/compilers/gcc-12/ld.so.conf b/docker/compilers/gcc-12/ld.so.conf new file mode 100644 index 00000000..063e964a --- /dev/null +++ b/docker/compilers/gcc-12/ld.so.conf @@ -0,0 +1,2 @@ +# Path to the directory containing libstdc++.so.6 +/usr/lib64 diff --git a/src/etl/impl/LedgerLoader.hpp b/src/etl/impl/LedgerLoader.hpp index fa4ef162..b3353d76 100644 --- a/src/etl/impl/LedgerLoader.hpp +++ b/src/etl/impl/LedgerLoader.hpp @@ -203,8 +203,8 @@ public: size_t numWrites = 0; backend_->cache().setFull(); - auto seconds = ::util::timed([this, edgeKeys = &edgeKeys, sequence, &numWrites] { - for (auto& key : *edgeKeys) { + auto seconds = ::util::timed([this, keys = &edgeKeys, sequence, &numWrites] { + for (auto& key : *keys) { LOG(log_.debug()) << "Writing edge key = " << ripple::strHex(key); auto succ = backend_->cache().getSuccessor(*ripple::uint256::fromVoidChecked(key), sequence); if (succ) diff --git a/src/etl/impl/SubscriptionSource.cpp b/src/etl/impl/SubscriptionSource.cpp index d162fb70..50feefae 100644 --- a/src/etl/impl/SubscriptionSource.cpp +++ b/src/etl/impl/SubscriptionSource.cpp @@ -234,9 +234,9 @@ SubscriptionSource::handleError(util::requests::RequestError const& error, boost } if (wsConnection_ != nullptr) { - auto const error = wsConnection_->close(yield); - if (error) { - LOG(log_.error()) << "Error closing websocket connection: " << error->message(); + auto const err = wsConnection_->close(yield); + if (err) { + LOG(log_.error()) << "Error closing websocket connection: " << err->message(); } wsConnection_.reset(); } diff --git a/src/feed/impl/TransactionFeed.cpp b/src/feed/impl/TransactionFeed.cpp index 22d6ba81..1803f13c 100644 --- a/src/feed/impl/TransactionFeed.cpp +++ b/src/feed/impl/TransactionFeed.cpp @@ -171,7 +171,7 @@ TransactionFeed::pub( } } - auto const genJsonByVersion = [&, tx = tx, meta = meta](std::uint32_t version) { + auto const genJsonByVersion = [&, tx, meta](std::uint32_t version) { boost::json::object pubObj; auto const txKey = version < 2u ? JS(transaction) : JS(tx_json); pubObj[txKey] = rpc::toJson(*tx); diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 273aa466..fe813359 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -3,13 +3,16 @@ target_sources(clio PRIVATE impl/Build.cpp) target_link_libraries(clio PUBLIC clio_etl clio_feed clio_web clio_rpc) -target_compile_features(clio PUBLIC cxx_std_20) +target_compile_features(clio PUBLIC cxx_std_23) # Clio server add_executable(clio_server) target_sources(clio_server PRIVATE Main.cpp) target_link_libraries(clio_server PRIVATE clio) target_link_options( - clio_server PRIVATE $<$>,$>>:-static-libstdc++ -static-libgcc> + # For now let's assume that we only using libstdc++ under gcc. + # + # TODO: libc++ static linkage in https://github.com/XRPLF/clio/issues/1300 + clio_server PRIVATE $<$,$>>:-static-libstdc++ -static-libgcc> ) set_target_properties(clio_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 0e11a027..30933978 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -36,9 +36,7 @@ target_link_libraries( clio_options ) -if (is_gcc) - # FIXME: needed on gcc for now - # - # For some reason cmake doesn't propagate the compile definitions from clio_options so we need to add them here - target_compile_definitions(clio_util PUBLIC BOOST_ASIO_DISABLE_CONCEPTS) -endif () +# FIXME: needed on gcc-12, clang-16 and AppleClang for now (known boost 1.82 issue for some compilers) +# +# For some reason cmake doesn't propagate the compile definitions from clio_options so we need to add them here +target_compile_definitions(clio_util PUBLIC BOOST_ASIO_DISABLE_CONCEPTS) diff --git a/src/util/async/Error.hpp b/src/util/async/Error.hpp index 9f1ae246..b0b9c5f1 100644 --- a/src/util/async/Error.hpp +++ b/src/util/async/Error.hpp @@ -26,6 +26,11 @@ #include #include +// for the static_assert at the bottom which fixes clang compilation: +// see: https://godbolt.org/z/fzTjMd7G1 vs https://godbolt.org/z/jhKG7deen +#include +#include + namespace util::async { /** @@ -63,4 +68,7 @@ struct ExecutionError { std::string message; }; +// these are not the robots you are looking for... +static_assert(std::is_copy_constructible_v>); + } // namespace util::async