Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Update to C++ 17 #6896

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ include( InstallDirectoryPermissions )
include( MASSigning )

set( BLOCKCHAIN_NAME "EOSIO" )
set( CMAKE_CXX_STANDARD 14 )
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_EXTENSIONS ON )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth turning this off? Seems like it compiles okay with it off

set( CXX_STANDARD_REQUIRED ON)

Expand Down
2 changes: 1 addition & 1 deletion libraries/fc
5 changes: 3 additions & 2 deletions libraries/wasm-jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
set(WAVM_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/Include)
include_directories(${WAVM_INCLUDE_DIR})
#
# Use C++11
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
# Use C++11
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

# Compile with all warnings and fatal warnings
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
Expand All @@ -36,6 +36,7 @@ include_directories(${WAVM_INCLUDE_DIR})
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
# endif()

set(CMAKE_CXX_STANDARD 11)
option(WAVM_METRICS_OUTPUT "controls printing the timings of some operations to stdout" OFF)
if(WAVM_METRICS_OUTPUT)
add_definitions("-DWAVM_METRICS_OUTPUT=1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class se_wallet final : public wallet_api {
string create_key(string key_type) override;
bool remove_key(string key) override;

optional<signature_type> try_sign_digest(const digest_type digest, const public_key_type public_key) override;
fc::optional<signature_type> try_sign_digest(const digest_type digest, const public_key_type public_key) override;

private:
std::unique_ptr<detail::se_wallet_impl> my;
};

}}
}}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class soft_wallet final : public wallet_api

/* Attempts to sign a digest via the given public_key
*/
optional<signature_type> try_sign_digest( const digest_type digest, const public_key_type public_key ) override;
fc::optional<signature_type> try_sign_digest( const digest_type digest, const public_key_type public_key ) override;

std::shared_ptr<detail::soft_wallet_impl> my;
void encrypt_keys();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class wallet_api

/** Returns a signature given the digest and public_key, if this wallet can sign via that public key
*/
virtual optional<signature_type> try_sign_digest( const digest_type digest, const public_key_type public_key ) = 0;
virtual fc::optional<signature_type> try_sign_digest( const digest_type digest, const public_key_type public_key ) = 0;
};

}}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class yubihsm_wallet final : public wallet_api {
string create_key(string key_type) override;
bool remove_key(string key) override;

optional<signature_type> try_sign_digest(const digest_type digest, const public_key_type public_key) override;
fc::optional<signature_type> try_sign_digest(const digest_type digest, const public_key_type public_key) override;

private:
std::unique_ptr<detail::yubihsm_wallet_impl> my;
};

}}
}}
8 changes: 4 additions & 4 deletions plugins/wallet_plugin/se_wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ struct se_wallet_impl {
return pub;
}

optional<signature_type> try_sign_digest(const digest_type d, const public_key_type public_key) {
fc::optional<signature_type> try_sign_digest(const digest_type d, const public_key_type public_key) {
auto it = _keys.find(public_key);
if(it == _keys.end())
return optional<signature_type>{};
return fc::optional<signature_type>{};

fc::ecdsa_sig sig = ECDSA_SIG_new();
CFErrorRef error = nullptr;
Expand Down Expand Up @@ -370,8 +370,8 @@ bool se_wallet::remove_key(string key) {
return my->remove_key(key);
}

optional<signature_type> se_wallet::try_sign_digest(const digest_type digest, const public_key_type public_key) {
fc::optional<signature_type> se_wallet::try_sign_digest(const digest_type digest, const public_key_type public_key) {
return my->try_sign_digest(digest, public_key);
}

}}
}}
10 changes: 5 additions & 5 deletions plugins/wallet_plugin/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ class soft_wallet_impl

string get_wallet_filename() const { return _wallet_filename; }

optional<private_key_type> try_get_private_key(const public_key_type& id)const
fc::optional<private_key_type> try_get_private_key(const public_key_type& id)const
{
auto it = _keys.find(id);
if( it != _keys.end() )
return it->second;
return optional<private_key_type>();
return fc::optional<private_key_type>();
}

optional<signature_type> try_sign_digest( const digest_type digest, const public_key_type public_key ) {
fc::optional<signature_type> try_sign_digest( const digest_type digest, const public_key_type public_key ) {
auto it = _keys.find(public_key);
if( it == _keys.end() )
return optional<signature_type>{};
return fc::optional<signature_type>{};
return it->second.sign(digest);
}

Expand Down Expand Up @@ -401,7 +401,7 @@ private_key_type soft_wallet::get_private_key( public_key_type pubkey )const
return my->get_private_key( pubkey );
}

optional<signature_type> soft_wallet::try_sign_digest( const digest_type digest, const public_key_type public_key ) {
fc::optional<signature_type> soft_wallet::try_sign_digest( const digest_type digest, const public_key_type public_key ) {
return my->try_sign_digest(digest, public_key);
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/wallet_plugin/wallet_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ wallet_manager::sign_transaction(const chain::signed_transaction& txn, const fla
bool found = false;
for (const auto& i : wallets) {
if (!i.second->is_locked()) {
optional<signature_type> sig = i.second->try_sign_digest(stxn.sig_digest(id, stxn.context_free_data), pk);
fc::optional<signature_type> sig = i.second->try_sign_digest(stxn.sig_digest(id, stxn.context_free_data), pk);
if (sig) {
stxn.signatures.push_back(*sig);
found = true;
Expand All @@ -260,7 +260,7 @@ wallet_manager::sign_digest(const chain::digest_type& digest, const public_key_t
try {
for (const auto& i : wallets) {
if (!i.second->is_locked()) {
optional<signature_type> sig = i.second->try_sign_digest(digest, key);
fc::optional<signature_type> sig = i.second->try_sign_digest(digest, key);
if (sig)
return *sig;
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/wallet_plugin/yubihsm_wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ struct yubihsm_wallet_impl {
});
}

optional<signature_type> try_sign_digest(const digest_type d, const public_key_type public_key) {
fc::optional<signature_type> try_sign_digest(const digest_type d, const public_key_type public_key) {
auto it = _keys.find(public_key);
if(it == _keys.end())
return optional<signature_type>{};
return fc::optional<signature_type>{};

size_t der_sig_sz = 128;
uint8_t der_sig[der_sig_sz];
Expand Down Expand Up @@ -265,7 +265,7 @@ bool yubihsm_wallet::remove_key(string key) {
return true;
}

optional<signature_type> yubihsm_wallet::try_sign_digest(const digest_type digest, const public_key_type public_key) {
fc::optional<signature_type> yubihsm_wallet::try_sign_digest(const digest_type digest, const public_key_type public_key) {
return my->try_sign_digest(digest, public_key);
}

Expand Down
8 changes: 4 additions & 4 deletions programs/cleos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,14 @@ void print_action( const fc::variant& at ) {
}

//resolver for ABI serializer to decode actions in proposed transaction in multisig contract
auto abi_serializer_resolver = [](const name& account) -> optional<abi_serializer> {
static unordered_map<account_name, optional<abi_serializer> > abi_cache;
auto abi_serializer_resolver = [](const name& account) -> fc::optional<abi_serializer> {
static unordered_map<account_name, fc::optional<abi_serializer> > abi_cache;
auto it = abi_cache.find( account );
if ( it == abi_cache.end() ) {
auto result = call(get_abi_func, fc::mutable_variant_object("account_name", account));
auto abi_results = result.as<eosio::chain_apis::read_only::get_abi_results>();

optional<abi_serializer> abis;
fc::optional<abi_serializer> abis;
if( abi_results.abi.valid() ) {
abis.emplace( *abi_results.abi, abi_serializer_max_time );
} else {
Expand Down Expand Up @@ -480,7 +480,7 @@ void print_result( const fc::variant& result ) { try {
cerr << " us\n";

if( status == "failed" ) {
auto soft_except = processed["except"].as<optional<fc::exception>>();
auto soft_except = processed["except"].as<fc::optional<fc::exception>>();
if( soft_except ) {
edump((soft_except->to_detail_string()));
}
Expand Down
11 changes: 8 additions & 3 deletions scripts/eosio_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export BOOST_LINK_LOCATION=${OPT_LOCATION}/boost
export LLVM_VERSION=release_40
export LLVM_ROOT=${OPT_LOCATION}/llvm
export LLVM_DIR=${LLVM_ROOT}/lib/cmake/llvm
export CLANG8_ROOT=${OPT_LOCATION}/clang8
export PINNED_COMPILER_VERSION=release_80
export DOXYGEN_VERSION=1_8_14
export DOXYGEN_ROOT=${SRC_LOCATION}/doxygen-${DOXYGEN_VERSION}
export TINI_VERSION=0.18.0
Expand Down Expand Up @@ -236,8 +238,8 @@ if [ "$ARCH" == "Linux" ]; then
;;
"Ubuntu")
FILE="${REPO_ROOT}/scripts/eosio_build_ubuntu.sh"
CXX_COMPILER=clang++-4.0
C_COMPILER=clang-4.0
CXX_COMPILER=g++
C_COMPILER=gcc
;;
"Debian GNU/Linux")
FILE="${REPO_ROOT}/scripts/eosio_build_ubuntu.sh"
Expand Down Expand Up @@ -279,9 +281,12 @@ printf "## ENABLE_COVERAGE_TESTING=%s\\n" "${ENABLE_COVERAGE_TESTING}"
mkdir -p $BUILD_DIR
cd $BUILD_DIR

C_COMPILER=${CLANG8_ROOT}/bin/clang
CXX_COMPILER=${CLANG8_ROOT}/bin/clang++

$CMAKE -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" \
-DCMAKE_C_COMPILER="${C_COMPILER}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL_NAME}" \
-DOPENSSL_ROOT_DIR="${OPENSSL_ROOT_DIR}" -DBUILD_MONGO_DB_PLUGIN=true \
-DOPENSSL_ROOT_DIR="${OPENSSL_ROOT_DIR}" -DBUILD_MONGO_DB_PLUGIN=OFF \
-DENABLE_COVERAGE_TESTING="${ENABLE_COVERAGE_TESTING}" -DBUILD_DOXYGEN="${DOXYGEN}" \
-DCMAKE_INSTALL_PREFIX=$OPT_LOCATION/eosio $LOCAL_CMAKE_FLAGS "${REPO_ROOT}"
if [ $? -ne 0 ]; then exit -1; fi
Expand Down
48 changes: 38 additions & 10 deletions scripts/eosio_build_amazon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ DISK_AVAIL_KB=$( df . | tail -1 | awk '{print $4}' )
DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 ))
DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 ))

DEP_ARRAY=(sudo file git autoconf automake make libtool bzip2 bzip2-devel doxygen graphviz python python-devel python33 gettext-devel \
openssl-devel gmp-devel libicu-devel libcurl-devel wget which libusbx-devel)

if [[ "${OS_NAME}" == "Amazon Linux AMI" ]]; then
DEP_ARRAY=(
sudo procps util-linux which gcc72 gcc72-c++ autoconf automake libtool make doxygen graphviz \
bzip2 bzip2-devel openssl-devel gmp gmp-devel libstdc++72 python27 python27-devel python34 python34-devel \
libedit-devel ncurses-devel swig wget file libcurl-devel libusb1-devel
)
# add gmp maybe
DEP_ARRAY+=(procps util-linux which gcc72 gcc72-c++ libstdc++72 python27 python27-devel python34 python34-devel \
libedit-devel ncurses-devel swig libusb1-devel)
else
DEP_ARRAY=(
git procps-ng util-linux gcc gcc-c++ autoconf automake libtool make bzip2 \
bzip2-devel openssl-devel gmp-devel libstdc++ libcurl-devel libusbx-devel \
python3 python3-devel python-devel libedit-devel doxygen graphviz
)
DEP_ARRAY+=(procps-ng util-linux gcc gcc-c++ libstdc++ python3 python3-devel python-devel libusbx-devel compat-openssl10)
fi

COUNT=1
Expand Down Expand Up @@ -122,6 +119,7 @@ printf "\\n"
printf "Checking CMAKE installation...\\n"
if [ ! -e $CMAKE ]; then
printf "Installing CMAKE...\\n"
curl -LO https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-$CMAKE_VERSION-Linux-x86_64.tar.gz \
curl -LO https://cmake.org/files/v$CMAKE_VERSION_MAJOR.$CMAKE_VERSION_MINOR/cmake-$CMAKE_VERSION.tar.gz \
&& tar -xzf cmake-$CMAKE_VERSION.tar.gz \
&& cd cmake-$CMAKE_VERSION \
Expand Down Expand Up @@ -248,6 +246,36 @@ if [ $? -ne 0 ]; then exit -1; fi
cd ..
printf "\\n"

printf "Checking Clang 8 support...\\n"
if [ ! -d $CLANG8_ROOT ]; then
printf "Installing Clang 8...\\n"
cd ../opt \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/llvm.git llvm && cd llvm \
&& cd tools \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/lld.git \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/polly.git \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/clang.git clang cd clang/tools/extra \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/clang-tools-extra.git \
&& cd ../../../../projects \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/libcxx.git \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/libunwind.git \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/compiler-rt.git \
&& cd .. \
&& mkdir build \
&& cd build \
&& $CMAKE -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${CLANG8_ROOT}" -DLINK_POLLY_INTO_TOOLS=ON -DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_ENABLE_LIBCXX=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_INCLUDE_DOCS=OFF -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_TARGETS_TO_BUILD=all -DWITH_POLLY=ON -DLLVM_CREATE_XCODE_TOOLCHAIN=OFF .. \
&& make -j"${JOBS}" \
&& make install \
&& cd ../.. \
|| exit 1
printf " - Clang 8 successfully installed @ ${CLANG8_ROOT}\\n"
else
printf " - Clang 8 found @ ${CLANG8_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi

printf "\\n"

function print_instructions() {
return 0
}
68 changes: 50 additions & 18 deletions scripts/eosio_build_darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,25 @@ if [ ! -d $MONGO_C_DRIVER_ROOT ]; then
else
printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "Checking MongoDB C++ driver installation...\\n"
if [ "$(grep "Version:" $HOME/lib/pkgconfig/libmongocxx-static.pc 2>/dev/null | tr -s ' ' | awk '{print $2}')" != $MONGO_CXX_DRIVER_VERSION ]; then
printf "Installing MongoDB C++ driver...\\n"
curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
&& tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \
&& cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \
&& $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME .. \
&& make -j"${JOBS}" VERBOSE=1 \
&& make install \
&& cd ../.. \
&& rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
|| exit 1
printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
else
printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi

#if [ $? -ne 0 ]; then exit -1; fi
#printf "Checking MongoDB C++ driver installation...\\n"
#if [ "$(grep "Version:" $HOME/lib/pkgconfig/libmongocxx-static.pc 2>/dev/null | tr -s ' ' | awk '{print $2}')" != $MONGO_CXX_DRIVER_VERSION ]; then
# printf "Installing MongoDB C++ driver...\\n"
# curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
# && tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \
# && cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \
# && $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME .. \
# && make -j"${JOBS}" VERBOSE=1 \
# && make install \
# && cd ../.. \
# && rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
# || exit 1
# printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
#else
# printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
#fi
#if [ $? -ne 0 ]; then exit -1; fi

printf "\\n"

Expand All @@ -261,6 +262,37 @@ fi
cd ..
printf "\\n"

printf "Checking Clang 8 support...\\n"
if [ ! -d $CLANG8_ROOT ]; then
printf "Installing Clang 8...\\n"
cd $OPT_LOCATION \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/llvm.git clang8 && cd clang8 \
&& cd tools \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/lld.git \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/polly.git \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/clang.git clang && cd clang/tools \
&& mkdir extra && cd extra \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/clang-tools-extra.git \
&& cd ../../../../projects \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/libcxx.git \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/libunwind.git \
&& git clone --depth 1 --single-branch --branch $PINNED_COMPILER_VERSION https://git.llvm.org/git/compiler-rt.git \
&& cd .. \
&& mkdir build \
&& cd build \
&& $CMAKE -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${CLANG8_ROOT}" -DLINK_POLLY_INTO_TOOLS=ON -DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_ENABLE_LIBCXX=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_INCLUDE_DOCS=OFF -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_TARGETS_TO_BUILD=all -DWITH_POLLY=ON -DLLVM_CREATE_XCODE_TOOLCHAIN=ON .. \
&& make -j"${JOBS}" \
&& make install \
&& cd ../.. \
|| exit 1
printf " - Clang 8 successfully installed @ ${CLANG8_ROOT}\\n"
else
printf " - Clang 8 found @ ${CLANG8_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi

printf "\\n"

function print_instructions() {
return 0
}