Skip to content

Commit cbc60d1

Browse files
committed
Update from C++17 to C++20
1 parent f1a1496 commit cbc60d1

File tree

6 files changed

+18
-48
lines changed

6 files changed

+18
-48
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -421,40 +421,6 @@ jobs:
421421
with:
422422
gcov: true
423423

424-
# Duplicates build-asan. Please keep in sync
425-
build-cxx20:
426-
name: c++20
427-
# Make sure we can still build on older Ubuntu
428-
runs-on: ubuntu-22.04
429-
env:
430-
CC: "gcc"
431-
CXX: "g++"
432-
steps:
433-
- uses: actions/setup-python@v5
434-
with:
435-
python-version: '3.x'
436-
- uses: actions/checkout@v4
437-
with:
438-
submodules: true
439-
- name: install ninja
440-
run: sudo apt-get install ninja-build
441-
- name: install v8
442-
run: |
443-
npm install jsvu -g
444-
jsvu --os=default --engines=v8
445-
- name: install Python dev dependencies
446-
run: pip3 install -r requirements-dev.txt
447-
- name: cmake
448-
run: |
449-
mkdir -p out
450-
cmake -S . -B out -G Ninja -DCMAKE_INSTALL_PREFIX=out/install -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20
451-
- name: build
452-
run: cmake --build out
453-
- name: test
454-
run: |
455-
python check.py --binaryen-bin=out/bin lit
456-
python check.py --binaryen-bin=out/bin gtest
457-
458424
# Ensures we can build in no-asserts mode (just building).
459425
build-noasserts:
460426
name: noasserts

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ full changeset diff at the end of each section.
1414

1515
Current Trunk
1616
-------------
17-
- The c api now has separate functions for `CallRef` and `ReturnCallRef` matching the semantics of `Call` and `ReturnCall`.
17+
- The c api now has separate functions for `CallRef` and `ReturnCallRef`
18+
matching the semantics of `Call` and `ReturnCall`.
19+
- Binaryen now uses C++20, therefore requires a C++20 compliant compiler.
1820

1921
v125
2022
----

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include(GNUInstallDirs)
1313
# The C++ standard whose features are required to build Binaryen.
1414
# Keep in sync with scripts/test/shared.py cxx_standard
1515
# The if condition allows embedding in a project with a higher default C++ standard set
16-
set(REQUIRED_CXX_STANDARD 17)
16+
set(REQUIRED_CXX_STANDARD 20)
1717
if(NOT CMAKE_CXX_STANDARD)
1818
set(CMAKE_CXX_STANDARD ${REQUIRED_CXX_STANDARD})
1919
elseif(CMAKE_CXX_STANDARD LESS ${REQUIRED_CXX_STANDARD})

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,9 @@ After that you can build with CMake:
412412
cmake . && make
413413
```
414414

415-
A C++17 compiler is required. On macOS, you need to install `cmake`, for example, via `brew install cmake`. Note that you can also use `ninja` as your generator: `cmake -G Ninja . && ninja`.
415+
A C++20 compiler is required. On macOS, you need to install `cmake`, for
416+
example, via `brew install cmake`. Note that you can also use `ninja` as your
417+
generator: `cmake -G Ninja . && ninja`.
416418

417419
To avoid the gtest dependency, you can pass `-DBUILD_TESTS=OFF` to cmake.
418420

scripts/test/shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
# The C++ standard whose features are required to build Binaryen.
2828
# Keep in sync with CMakeLists.txt CXX_STANDARD
29-
cxx_standard = 17
29+
cxx_standard = 20
3030

3131

3232
def parse_args(args):

src/ir/module-splitting.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,9 @@ void ModuleSplitter::classifyFunctions() {
457457
// module since that would make them async when they may not have the JSPI
458458
// wrapper. Exported JSPI functions can still benefit from splitting though
459459
// since only the JSPI wrapper stub will remain in the primary module.
460-
if (func->imported() || !configSecondaryFuncs.count(func->name) ||
460+
if (func->imported() || !configSecondaryFuncs.contains(func->name) ||
461461
(config.jspi && ExportUtils::isExported(primary, *func)) ||
462-
segmentReferrers.count(func->name)) {
462+
segmentReferrers.contains(func->name)) {
463463
primaryFuncs.insert(func->name);
464464
} else {
465465
assert(func->name != primary.start && "The start function must be kept");
@@ -520,7 +520,7 @@ void ModuleSplitter::moveSecondaryFunctions() {
520520
for (auto& funcNames : config.secondaryFuncs) {
521521
auto secondary = initSecondary(primary);
522522
for (auto funcName : funcNames) {
523-
if (allSecondaryFuncs.count(funcName)) {
523+
if (allSecondaryFuncs.contains(funcName)) {
524524
auto* func = primary.getFunction(funcName);
525525
ModuleUtils::copyFunction(func, *secondary);
526526
primary.removeFunction(funcName);
@@ -567,7 +567,7 @@ void ModuleSplitter::thunkExportedSecondaryFunctions() {
567567
Builder builder(primary);
568568
for (auto& ex : primary.exports) {
569569
if (ex->kind != ExternalKind::Function ||
570-
!allSecondaryFuncs.count(*ex->getInternalName())) {
570+
!allSecondaryFuncs.contains(*ex->getInternalName())) {
571571
continue;
572572
}
573573
Name trampoline = getTrampoline(*ex->getInternalName());
@@ -609,7 +609,7 @@ void ModuleSplitter::indirectReferencesToSecondaryFunctions() {
609609
// 1. ref.func's target func is in one of the secondary modules and
610610
// 2. the current module is a different module (either the primary module
611611
// or a different secondary module)
612-
if (parent.allSecondaryFuncs.count(curr->func) &&
612+
if (parent.allSecondaryFuncs.contains(curr->func) &&
613613
(currModule == &parent.primary ||
614614
parent.secondaries.at(parent.funcToSecondaryIndex.at(curr->func))
615615
.get() != currModule)) {
@@ -645,7 +645,7 @@ void ModuleSplitter::indirectReferencesToSecondaryFunctions() {
645645
std::vector<RefFunc*> relevantRefFuncs;
646646
for (auto* refFunc : refFuncs) {
647647
assert(refFunc->func == name);
648-
if (!ignore.count(refFunc)) {
648+
if (!ignore.contains(refFunc)) {
649649
relevantRefFuncs.push_back(refFunc);
650650
}
651651
}
@@ -669,7 +669,7 @@ void ModuleSplitter::indirectCallsToSecondaryFunctions() {
669669
CallIndirector(ModuleSplitter& parent) : parent(parent) {}
670670
void visitCall(Call* curr) {
671671
// Return if the call's target is not in one of the secondary module.
672-
if (!parent.allSecondaryFuncs.count(curr->target)) {
672+
if (!parent.allSecondaryFuncs.contains(curr->target)) {
673673
return;
674674
}
675675
// Return if the current module is the same module as the call's target,
@@ -719,12 +719,12 @@ void ModuleSplitter::exportImportCalledPrimaryFunctions() {
719719
: primaryFuncs(primaryFuncs),
720720
calledPrimaryToModules(calledPrimaryToModules) {}
721721
void visitCall(Call* curr) {
722-
if (primaryFuncs.count(curr->target)) {
722+
if (primaryFuncs.contains(curr->target)) {
723723
calledPrimaryToModules[curr->target].insert(getModule());
724724
}
725725
}
726726
void visitRefFunc(RefFunc* curr) {
727-
if (primaryFuncs.count(curr->func)) {
727+
if (primaryFuncs.contains(curr->func)) {
728728
calledPrimaryToModules[curr->func].insert(getModule());
729729
}
730730
}
@@ -760,7 +760,7 @@ void ModuleSplitter::setupTablePatching() {
760760
if (!ref) {
761761
return;
762762
}
763-
if (!allSecondaryFuncs.count(ref->func)) {
763+
if (!allSecondaryFuncs.contains(ref->func)) {
764764
return;
765765
}
766766
assert(table == tableManager.activeTable->name);

0 commit comments

Comments
 (0)