From be838652fae1ee4683b62785192a58992a76d1fe Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Wed, 31 Aug 2022 18:02:18 +0000 Subject: [PATCH] examples: Compile with c++20 This change will apply to ubuntu only. Fixes: https://tracker.ceph.com/issues/57163 Signed-off-by: Matan Breizman --- examples/librados/Makefile | 2 +- qa/workunits/ceph-helpers-root.sh | 12 ++++++++++++ qa/workunits/rados/test_librados_build.sh | 5 ++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/examples/librados/Makefile b/examples/librados/Makefile index fd61cb99803..a97d640eb1f 100644 --- a/examples/librados/Makefile +++ b/examples/librados/Makefile @@ -1,6 +1,6 @@ CXX?=g++ -CXX_FLAGS?=-std=c++11 -Wno-unused-parameter -Wall -Wextra -Werror -g +CXX_FLAGS+=-Wno-unused-parameter -Wall -Wextra -Werror -g CXX_LIBS?=-lrados -lradosstriper CXX_INC?=$(LOCAL_LIBRADOS_INC) CXX_CC=$(CXX) $(CXX_FLAGS) $(CXX_INC) $(LOCAL_LIBRADOS) diff --git a/qa/workunits/ceph-helpers-root.sh b/qa/workunits/ceph-helpers-root.sh index f4557aec458..5b5d2b409ee 100755 --- a/qa/workunits/ceph-helpers-root.sh +++ b/qa/workunits/ceph-helpers-root.sh @@ -28,9 +28,21 @@ function distro_version() { } function install() { + if [ $(distro_id) = "ubuntu" ]; then + sudo apt-get purge -y gcc + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + fi for package in "$@" ; do install_one $package done + if [ $(distro_id) = "ubuntu" ]; then + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11 + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 11 + sudo update-alternatives --set cc /usr/bin/gcc + sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 11 + sudo update-alternatives --set c++ /usr/bin/g++ + fi } function install_one() { diff --git a/qa/workunits/rados/test_librados_build.sh b/qa/workunits/rados/test_librados_build.sh index 75f1748cf42..3463c47dcdb 100755 --- a/qa/workunits/rados/test_librados_build.sh +++ b/qa/workunits/rados/test_librados_build.sh @@ -71,7 +71,10 @@ pushd $DESTDIR case $(distro_id) in centos|fedora|rhel|opensuse*|suse|sles) install gcc-c++ make libradospp-devel librados-devel;; - ubuntu|debian|devuan|softiron) + ubuntu) + install gcc-11 g++-11 make libradospp-dev librados-dev + export CXX_FLAGS="-std=c++20";; + debian|devuan|softiron) install g++ make libradospp-dev librados-dev;; *) echo "$(distro_id) is unknown, $@ will have to be installed manually." -- 2.39.5