forked from libgit2/libgit2sharp.nativebinaries
-
Notifications
You must be signed in to change notification settings - Fork 0
Build in statically linked libssh2 for openssl1.1 #11
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
Merged
eddymoulton
merged 8 commits into
octopus/master
from
octopus/em/build-for-multiple-openssls
May 13, 2026
+104
−17
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
89a3b62
Build libssh2 for multiple openssl backends
eddymoulton e3d8e4e
Merge branch 'octopus/master' into octopus/em/build-for-multiple-open…
eddymoulton e3d8199
Keep libcrypto3 build the same as it was
eddymoulton 4e82270
Build for all linux
eddymoulton e61ef06
Fix ppc641e build
eddymoulton 4835594
Build variants in parallel
eddymoulton c78f301
Simplify dockerbuild.sh
eddymoulton 57e06ec
PR comments
eddymoulton 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,37 +12,64 @@ jobs: | |
| name: ${{ matrix.name }} | ||
| runs-on: ${{ matrix.os }} | ||
| env: | ||
| RID: ${{ matrix.name }} | ||
| RID: ${{ matrix.rid }} | ||
| VARIANT: ${{ matrix.variant }} | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - os: windows-2022 | ||
| name: win-x86 | ||
| rid: win-x86 | ||
| param: -x86 | ||
| - os: windows-2022 | ||
| name: win-x64 | ||
| rid: win-x64 | ||
| param: -x64 | ||
| - os: windows-2022 | ||
| name: win-arm64 | ||
| rid: win-arm64 | ||
| param: -arm64 | ||
| - os: ubuntu-24.04 | ||
| name: linux-x64 | ||
| rid: linux-x64 | ||
| - os: ubuntu-24.04 | ||
| name: linux-x64-openssl1.1 | ||
| rid: linux-x64 | ||
| variant: openssl1.1 | ||
| - os: ubuntu-24.04 | ||
| name: linux-arm | ||
| rid: linux-arm | ||
| - os: ubuntu-24.04 | ||
| name: linux-arm-openssl1.1 | ||
| rid: linux-arm | ||
| variant: openssl1.1 | ||
| - os: ubuntu-24.04 | ||
| name: linux-arm64 | ||
| rid: linux-arm64 | ||
| - os: ubuntu-24.04 | ||
| name: linux-arm64-openssl1.1 | ||
| rid: linux-arm64 | ||
| variant: openssl1.1 | ||
| # debian:bullseye-slim has no ppc64le manifest, so the openssl1.1 | ||
| # variant is omitted for this RID. | ||
| - os: ubuntu-24.04 | ||
| name: linux-ppc64le | ||
| rid: linux-ppc64le | ||
| - os: ubuntu-24.04 | ||
| name: linux-musl-x64 | ||
| rid: linux-musl-x64 | ||
| - os: ubuntu-24.04 | ||
| name: linux-musl-arm | ||
| rid: linux-musl-arm | ||
| - os: ubuntu-24.04 | ||
| name: linux-musl-arm64 | ||
| rid: linux-musl-arm64 | ||
| - os: macos-26-intel | ||
| name: osx-x64 | ||
| rid: osx-x64 | ||
| - os: macos-26 | ||
| name: osx-arm64 | ||
| rid: osx-arm64 | ||
| fail-fast: false | ||
| steps: | ||
| - name: Checkout | ||
|
|
@@ -56,7 +83,7 @@ jobs: | |
| if: runner.os == 'macOS' | ||
| run: ./build.libgit2.sh | ||
| - name: Setup QEMU | ||
| if: runner.os == 'Linux' && (matrix.name == 'linux-arm' || matrix.name == 'linux-arm64' || matrix.name == 'linux-ppc64le' || matrix.name == 'linux-musl-arm' || matrix.name == 'linux-musl-arm64') | ||
| if: runner.os == 'Linux' && (matrix.rid == 'linux-arm' || matrix.rid == 'linux-arm64' || matrix.rid == 'linux-ppc64le' || matrix.rid == 'linux-musl-arm' || matrix.rid == 'linux-musl-arm64') | ||
| uses: docker/setup-qemu-action@v4 | ||
| - name: Set up Docker Buildx | ||
| if: runner.os == 'Linux' | ||
|
|
@@ -68,7 +95,7 @@ jobs: | |
| uses: actions/upload-artifact@v7.0.0 | ||
| with: | ||
| name: ${{ matrix.name }} | ||
| path: nuget.package/runtimes/${{ matrix.name }} | ||
| path: nuget.package/runtimes/${{ matrix.rid }} | ||
| package: | ||
| name: Create package | ||
| needs: build | ||
|
|
@@ -103,6 +130,23 @@ jobs: | |
| uses: actions/download-artifact@v8.0.1 | ||
| with: | ||
| path: nuget.package/runtimes/ | ||
| - name: Merge variant artifacts into RID directories | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: this bash, while working (and dense) reads like code golf. Possibly worth adding a small comment around exactly what we expect this to do in a future PR (if this survives the test of time, I'll be seen as a good reviewer) |
||
| shell: bash | ||
| run: | | ||
| # Variant artifacts (e.g. "linux-x64-openssl1.1") need their native | ||
| # binaries merged into the base RID directory ("linux-x64") so the | ||
| # NuGet package contains a single runtimes/<rid>/native/ tree per RID. | ||
| cd nuget.package/runtimes | ||
| for variant_dir in *-openssl1.1; do | ||
| [[ -d "$variant_dir" ]] || continue | ||
|
|
||
| rid="${variant_dir%-openssl1.1}" | ||
| target="$rid/native" | ||
|
|
||
| mkdir -p "$target" | ||
| mv "$variant_dir/native/"* "$target/" | ||
| rm -rf "$variant_dir" | ||
| done | ||
| - name: Create package | ||
| run: dotnet pack nuget.package ${{ steps.version.outputs.override && format('/p:MinVerVersionOverride={0}', steps.version.outputs.override) || '' }} | ||
| - name: Upload NuGet package | ||
|
|
||
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,33 @@ | ||
| FROM debian:bullseye-slim | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| build-essential \ | ||
| cmake \ | ||
| pkg-config \ | ||
| ca-certificates \ | ||
| curl \ | ||
| git \ | ||
| libssl-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Build libssh2 from source as a PIC static archive. apt's libssh2.a is not | ||
| # compiled with -fPIC, which prevents linking into libgit2.so. Static linking | ||
| # lets us ship one libgit2-<sha>-<openssl-variant>.so per OpenSSL ABI without | ||
| # colliding libssh2.so.1 SONAMEs across variants. | ||
| ARG LIBSSH2_VERSION=1.11.1 | ||
| RUN curl -fsSL https://github.com/libssh2/libssh2/releases/download/libssh2-${LIBSSH2_VERSION}/libssh2-${LIBSSH2_VERSION}.tar.gz -o libssh2.tar.gz \ | ||
| && tar xf libssh2.tar.gz \ | ||
| && cmake -S libssh2-${LIBSSH2_VERSION} -B libssh2-${LIBSSH2_VERSION}/build \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DBUILD_SHARED_LIBS=OFF \ | ||
| -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ | ||
| -DCRYPTO_BACKEND=OpenSSL \ | ||
| -DBUILD_TESTING=OFF \ | ||
| -DBUILD_EXAMPLES=OFF \ | ||
| && cmake --build libssh2-${LIBSSH2_VERSION}/build --target install \ | ||
| && rm -rf libssh2-${LIBSSH2_VERSION} libssh2.tar.gz | ||
|
|
||
| WORKDIR /nativebinaries | ||
| COPY . /nativebinaries/ | ||
|
|
||
| CMD ["/bin/bash", "-c", "./build.libgit2.sh"] |
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
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.
We explicitly build openssl1.1 variants where needed (only linux targets)