diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7746f2e889a..1a1ee41cafc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -421,40 +421,6 @@ jobs: with: gcov: true - # Duplicates build-asan. Please keep in sync - build-cxx20: - name: c++20 - # Make sure we can still build on older Ubuntu - runs-on: ubuntu-22.04 - env: - CC: "gcc" - CXX: "g++" - steps: - - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - uses: actions/checkout@v4 - with: - submodules: true - - name: install ninja - run: sudo apt-get install ninja-build - - name: install v8 - run: | - npm install jsvu -g - jsvu --os=default --engines=v8 - - name: install Python dev dependencies - run: pip3 install -r requirements-dev.txt - - name: cmake - run: | - mkdir -p out - 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 - - name: build - run: cmake --build out - - name: test - run: | - python check.py --binaryen-bin=out/bin lit - python check.py --binaryen-bin=out/bin gtest - # Ensures we can build in no-asserts mode (just building). build-noasserts: name: noasserts diff --git a/CHANGELOG.md b/CHANGELOG.md index 11f61958d7f..0b1334ce0f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,9 @@ full changeset diff at the end of each section. Current Trunk ------------- -- The c api now has separate functions for `CallRef` and `ReturnCallRef` matching the semantics of `Call` and `ReturnCall`. +- The c api now has separate functions for `CallRef` and `ReturnCallRef` + matching the semantics of `Call` and `ReturnCall`. +- Binaryen now uses C++20, therefore requires a C++20 compliant compiler. v125 ---- diff --git a/CMakeLists.txt b/CMakeLists.txt index 041793662b3..d86f8d33771 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ include(GNUInstallDirs) # The C++ standard whose features are required to build Binaryen. # Keep in sync with scripts/test/shared.py cxx_standard # The if condition allows embedding in a project with a higher default C++ standard set -set(REQUIRED_CXX_STANDARD 17) +set(REQUIRED_CXX_STANDARD 20) if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD ${REQUIRED_CXX_STANDARD}) elseif(CMAKE_CXX_STANDARD LESS ${REQUIRED_CXX_STANDARD}) diff --git a/README.md b/README.md index 529eda8ccee..d3bf66f8722 100644 --- a/README.md +++ b/README.md @@ -412,7 +412,9 @@ After that you can build with CMake: cmake . && make ``` -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`. +A C++20 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`. To avoid the gtest dependency, you can pass `-DBUILD_TESTS=OFF` to cmake. diff --git a/scripts/test/shared.py b/scripts/test/shared.py index 5116fb0c1bf..e6a0917ee24 100644 --- a/scripts/test/shared.py +++ b/scripts/test/shared.py @@ -26,7 +26,7 @@ # The C++ standard whose features are required to build Binaryen. # Keep in sync with CMakeLists.txt CXX_STANDARD -cxx_standard = 17 +cxx_standard = 20 def parse_args(args): diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp index 797314e9f34..30c8ff59aec 100644 --- a/src/ir/module-splitting.cpp +++ b/src/ir/module-splitting.cpp @@ -457,9 +457,9 @@ void ModuleSplitter::classifyFunctions() { // module since that would make them async when they may not have the JSPI // wrapper. Exported JSPI functions can still benefit from splitting though // since only the JSPI wrapper stub will remain in the primary module. - if (func->imported() || !configSecondaryFuncs.count(func->name) || + if (func->imported() || !configSecondaryFuncs.contains(func->name) || (config.jspi && ExportUtils::isExported(primary, *func)) || - segmentReferrers.count(func->name)) { + segmentReferrers.contains(func->name)) { primaryFuncs.insert(func->name); } else { assert(func->name != primary.start && "The start function must be kept"); @@ -520,7 +520,7 @@ void ModuleSplitter::moveSecondaryFunctions() { for (auto& funcNames : config.secondaryFuncs) { auto secondary = initSecondary(primary); for (auto funcName : funcNames) { - if (allSecondaryFuncs.count(funcName)) { + if (allSecondaryFuncs.contains(funcName)) { auto* func = primary.getFunction(funcName); ModuleUtils::copyFunction(func, *secondary); primary.removeFunction(funcName); @@ -567,7 +567,7 @@ void ModuleSplitter::thunkExportedSecondaryFunctions() { Builder builder(primary); for (auto& ex : primary.exports) { if (ex->kind != ExternalKind::Function || - !allSecondaryFuncs.count(*ex->getInternalName())) { + !allSecondaryFuncs.contains(*ex->getInternalName())) { continue; } Name trampoline = getTrampoline(*ex->getInternalName()); @@ -609,7 +609,7 @@ void ModuleSplitter::indirectReferencesToSecondaryFunctions() { // 1. ref.func's target func is in one of the secondary modules and // 2. the current module is a different module (either the primary module // or a different secondary module) - if (parent.allSecondaryFuncs.count(curr->func) && + if (parent.allSecondaryFuncs.contains(curr->func) && (currModule == &parent.primary || parent.secondaries.at(parent.funcToSecondaryIndex.at(curr->func)) .get() != currModule)) { @@ -645,7 +645,7 @@ void ModuleSplitter::indirectReferencesToSecondaryFunctions() { std::vector relevantRefFuncs; for (auto* refFunc : refFuncs) { assert(refFunc->func == name); - if (!ignore.count(refFunc)) { + if (!ignore.contains(refFunc)) { relevantRefFuncs.push_back(refFunc); } } @@ -669,7 +669,7 @@ void ModuleSplitter::indirectCallsToSecondaryFunctions() { CallIndirector(ModuleSplitter& parent) : parent(parent) {} void visitCall(Call* curr) { // Return if the call's target is not in one of the secondary module. - if (!parent.allSecondaryFuncs.count(curr->target)) { + if (!parent.allSecondaryFuncs.contains(curr->target)) { return; } // Return if the current module is the same module as the call's target, @@ -719,12 +719,12 @@ void ModuleSplitter::exportImportCalledPrimaryFunctions() { : primaryFuncs(primaryFuncs), calledPrimaryToModules(calledPrimaryToModules) {} void visitCall(Call* curr) { - if (primaryFuncs.count(curr->target)) { + if (primaryFuncs.contains(curr->target)) { calledPrimaryToModules[curr->target].insert(getModule()); } } void visitRefFunc(RefFunc* curr) { - if (primaryFuncs.count(curr->func)) { + if (primaryFuncs.contains(curr->func)) { calledPrimaryToModules[curr->func].insert(getModule()); } } @@ -760,7 +760,7 @@ void ModuleSplitter::setupTablePatching() { if (!ref) { return; } - if (!allSecondaryFuncs.count(ref->func)) { + if (!allSecondaryFuncs.contains(ref->func)) { return; } assert(table == tableManager.activeTable->name);