Skip to content

Commit

Permalink
Enforce Cxx17 (#2878)
Browse files Browse the repository at this point in the history
* Move clang test environment to clang-6 for c++17 support

* stop building clang 3.9.1

* centos updates

GCC 7.4.1
cmake 3.15.4
boost build shared via prep.sh.in
fix spec.in for nano_rpc

* remove support for building CMAKE_CXX_STANDARD 14

* test instabilitydisable node_DeathTest.readonly_block_store_not_existinstability with clang and actions specfically
  • Loading branch information
Russel Waters authored Aug 12, 2020
1 parent 05f7318 commit 49cb67f
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Fetch Deps
run: ci/actions/linux/install_deps.sh
- name: Run Tests
run: docker run -v ${PWD}:/workspace nanocurrency/nano-env:clang /bin/bash -c "cd /workspace && RELEASE=1 ./ci/build-travis.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5 ${PWD}"
run: docker run -v ${PWD}:/workspace nanocurrency/nano-env:clang-6 /bin/bash -c "cd /workspace && RELEASE=1 ./ci/build-travis.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5 ${PWD}"

windows_test:
runs-on: windows-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Fetch Deps
run: ci/actions/linux/install_deps.sh
- name: Run Tests
run: docker run -v ${PWD}:/workspace nanocurrency/nano-env:clang /bin/bash -c "cd /workspace && ./ci/build-travis.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5 ${PWD}"
run: docker run -v ${PWD}:/workspace nanocurrency/nano-env:clang-6 /bin/bash -c "cd /workspace && ./ci/build-travis.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5 ${PWD}"

windows_test:
runs-on: windows-latest
Expand Down
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,7 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
#set(CMAKE_C_EXTENSIONS OFF)

set(NANO_SUPPORTED_CPP_STANDARD "17" CACHE STRING "Supported C++ standard (14 or 17)")
if (CI_BUILD OR CI_TEST)
set(NANO_SUPPORTED_CPP_STANDARD "14")
endif()
set(CMAKE_CXX_STANDARD ${NANO_SUPPORTED_CPP_STANDARD})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
2 changes: 1 addition & 1 deletion ci/actions/linux/deploy-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [ -n "$DOCKER_PASSWORD" ]; then
if [[ "$GITHUB_WORKFLOW" = "Develop" ]]; then
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:base"
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:gcc"
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:clang"
"$scripts"/custom-timeout.sh 30 docker push "nanocurrency/nano-env:clang-6"
echo "Deployed nano-env"
exit 0
else
Expand Down
2 changes: 1 addition & 1 deletion ci/actions/linux/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ sudo mkdir -p /etc/docker && echo '{"ipv6":true,"fixed-cidr-v6":"2001:db8:1::/64

ci/build-docker-image.sh docker/ci/Dockerfile-base nanocurrency/nano-env:base
ci/build-docker-image.sh docker/ci/Dockerfile-gcc nanocurrency/nano-env:gcc
ci/build-docker-image.sh docker/ci/Dockerfile-clang nanocurrency/nano-env:clang
ci/build-docker-image.sh docker/ci/Dockerfile-clang-6 nanocurrency/nano-env:clang-6
4 changes: 2 additions & 2 deletions ci/build-centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ run_source() {
run_build() {
mkdir -p ~/rpmbuild/SOURCES/
mv -f ~/nano-${VERSIONS}.tar.gz ~/rpmbuild/SOURCES/.
scl enable llvm-toolset-7 devtoolset-7 'rpmbuild -ba nanocurrency.spec'
scl enable llvm-toolset-7 devtoolset-7 'rpmbuild -ba nanocurrency-beta.spec'
scl enable devtoolset-7 'rpmbuild -ba nanocurrency.spec'
scl enable devtoolset-7 'rpmbuild -ba nanocurrency-beta.spec'
}

run_update() {
Expand Down
2 changes: 2 additions & 0 deletions docker/ci/Dockerfile-clang-6
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM nanocurrency/nano-env:base
# need https for llvm
RUN apt-get update && apt-get install apt-transport-https ca-certificates -yqq

RUN apt-get update && apt-get install -yqq software-properties-common && \
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
Expand Down
6 changes: 5 additions & 1 deletion nano/core_test/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ TEST (node, block_store_path_failure)
ASSERT_TRUE (node->wallets.items.empty ());
node->stop ();
}

#if defined(__clang__) && defined(__linux__) && CI
// Disable test due to instability with clang and actions
TEST (node_DeathTest, DISABLED_readonly_block_store_not_exist)
#else
TEST (node_DeathTest, readonly_block_store_not_exist)
#endif
{
// For ASSERT_DEATH_IF_SUPPORTED
testing::FLAGS_gtest_death_test_style = "threadsafe";
Expand Down
6 changes: 4 additions & 2 deletions nanocurrency-beta.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ the nano daemon, and a service.
%prep
if [ ! -x "$(which cmake)" ]; then
echo "cmake must exist, try:" >&2
echo " scl enable llvm-toolset-7 devtoolset-7 'rpmbuild ...'" >&2
echo " scl enable devtoolset-7 'rpmbuild ...'" >&2
exit 1
fi
if cc --std=c++14 --version 2>&1 >/dev/null | grep '^' >/dev/null; then
echo "Unsupported C++ compiler, try:" >&2
echo " scl enable llvm-toolset-7 devtoolset-7 'rpmbuild ...'" >&2
echo " scl enable devtoolset-7 'rpmbuild ...'" >&2
exit 1
fi
if test ! -d /usr/local/boost; then
Expand All @@ -34,6 +34,7 @@ fi
%build
cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBOOST_ROOT=/usr/local/boost -DACTIVE_NETWORK=nano_beta_network .
make nano_node %{?_smp_mflags}
make nano_rpc %{?_smp_mflags}

%install
if [ ! %{buildroot} = "/" ]; then %{__rm} -rf %{buildroot}; fi
Expand All @@ -49,6 +50,7 @@ if [ ! %{buildroot} = "/" ]; then %{__rm} -rf %{buildroot}; fi
%files
%defattr(755,root,root)
%{_bindir}/nano_node-beta
%{_bindir}/nano_rpc-beta
%attr(644,root,root) /etc/systemd/system/nanocurrency-beta.service

%pre
Expand Down
6 changes: 4 additions & 2 deletions nanocurrency.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ the nano daemon, and a service.
%prep
if [ ! -x "$(which cmake)" ]; then
echo "cmake must exist, try:" >&2
echo " scl enable llvm-toolset-7 devtoolset-7 'rpmbuild ...'" >&2
echo " scl enable devtoolset-7 'rpmbuild ...'" >&2
exit 1
fi
if cc --std=c++14 --version 2>&1 >/dev/null | grep '^' >/dev/null; then
echo "Unsupported C++ compiler, try:" >&2
echo " scl enable llvm-toolset-7 devtoolset-7 'rpmbuild ...'" >&2
echo " scl enable devtoolset-7 'rpmbuild ...'" >&2
exit 1
fi
if test ! -d /usr/local/boost; then
Expand All @@ -34,6 +34,7 @@ fi
%build
cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBOOST_ROOT=/usr/local/boost .
make nano_node %{?_smp_mflags}
make nano_rpc %{?_smp_mflags}

%install
if [ ! %{buildroot} = "/" ]; then %{__rm} -rf %{buildroot}; fi
Expand All @@ -49,6 +50,7 @@ if [ ! %{buildroot} = "/" ]; then %{__rm} -rf %{buildroot}; fi
%files
%defattr(755,root,root)
%{_bindir}/nano_node
%{_bindir}/nano_rpc
%attr(644,root,root) /etc/systemd/system/nanocurrency.service

%pre
Expand Down
13 changes: 10 additions & 3 deletions util/build_prep/centos/prep.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ yes | yum install -y jq || exit 1
yes | yum install -y rpm-build || exit 1
yes | yum install -y glibc-devel glibc-headers make which libstdc++-static || exit 1
yes | yum install -y centos-release-scl || exit 1
yes | yum install -y llvm-toolset-7-cmake devtoolset-7-llvm|| exit 1
yes | yum install -y devtoolset-7-gcc-c++|| exit 1

wget -O cmake_install.sh https://github.com/Kitware/CMake/releases/download/v3.15.4/cmake-3.15.4-Linux-x86_64.sh
chmod +x cmake_install.sh
./cmake_install.sh --prefix=/usr --exclude-subdir --skip-license

rm -f ./cmake_install.sh


# Ensure we have a new enough Boost
(
eval "$(scl enable llvm-toolset-7 devtoolset-7 "bash -c 'set | grep ^PATH='")"
eval "$(scl enable devtoolset-7 "bash -c 'set | grep ^PATH='")"
if ! have boost; then
bootstrap_boost -m
bootstrap_boost -m -s
fi

if ! have boost; then
Expand Down
2 changes: 1 addition & 1 deletion util/build_prep/macosx/prep.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if ! have boost; then
BOOST_ROOT="${KEEP_AROUND_DIRECTORY}/boost"

if ! have boost; then
bootstrap_boost -m -c -k
bootstrap_boost -m -c -s
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion util/build_prep/ubuntu/prep.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ apt autoremove --yes

# Ensure we have a new enough Boost
if ! have boost; then
bootstrap_boost -m -k
bootstrap_boost -m -s
fi

if ! have boost; then
Expand Down

0 comments on commit 49cb67f

Please sign in to comment.