Repository navigation
build: fix AIX shared library exports generation #67359
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
sxa
wants to merge
4
commits into
nodejs:main
Choose a base branch
from
sxa:aix_shared_patch
base: main
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
Changes from all commits
Commits
Show all changes
4 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
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 |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ const char* dlopen_pong(void) { | |
|
|
||
| namespace { | ||
|
|
||
| using v8::Exception; | ||
| using v8::FunctionCallbackInfo; | ||
| using v8::Isolate; | ||
| using v8::Local; | ||
|
|
@@ -24,20 +25,41 @@ typedef const char* (*ping)(void); | |
|
|
||
| static ping ping_func; | ||
|
|
||
| void ThrowError(Isolate* isolate, const char* message) { | ||
| isolate->ThrowException( | ||
| Exception::Error(String::NewFromUtf8(isolate, message).ToLocalChecked())); | ||
| } | ||
|
|
||
| void LoadLibrary(const FunctionCallbackInfo<Value>& args) { | ||
| const String::Utf8Value filename(args.GetIsolate(), args[0]); | ||
| Isolate* isolate = args.GetIsolate(); | ||
| const String::Utf8Value filename(isolate, args[0]); | ||
| void* handle = dlopen(*filename, RTLD_LAZY); | ||
| if (handle == nullptr) fprintf(stderr, "%s\n", dlerror()); | ||
| assert(handle != nullptr); | ||
| if (handle == nullptr) { | ||
| ThrowError(isolate, dlerror() != nullptr ? dlerror() : "dlopen failed"); | ||
| return; | ||
| } | ||
| ping_func = reinterpret_cast<ping>(dlsym(handle, "dlopen_ping")); | ||
| assert(ping_func != nullptr); | ||
| if (ping_func == nullptr) { | ||
| dlclose(handle); | ||
| ThrowError(isolate, | ||
| dlerror() != nullptr ? dlerror() : "dlsym dlopen_ping failed"); | ||
|
Contributor
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. same issue as above, also calling |
||
| return; | ||
| } | ||
| } | ||
|
|
||
| void Ping(const FunctionCallbackInfo<Value>& args) { | ||
| Isolate* isolate = args.GetIsolate(); | ||
| assert(ping_func != nullptr); | ||
| args.GetReturnValue().Set(String::NewFromUtf8( | ||
| isolate, ping_func()).ToLocalChecked()); | ||
| if (ping_func == nullptr) { | ||
| ThrowError(isolate, "ping library was not loaded"); | ||
| return; | ||
| } | ||
| const char* answer = ping_func(); | ||
| if (answer == nullptr) { | ||
| ThrowError(isolate, "dlopen_pong could not be resolved (RTLD_GLOBAL)"); | ||
| return; | ||
| } | ||
| args.GetReturnValue().Set( | ||
| String::NewFromUtf8(isolate, answer).ToLocalChecked()); | ||
| } | ||
|
|
||
| void init(Local<Object> exports) { | ||
|
|
||
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 |
|---|---|---|
| @@ -1,10 +1,26 @@ | ||
| #ifndef _WIN32 | ||
|
|
||
| #if defined(_AIX) | ||
| #include <stddef.h> | ||
| #include <dlfcn.h> | ||
| #else | ||
| const char* dlopen_pong(void); | ||
| #endif | ||
|
|
||
| __attribute__((visibility("default"))) | ||
| const char* dlopen_ping(void) { | ||
| #if defined(_AIX) | ||
| /* ping.so is built with -Wl,-G: link-time import of dlopen_pong is resolved | ||
| * when ping.so is loaded. On --shared libnode builds that resolution can fail | ||
| * even when dlopen_pong appears in binding's loader table (dump). Resolve | ||
| * at call time via the global symbol set after process.dlopen(RTLD_GLOBAL). */ | ||
| typedef const char* (*pong_fn)(void); | ||
| pong_fn pong = | ||
| (pong_fn)dlsym(RTLD_DEFAULT, "dlopen_pong"); | ||
| return pong != NULL ? pong() : NULL; | ||
| #else | ||
| return dlopen_pong(); | ||
| #endif | ||
| } | ||
|
|
||
| #endif // _WIN32 |
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
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.
first
dlerrorcall here clears any existing error on linux and it looks like same applies on AIX:https://www.ibm.com/docs/en/aix/7.1.0?topic=d-dlerror-subroutine
Which makes the second call
? dlerror()problematic.