Skip to content

Commit 96c8f38

Browse files
authored
Merge pull request #15751 from ethereum/cpp20
Switch from c++17 to c++20 and reactivate fully static builds
2 parents ea6c4d6 + e4b82f9 commit 96c8f38

28 files changed

+143
-198
lines changed

.circleci/config.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,10 +1073,10 @@ jobs:
10731073
# to avoid glibc incompatibilities.
10741074
# See: https://github.com/ethereum/solidity/issues/13954
10751075
# On large runs 2x faster than on medium. 3x on xlarge.
1076-
<<: *base_ubuntu2004_xlarge
1076+
<<: *base_ubuntu2404_xlarge
10771077
environment:
1078-
<<: *base_ubuntu2004_xlarge_env
1079-
CMAKE_OPTIONS: -DCMAKE_BUILD_TYPE=Release -DSOLC_STATIC_STDLIBS=ON
1078+
<<: *base_ubuntu2404_xlarge_env
1079+
CMAKE_OPTIONS: -DCMAKE_BUILD_TYPE=Release -DSOLC_LINK_STATIC=ON
10801080
steps:
10811081
- checkout
10821082
- run_build
@@ -1093,21 +1093,6 @@ jobs:
10931093
- solc/solc-static-linux
10941094
- matrix_notify_failure_unless_pr
10951095

1096-
# Builds in C++20 mode and uses debug build in order to speed up.
1097-
# Do *NOT* store any artifacts or workspace as we don't run tests on this build.
1098-
b_ubu_cxx20:
1099-
<<: *base_ubuntu2404_large
1100-
environment:
1101-
<<: *base_ubuntu2404_large_env
1102-
CMAKE_BUILD_TYPE: Debug
1103-
# gold is more memory-efficient than the default, allows us to stay with the "large" resource class without OOM errors
1104-
CMAKE_OPTIONS: -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_FLAGS=-fuse-ld=gold
1105-
MAKEFLAGS: -j 6
1106-
steps:
1107-
- checkout
1108-
- run_build
1109-
- matrix_notify_failure_unless_pr
1110-
11111096
b_ubu_2204:
11121097
<<: *base_ubuntu2204_large
11131098
steps:
@@ -1873,7 +1858,6 @@ workflows:
18731858

18741859
# build-only
18751860
- b_docs: *requires_nothing
1876-
- b_ubu_cxx20: *requires_nothing
18771861
- b_ubu_ossfuzz: *requires_nothing
18781862
- b_ubu_2204: *requires_nothing
18791863
- b_ubu_2204_clang: *requires_nothing

.github/workflows/buildpack-deps.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
paths:
77
- 'scripts/docker/buildpack-deps/Dockerfile.emscripten'
88
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu.clang.ossfuzz'
9-
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2004'
109
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2204'
1110
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2404'
1211
- 'scripts/docker/buildpack-deps/Dockerfile.ubuntu2404.clang'

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Bugfixes:
1919
* Yul: Fix internal compiler error when a code generation error should be reported instead.
2020

2121

22+
Build system:
23+
* Linux release builds are fully static again and no longer depend on ``glibc``.
24+
* Switch from C++17 to C++20 as the target standard.
25+
2226
### 0.8.28 (2024-10-09)
2327

2428
Language Features:

ReleaseChecklist.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ At least a day before the release:
9494
**SERIOUSLY: DO NOT PROCEED EARLIER!!!**
9595
- [ ] *After* the package with the static build is *published*, use it to create packages for older Ubuntu versions.
9696
Copy the static package to the [``~ethereum/ethereum`` PPA](https://launchpad.net/~ethereum/+archive/ubuntu/ethereum)
97-
for the destination series ``Trusty``, ``Xenial`` and ``Bionic`` while selecting ``Copy existing binaries``.
97+
for the destination series ``Trusty``, ``Xenial``, ``Bionic``, and ``Focal``
98+
while selecting ``Copy existing binaries``.
9899

99100
### Release solc-js
100101
- [ ] Wait until solc-bin was properly deployed. You can test this via remix - a test run through remix is advisable anyway.

cmake/EthCompilerSettings.cmake

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,29 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
8989

9090
# Additional GCC-specific compiler settings.
9191
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
92-
# Check that we've got GCC 8.0 or newer.
93-
if (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0))
94-
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 8.0 or greater.")
92+
# Check that we've got GCC 11.0 or newer.
93+
if (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0))
94+
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 11.0 or greater.")
95+
endif ()
96+
97+
# GCC 12 emits warnings for string concatenations with operator+ under O3
98+
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105651
99+
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0)
100+
add_compile_options(-Wno-error=restrict)
95101
endif ()
96102

97103
# Use fancy colors in the compiler diagnostics
98104
add_compile_options(-fdiagnostics-color)
99105

100106
# Additional Clang-specific compiler settings.
101107
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
102-
# Check that we've got clang 7.0 or newer.
103-
if (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0))
104-
message(FATAL_ERROR "${PROJECT_NAME} requires clang++ 7.0 or greater.")
108+
# Check that we've got clang 14.0 or newer.
109+
if (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0))
110+
message(FATAL_ERROR "${PROJECT_NAME} requires clang++ 14.0 or greater.")
105111
endif ()
106112

113+
# use std::invoke_result, superseding std::result_of which has been removed in c++20
114+
add_compile_definitions(BOOST_ASIO_HAS_STD_INVOKE_RESULT)
107115
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
108116
# Set stack size to 32MB - by default Apple's clang defines a stack size of 8MB.
109117
# Normally 16MB is enough to run all tests, but it will exceed the stack, if -DSANITIZE=address is used.

cmake/EthToolchains.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Require C++17.
1+
# Require C++20.
22
if (NOT DEFINED CMAKE_CXX_STANDARD)
3-
set(CMAKE_CXX_STANDARD 17) # This requires at least CMake 3.8 to accept this C++17 flag.
3+
set(CMAKE_CXX_STANDARD 20) # This requires at least CMake 3.12 to accept this C++20 flag.
44
endif ()
55
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
66
set(CMAKE_CXX_EXTENSIONS OFF)

docs/installing-solidity.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ Minimum Compiler Versions
372372

373373
The following C++ compilers and their minimum versions can build the Solidity codebase:
374374

375-
- `GCC <https://gcc.gnu.org>`_, version 8+
376-
- `Clang <https://clang.llvm.org/>`_, version 7+
375+
- `GCC <https://gcc.gnu.org>`_, version 11+
376+
- `Clang <https://clang.llvm.org/>`_, version 14+
377377
- `MSVC <https://visualstudio.microsoft.com/vs/>`_, version 2019+
378378

379379
Prerequisites - macOS

libevmasm/ConstantOptimiser.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ bigint LiteralMethod::gasNeeded() const
140140
);
141141
}
142142

143+
AssemblyItems LiteralMethod::execute(Assembly&) const
144+
{
145+
return {};
146+
}
147+
143148
bigint CodeCopyMethod::gasNeeded() const
144149
{
145150
return combineGas(
@@ -226,6 +231,23 @@ AssemblyItems CodeCopyMethod::copyRoutine(AssemblyItem* _pushData) const
226231
}
227232
}
228233

234+
ComputeMethod::ComputeMethod(Params const& _params, u256 const& _value):
235+
ConstantOptimisationMethod(_params, _value)
236+
{
237+
m_routine = findRepresentation(m_value);
238+
assertThrow(
239+
checkRepresentation(m_value, m_routine),
240+
OptimizerException,
241+
"Invalid constant expression created."
242+
);
243+
}
244+
ComputeMethod::~ComputeMethod() = default;
245+
246+
AssemblyItems ComputeMethod::execute(Assembly&) const
247+
{
248+
return m_routine;
249+
}
250+
229251
AssemblyItems ComputeMethod::findRepresentation(u256 const& _value)
230252
{
231253
if (_value < 0x10000)

libevmasm/ConstantOptimiser.h

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class LiteralMethod: public ConstantOptimisationMethod
108108
explicit LiteralMethod(Params const& _params, u256 const& _value):
109109
ConstantOptimisationMethod(_params, _value) {}
110110
bigint gasNeeded() const override;
111-
AssemblyItems execute(Assembly&) const override { return AssemblyItems{}; }
111+
AssemblyItems execute(Assembly&) const override;
112112
};
113113

114114
/**
@@ -132,22 +132,11 @@ class CodeCopyMethod: public ConstantOptimisationMethod
132132
class ComputeMethod: public ConstantOptimisationMethod
133133
{
134134
public:
135-
explicit ComputeMethod(Params const& _params, u256 const& _value):
136-
ConstantOptimisationMethod(_params, _value)
137-
{
138-
m_routine = findRepresentation(m_value);
139-
assertThrow(
140-
checkRepresentation(m_value, m_routine),
141-
OptimizerException,
142-
"Invalid constant expression created."
143-
);
144-
}
135+
ComputeMethod(Params const& _params, u256 const& _value);
136+
~ComputeMethod() override;
145137

146138
bigint gasNeeded() const override { return gasNeeded(m_routine); }
147-
AssemblyItems execute(Assembly&) const override
148-
{
149-
return m_routine;
150-
}
139+
AssemblyItems execute(Assembly&) const override;
151140

152141
protected:
153142
/// Tries to recursively find a way to compute @a _value.

libevmasm/PeepholeOptimiser.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,12 @@ size_t numberOfPops(AssemblyItems const& _items)
709709

710710
}
711711

712+
PeepholeOptimiser::PeepholeOptimiser(AssemblyItems& _items, langutil::EVMVersion const _evmVersion):
713+
m_items(_items),
714+
m_evmVersion(_evmVersion)
715+
{
716+
}
717+
712718
bool PeepholeOptimiser::optimise()
713719
{
714720
// Avoid referencing immutables too early by using approx. counting in bytesRequired()

0 commit comments

Comments
 (0)