-
Notifications
You must be signed in to change notification settings - Fork 82
[doc] Document how to avoid symbol clashes with embedder #2740
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
base: main
Are you sure you want to change the base?
Conversation
PR HealthLicense Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with |
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.
Thanks for documenting this 👍
| Create a wrapper library that statically links the conflicting library (e.g., | ||
| SQLite) and re-exposes its symbols with a unique prefix. This avoids name | ||
| collisions with the library loaded by the embedder. | ||
|
|
||
| If your library allows the end-user to pass a dynamic library with user defines | ||
| or use the system library, then the wrapper can be designed to to dynamically | ||
| link against that library while still re-exposing the symbols with a prefix. |
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.
Just my two cents: This isn't trivial to get right. Because if I do say
int my_package_sqlite3_open_v2(
const char *filename,
sqlite3 **ppDb,
int flags,
const char *zVfs
) {
return sqlite3_open_v2(filename, ppDb, flags, zVfs);
}and use the default options from native_toolchain_c to link that and sqlite3.c into a shared library, my understanding is that sqlite3_open_v2 from the previously loaded library takes precedence over the sqlite3_open_v2 defined in the my wrapper library.
I think if I compile sqlite3.c with -fvisibility=hidden this could work, but then it's essentially the same thing as approach 2 with extra steps.
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.
So, this only works with the option to use the system library for space savings,
not with a custom library.
Closes: #2724
cc @simolus3