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

c++17 and compiler pinning #7107

Merged
merged 93 commits into from
Apr 25, 2019
Merged

c++17 and compiler pinning #7107

merged 93 commits into from
Apr 25, 2019

Conversation

larryk85
Copy link
Contributor

Change Description

Update libraries and CMake to build with C++ 17 instead of C++ 14. And pin all noninteractive builds (buildkite builds) to use clang 8.

Consensus Changes

  • Consensus Changes

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@larryk85 larryk85 mentioned this pull request Apr 10, 2019
@larryk85 larryk85 requested a review from spoonincode April 10, 2019 21:40
Copy link
Contributor

@spoonincode spoonincode left a comment

Choose a reason for hiding this comment

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

And pin all noninteractive builds (buildkite builds) to use clang 8.

Should this be a separate option?

-DCMAKE_C_COMPILER="${C_COMPILER}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL_NAME}" \
-DOPENSSL_ROOT_DIR="${OPENSSL_ROOT_DIR}" -DBUILD_MONGO_DB_PLUGIN=true \
-DENABLE_COVERAGE_TESTING="${ENABLE_COVERAGE_TESTING}" -DBUILD_DOXYGEN="${DOXYGEN}" \
$CMAKE -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_CXX_COMPILER="${CXX}" -DOPENSSL_ROOT_DIR="${OPENSSL_ROOT_DIR}" -DBUILD_MONGO_DB_PLUGIN=false \
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I can tell this won't actually use llvm's libc++, for example:

opt/clang8/bin/clang++ -std=c++17 string_view.cpp -o string_view -v
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8
 /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
 /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
 /usr/local/include
 /home/ubuntu/opt/clang8/lib/clang/8.0.1/include
 /usr/include/x86_64-linux-gnu
 /usr/include

so we only get the system lib's string_view. Also the linkage is to the system's libc++, i.e.

$ ldd string_view
        linux-vdso.so.1 =>  (0x00007fff2a3e5000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd0ec3e1000)

If we're going to pin the compiler, don't we want the stdc++ lib to be part of that pin?

@@ -25,7 +25,7 @@ include( InstallDirectoryPermissions )
include( MASSigning )

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

Choose a reason for hiding this comment

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

Also need to change the compiler check that's a few lines down from here

@@ -248,6 +248,39 @@ if [ $? -ne 0 ]; then exit -1; fi
cd ..
printf "\\n"

if [ $BUILD_CLANG8 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this check is true no matter BUILD_CLANG8 contains true or false

printf "#include <iostream>\nint main(){ std::cout << \"Hello, World!\" << std::endl; }" &> $TEMP_DIR/test.cpp
`c++ -c -std=c++17 $TEMP_DIR/test.cpp -o $TEMP_DIR/test.o &> /dev/null`
if [ $? -ne 0 ]; then
`CXX -c -std=c++17 $TEMP_DIR/test.cpp -o $TEMP_DIR/test.o &> /dev/null`
Copy link
Contributor

Choose a reason for hiding this comment

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

was this supposed to be $CXX instead of CXX?

@@ -179,6 +181,31 @@ if [ $STALE_SUBMODS -gt 0 ]; then
exit 1
fi

BUILD_CLANG8=false
if [ $NONINTERACTIVE -eq 0 ]; then
printf "#include <iostream>\nint main(){ std::cout << \"Hello, World!\" << std::endl; }" &> $TEMP_DIR/test.cpp
Copy link
Contributor

@spoonincode spoonincode Apr 11, 2019

Choose a reason for hiding this comment

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

This check won't work as is; even the gcc 5.5.0 on ubuntu 16.04 passes validation here (and then the build fails when the cmake 6.0 or greater check fails).

@@ -71,6 +71,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
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure this isn't a pin to a released version. The current compiler version I have after running the script is
clang version 8.0.1 (https://git.llvm.org/git/clang.git a03da8be08a208122e292016cb6cea1f30229677)

@spoonincode
Copy link
Contributor

I am unable to determine why building zlib is required. I made a branch where I removed that:
feature/cpp17_compiler_pinning...cpp17_remove_zlib

and the builds seemed to be fine:
https://buildkite.com/EOSIO/eosio/builds/11071

(mac build failed for something unrelated; I didn't change mac builds)

@larryk85
Copy link
Contributor Author

I am unable to determine why building zlib is required. I made a branch where I removed that:
feature/cpp17_compiler_pinning...cpp17_remove_zlib

and the builds seemed to be fine:
https://buildkite.com/EOSIO/eosio/builds/11071

(mac build failed for something unrelated; I didn't change mac builds)

That is fine, we can change it after we get this merged. I really don't want to keep tinkering with this right now. It builds fine currently, but it might be a little bit aggressive in terms of dependencies.

@larryk85 larryk85 changed the base branch from forced-replay to develop April 24, 2019 18:50
Copy link
Contributor

@spoonincode spoonincode left a comment

Choose a reason for hiding this comment

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

Looks like on macos we don't build our own llvm4 when pinned? Seems potentially dangerous going forward but probably not an issue for now

@larryk85
Copy link
Contributor Author

Looks like on macos we don't build our own llvm4 when pinned? Seems potentially dangerous going forward but probably not an issue for now

Shouldn't be dangerous, as the mac build by default is libcxx and we are statically linking libcxx so even though we don't build llvm4 I don't see it as an issue. Secondly, the plan is that llvm4 is a temporary dependency at this point. Either we replace WAVM or port it up to use llvm 8 which we are already building.

@arhag arhag merged commit e751f91 into develop Apr 25, 2019
@arhag arhag deleted the feature/cpp17_compiler_pinning branch April 25, 2019 17:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants