-
-
Notifications
You must be signed in to change notification settings - Fork 13
Rewrite the addon's libchdb path whatever the engine calls it #80
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -1,8 +1,43 @@ | ||
| #!/bin/bash | ||
|
|
||
| cd "$(dirname "$0")" | ||
| set -o pipefail | ||
|
|
||
| # Point the addon at the libchdb.so that ships beside it, instead of whatever the | ||
| # linker recorded. | ||
| # | ||
| # Which name the linker records comes from the engine's install_name, and that is | ||
| # not stable: chdb-core shipped `libchdb.so` through v26.5.x and `@rpath/libchdb.so` | ||
| # from v26.7.0. `install_name_tool -change` silently succeeds when the old name | ||
| # matches nothing, so a script that knew only one spelling left the addon pointing | ||
| # at `@rpath/libchdb.so` with no LC_RPATH to resolve it — and the failure surfaced | ||
| # far away, as ERR_DLOPEN_FAILED when the loader tried to require the addon. | ||
| # | ||
| # Hence: rewrite every spelling we have seen, then verify. A dependency this script | ||
| # cannot resolve is a build failure, not something to discover at runtime. | ||
| if [[ $(uname -s) == "Darwin" ]]; then | ||
| install_name_tool -change libchdb.so @loader_path/../../libchdb.so build/Release/chdb_node.node | ||
| otool -L build/Release/chdb_node.node | ||
| ADDON=build/Release/chdb_node.node | ||
| TARGET=@loader_path/../../libchdb.so | ||
|
|
||
| for old in libchdb.so @rpath/libchdb.so; do | ||
| install_name_tool -change "$old" "$TARGET" "$ADDON" 2>/dev/null || true | ||
| done | ||
|
|
||
| otool -L "$ADDON" | ||
|
|
||
| # Assert what the dependency IS, rather than grepping for what it is not. That | ||
| # covers otool failing on a missing or unreadable addon (no output), an addon | ||
| # with no libchdb dependency at all, more than one of them, and a path that | ||
| # merely resembles the target — a `grep "$TARGET"` would accept | ||
| # @loader_path/ab/cd/libchdb.so, since the dots are wildcards. | ||
| dep=$(otool -L "$ADDON" | awk '/libchdb\.so/ { print $1 }') | ||
| if [ "$dep" != "$TARGET" ]; then | ||
| echo "fix_loader_path.sh: expected $ADDON to depend on exactly" >&2 | ||
| echo " $TARGET" >&2 | ||
| echo "and it depends on:" >&2 | ||
| echo " ${dep:-<nothing, or otool failed>}" >&2 | ||
| echo "If that is a new install_name spelling from the engine, add it to the" >&2 | ||
| echo "loop above. Left alone, dlopen fails at runtime." >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
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.
Uh oh!
There was an error while loading. Please reload this page.