Skip to content

Commit 0f01620

Browse files
committed
also patchelf for osx
1 parent 25cef37 commit 0f01620

File tree

1 file changed

+40
-14
lines changed

1 file changed

+40
-14
lines changed

.github/workflows/build-native-nuget.yml

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616

1717
jobs:
1818
build-all:
19-
runs-on: ubuntu-22.04
19+
runs-on: ${{ matrix.rid == 'osx-x64' && 'macos-13' || matrix.rid == 'osx-arm64' && 'macos-15' || 'ubuntu-22.04' }}
2020
strategy:
2121
matrix:
2222
include:
@@ -81,20 +81,46 @@ jobs:
8181
fi
8282
8383
ls -l nuget
84-
85-
- name: Patch RPATH for paddle_inference_c.so(linux only)
86-
if: ${{ matrix.rid == 'linux-x64' || matrix.rid == 'linux-arm64' }}
84+
85+
- name: Patch RPATH / install-name for Paddle
86+
shell: bash
8787
run: |
88-
echo "Current RPATH for libpaddle_inference_c.so"
89-
patchelf --print-rpath nuget/libpaddle_inference_c.so
90-
91-
echo "Patching RPATH for libpaddle_inference_c.so"
92-
patchelf --set-rpath '$ORIGIN' nuget/libpaddle_inference_c.so
93-
94-
echo "RPATH set to '$ORIGIN' for libpaddle_inference_c.so"
95-
patchelf --print-rpath nuget/libpaddle_inference_c.so
96-
97-
echo "RPATH patched successfully."
88+
set -e
89+
echo "RID=${{ matrix.rid }}"
90+
91+
case "${{ matrix.rid }}" in
92+
93+
# ---------- Linux (x86_64 / aarch64) ----------
94+
linux-*)
95+
echo "Before:"
96+
patchelf --print-rpath nuget/libpaddle_inference_c.so || true
97+
98+
patchelf --set-rpath '$ORIGIN' nuget/libpaddle_inference_c.so
99+
100+
echo "After :"
101+
patchelf --print-rpath nuget/libpaddle_inference_c.so
102+
;;
103+
104+
# ---------- macOS (x86_64 / arm64) ----------
105+
osx-*)
106+
dylib=nuget/libpaddle_inference_c.dylib
107+
108+
echo "Before:"
109+
otool -l "$dylib" | grep -A2 LC_RPATH || true
110+
111+
install_name_tool -id @rpath/$(basename "$dylib") "$dylib"
112+
install_name_tool -add_rpath @loader_path "$dylib" 2>/dev/null || true
113+
114+
echo "After :"
115+
otool -l "$dylib" | grep -A2 LC_RPATH
116+
;;
117+
118+
*)
119+
echo "no rpath patch needed for ${{ matrix.rid }}"
120+
;;
121+
esac
122+
123+
echo "RPATH / LC_RPATH patched successfully."
98124

99125
- name: Build NuGet package
100126
run: |

0 commit comments

Comments
 (0)