Skip to content

Commit

Permalink
Merge pull request #195 from ethereum/gcc4
Browse files Browse the repository at this point in the history
Test minimal supported compilers
  • Loading branch information
chfast authored Mar 11, 2019
2 parents b416176 + 35bf88d commit fb820fc
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 32 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

if(EVMC_TESTING)
set(HUNTER_CONFIGURATION_TYPES Release CACHE STRING "Build type of Hunter packages")
include(HunterGate)
include(HunterConfig)
include(defaults/HunterCacheServers)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Please visit the [documentation].

### Languages support

| Language | Supported Versions |
| ----------------------- | ------------------- |
| **C** | C90, C99, C11 |
| **C++** _(helpers)_[^1] | C++11, C++14, C++17 |
| Language | Supported Versions | Supported Compilers
| ----------------------- | ------------------- | -------------------
| **C** | C90, C99, C11 | GCC 6+, clang 3.8+
| **C++** _(helpers)_[^1] | C++11, C++14, C++17 | GCC 6+, clang 3.8+
| **Go** _(bindings)_ | 1.9, 1.10, 1.11 |

[^1]: C++ support is provided by C headers and some optional C++ helpers.
Expand Down
46 changes: 35 additions & 11 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ jobs:

lint:
docker:
- image: ethereum/cpp-build-env:7
- image: ethereum/cpp-build-env:10
steps:
- checkout
- run:
name: "Check code format"
command: |
clang-format --version
find examples include lib test -name '*.hpp' -o -name '*.cpp' -o -name '*.h' -o -name '*.c' | xargs clang-format -i
git diff --color --exit-code
- run:
Expand All @@ -18,11 +19,21 @@ jobs:
sudo pip3 install codespell
codespell --quiet-level=4 --ignore-words=./.codespell-whitelist
build-cxx11: &build
build: &build
docker:
- image: ethereum/cpp-build-env:7
- image: ethereum/cpp-build-env:10
steps:
- checkout
- run:
name: "Environment"
command: |
CC=${CC:-cc}
CXX=${CXX:-cpp}
echo CC: $CC
echo CXX: $CXX
$CC --version
$CXX --version
cmake --version
- run:
name: "Configure"
working_directory: ~/build
Expand Down Expand Up @@ -63,23 +74,35 @@ jobs:
name: "Run evmc-vmtester libevmc-example-vm.so"
command: ~/install/bin/evmc-vmtester ~/install/lib/libevmc-example-vm.so

build-cxx17:
<<: *build
environment:
CC: gcc-8
CXX: g++-8
CMAKE_OPTIONS: -DTOOLCHAIN=cxx17-pic

build-cxx14:
<<: *build
environment:
CC: clang-3.8
CXX: clang++-3.8
CC: clang-8
CXX: clang++-8
CMAKE_OPTIONS: -DTOOLCHAIN=cxx14-pic

build-cxx17:
build-gcc6:
<<: *build
environment:
CC: gcc-6
CXX: g++-6
CMAKE_OPTIONS: -DTOOLCHAIN=cxx17-pic

build-clang3.8:
<<: *build
environment:
CC: clang-3.8
CXX: clang++-3.8

test-docs:
docker:
- image: ethereum/cpp-build-env
- image: ethereum/cpp-build-env:10
steps:
- checkout
- run:
Expand All @@ -98,7 +121,7 @@ jobs:

upload-docs:
docker:
- image: ethereum/cpp-build-env
- image: ethereum/cpp-build-env:10
steps:
- checkout
- run:
Expand Down Expand Up @@ -141,9 +164,10 @@ workflows:
evmc:
jobs:
- lint
- build-cxx11
- build-cxx14
- build-cxx17
- build-cxx14
- build-gcc6
- build-clang3.8
- bindings-go-1.11
- bindings-go-1.10
- bindings-go-1.9
Expand Down
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# EVMC: Ethereum Client-VM Connector API.
# Copyright 2018 The EVMC Authors.
# Copyright 2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0. See the LICENSE file.

hunter_add_package(GTest)
Expand All @@ -8,6 +8,7 @@ find_package(GTest CONFIG REQUIRED)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_EXTENSIONS OFF)
endif()

add_subdirectory(integration)
Expand Down
30 changes: 17 additions & 13 deletions test/integration/compilation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,32 @@
# This CMake script creates multiple additional targets to test the compilation of public headers
# with different C and C++ standards.

set(standards c_std_90;c_std_99;c_std_11;cxx_std_11;cxx_std_14)
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL Clang OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.8.1)
list(APPEND standards cxx_std_17)
endif()

list(APPEND all_features ${CMAKE_CXX_COMPILE_FEATURES})
list(APPEND all_features ${CMAKE_C_COMPILE_FEATURES})

macro(create_compilation_test STANDARD)
if (${STANDARD} MATCHES "^(C|CXX)([0-9]+)$")
if (${STANDARD} MATCHES "^(c|cxx)_std_([0-9]+)$")
set(lang ${CMAKE_MATCH_1})
set(num ${CMAKE_MATCH_2})
else()
message(FATAL_ERROR "Unknown language standard: ${STANDARD}")
message(FATAL_ERROR "Unknown standard: ${STANDARD}")
endif()

if (lang STREQUAL CXX)
set(ext cpp)
if(${STANDARD} IN_LIST all_features)
set(target test-compile-${STANDARD})
add_library(${target} OBJECT compilation_test.${lang})
target_compile_features(${target} PRIVATE ${STANDARD})
target_include_directories(${target} PRIVATE ${include_dir})
else()
set(ext c)
message(STATUS "Compilation test SKIPPED: ${STANDARD}")
endif()

string(TOLOWER ${STANDARD} standard)
set(target test-compile-${standard})

add_library(${target} OBJECT compilation_test.${ext})
target_include_directories(${target} PRIVATE ${include_dir})
set_target_properties(${target} PROPERTIES ${lang}_STANDARD ${num} ${lang}_EXTENSIONS OFF)
endmacro()

foreach(standard C90;C99;C11;CXX11;CXX14;CXX17)
foreach(standard ${standards})
create_compilation_test(${standard})
endforeach()
6 changes: 3 additions & 3 deletions test/vmtester/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ TEST_F(evmc_vm_test, version)

TEST_F(evmc_vm_test, set_tracer)
{
static const auto tracer_callback = [](evmc_tracer_context*, size_t, evmc_status_code, int64_t,
size_t, const evmc_uint256be*, size_t, size_t, size_t,
const uint8_t*) noexcept {};
static const auto tracer_callback =
[](evmc_tracer_context*, size_t, evmc_status_code, int64_t, size_t, const evmc_uint256be*,
size_t, size_t, size_t, const uint8_t*) noexcept {};
if (vm->set_tracer)
vm->set_tracer(vm, tracer_callback, nullptr);
}
Expand Down

0 comments on commit fb820fc

Please sign in to comment.