Repository navigation
Add C++ module support #1288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mikomikotaishi
wants to merge
16
commits into
libcpr:master
Choose a base branch
from
mikomikotaishi:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add C++ module support #1288
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c048707
Add C++ module support
mikomikotaishi 6ca8ff2
Add modules CI for building the modules
mikomikotaishi b36ecd8
Modules raw
COM8 bfa74b0
Use import std if possible
COM8 71ade0c
import std fixes
COM8 093df41
Fixed version check test compilation
COM8 0768e32
Further cpr version test fixes
COM8 cfa8462
Removed old version tests
COM8 d333f25
Disable CMAKE_CXX_MODULE_STD to prevent passing onto dependencies
mikomikotaishi 0cad1b0
Merge branch 'master' into master
mikomikotaishi 4cc44f1
Fix errors made in merging and incorrect includes without guards
mikomikotaishi 891cfec
Merge branch 'master' into master
mikomikotaishi 36e7474
Diagnose missing test executables in CI
mikomikotaishi af754b2
Remove missing test diagnostics now that the root cause is found
mikomikotaishi e8057e4
Address suggested changes in recent batch of reviews
mikomikotaishi c33421e
Suppress `-Wreserved-module-identifier`, false positive
mikomikotaishi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| name: C++20 Modules CI | ||
| on: [push, workflow_dispatch, pull_request] | ||
|
|
||
| env: | ||
| # Enable verbose output for CMake and tests | ||
| VERBOSE: 1 | ||
| CTEST_OUTPUT_ON_FAILURE: 1 | ||
|
|
||
| jobs: | ||
| fedora-clang-modules: | ||
| strategy: | ||
| matrix: | ||
| buildType: [Debug, Release] | ||
| runs-on: ubuntu-latest | ||
| # Fedora ships a recent Clang, libc++ and CMake out of the box, so we do not | ||
| # have to download and pin specific compiler/CMake versions by hand. | ||
| container: "fedora:latest" | ||
| steps: | ||
| - name: Update package list | ||
| run: dnf update -y | ||
| - name: Install Dependencies | ||
| run: dnf install -y clang clang-tools-extra libcxx-devel libcxxabi-devel cmake git make openssl-devel libcurl-devel libpsl-devel libunistring-devel meson ninja-build tar wget | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
| - name: Configure | ||
| run: | | ||
| cmake -S . -B build \ | ||
| -DCMAKE_BUILD_TYPE=${{ matrix.buildType }} \ | ||
| -DCMAKE_CXX_COMPILER=clang++ \ | ||
| -DCMAKE_C_COMPILER=clang \ | ||
| -DCMAKE_CXX_FLAGS="-stdlib=libc++" \ | ||
| -DCPR_BUILD_MODULES=ON \ | ||
| -DCPR_BUILD_TESTS=ON \ | ||
| -DCPR_BUILD_TESTS_SSL=ON \ | ||
| -DCPR_FORCE_OPENSSL_BACKEND=ON \ | ||
| -DCPR_USE_SYSTEM_CURL=OFF \ | ||
| -G Ninja | ||
| - name: Build | ||
| run: cmake --build build --verbose | ||
| - name: Test | ||
| run: ctest --test-dir build --output-on-failure --repeat until-pass:5 | ||
| - name: Verify Module Build | ||
| # Running the 'import cpr;' example is the real proof that the module was | ||
| # built and is importable; grepping for a library file on disk is not, | ||
| # since a module-only target may not emit a conventional archive. | ||
| run: ./build/bin/cpr_module_example | ||
|
|
||
| fedora-gcc-modules: | ||
| runs-on: ubuntu-latest | ||
| container: "fedora:latest" | ||
| steps: | ||
| - name: Update package list | ||
| run: dnf update -y | ||
| - name: Install Dependencies | ||
| # Fedora ships GCC and CMake recent enough for 'import std' out of the box. | ||
| run: dnf install -y gcc g++ git make cmake openssl-devel libcurl-devel libpsl-devel libunistring-devel meson ninja-build tar wget | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
| - name: Configure | ||
| run: | | ||
| cmake -S . -B build \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCPR_BUILD_MODULES=ON \ | ||
| -DCPR_BUILD_TESTS=ON \ | ||
| -DCPR_BUILD_TESTS_SSL=ON \ | ||
| -DCPR_FORCE_OPENSSL_BACKEND=ON \ | ||
| -DCPR_USE_SYSTEM_CURL=OFF \ | ||
| -G Ninja | ||
| - name: Build | ||
| run: cmake --build build --verbose | ||
| - name: Test | ||
| run: ctest --test-dir build --output-on-failure --repeat until-pass:5 | ||
| - name: Verify Module Build | ||
| # Running the 'import cpr;' example proves the module compiled and imports. | ||
| run: ./build/bin/cpr_module_example | ||
|
|
||
| windows-msvc-modules: | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/setup-python@v6 | ||
| - name: Install meson | ||
| run: pip install meson | ||
| - name: Setup MSVC environment | ||
| uses: ilammy/msvc-dev-cmd@v1 | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
| - name: Install dependencies via vcpkg | ||
| run: | | ||
| vcpkg install curl zlib openssl --triplet x64-windows | ||
| shell: pwsh | ||
| - name: Configure | ||
| run: | | ||
| cmake -S . -B build ` | ||
| -DCMAKE_BUILD_TYPE=Release ` | ||
| -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" ` | ||
| -DVCPKG_TARGET_TRIPLET=x64-windows ` | ||
| -DCPR_BUILD_MODULES=ON ` | ||
| -DCPR_BUILD_TESTS=ON ` | ||
| -DCPR_BUILD_TESTS_SSL=OFF ` | ||
| -DCPR_USE_SYSTEM_CURL=ON ` | ||
| -G Ninja | ||
| shell: pwsh | ||
| - name: Build | ||
| run: cmake --build build --config Release --verbose | ||
| - name: Test | ||
| run: ctest --test-dir build -C Release --output-on-failure --repeat until-pass:5 | ||
| - name: Verify Module Build | ||
| # Running the 'import cpr;' example proves the module compiled and imports. | ||
| run: ./build/bin/cpr_module_example.exe | ||
| shell: pwsh | ||
|
|
||
| macos-clang-modules: | ||
| runs-on: macos-latest | ||
| # Uses Homebrew LLVM's own libc++ for 'import std' (see Configure). | ||
| # Keep the job non-blocking until it has been confirmed stable on CI. | ||
| continue-on-error: true | ||
| steps: | ||
| - name: Install Dependencies | ||
| run: | | ||
| brew install cmake llvm libpsl ninja | ||
| echo "$(brew --prefix cmake)/bin" >> "$GITHUB_PATH" | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
| - name: Configure | ||
| run: | | ||
| # Homebrew's clang links the macOS system libc++ by default, and CMake's | ||
| # '-print-file-name' lookup does not find the 'libc++.modules.json' that | ||
| # Homebrew's own libc++ ships. Point CMake at it and link that libc++. | ||
| LLVM_PREFIX="$(brew --prefix llvm)" | ||
| MODULES_JSON="$(find "$LLVM_PREFIX/lib" -name 'libc++.modules.json' -print -quit)" | ||
| if [ -z "$MODULES_JSON" ]; then | ||
| echo "Error: libc++.modules.json not found under $LLVM_PREFIX/lib" | ||
| exit 1 | ||
| fi | ||
| echo "Using $MODULES_JSON" | ||
| LIBCXX_LDFLAGS="-L$LLVM_PREFIX/lib/c++ -Wl,-rpath,$LLVM_PREFIX/lib/c++ -L$LLVM_PREFIX/lib/unwind -Wl,-rpath,$LLVM_PREFIX/lib/unwind -lunwind" | ||
| cmake -S . -B build \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_CXX_STDLIB_MODULES_JSON="$MODULES_JSON" \ | ||
| -DCMAKE_EXE_LINKER_FLAGS="$LIBCXX_LDFLAGS" \ | ||
| -DCMAKE_SHARED_LINKER_FLAGS="$LIBCXX_LDFLAGS" \ | ||
| -DCMAKE_MODULE_LINKER_FLAGS="$LIBCXX_LDFLAGS" \ | ||
| -DCMAKE_CXX_COMPILER=$LLVM_PREFIX/bin/clang++ \ | ||
| -DCMAKE_C_COMPILER=$(brew --prefix llvm)/bin/clang \ | ||
| -DCPR_BUILD_MODULES=ON \ | ||
| -DCPR_BUILD_TESTS=ON \ | ||
| -DCPR_BUILD_TESTS_SSL=OFF \ | ||
| -DCPR_USE_SYSTEM_LIB_PSL=ON \ | ||
| -G Ninja | ||
| - name: Build | ||
| run: cmake --build build --verbose | ||
| - name: Test | ||
| run: ctest --test-dir build --output-on-failure --repeat until-pass:5 | ||
| - name: Verify Module Build | ||
| # Running the 'import cpr;' example proves the module compiled and imports. | ||
| run: ./build/bin/cpr_module_example | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest adding a small example in
examples/modules/...where the test actually compiles and uses modules viaimport cpr;.