-
Notifications
You must be signed in to change notification settings - Fork 628
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
Link libc++ statically to reduce runtime dependency of wamrc #3331
base: main
Are you sure you want to change the base?
Conversation
cb7047d
to
a2528d0
Compare
# If not on macOS, link libgcc statically | ||
if (NOT APPLE) | ||
target_link_libraries (wamrc -static-libgcc) | ||
endif() |
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.
which instance of these libraries are used by shared libraries loaded by --native-lib
?
is it ok to have multiple copies of these libraries in a process?
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.
I'm not sure which copy will be used in the native lib, but it seems OK since I have used a cxx based custom compiler plugin with prebuilt wasi-sdk, it works fine without special action, please refer to: https://clang.llvm.org/docs/ClangPlugins.html
I guess it use the dynamic libc++ from system instead of the static version in the clang/wamrc
target_link_libraries (wamrc -static-libstdc++) | ||
# If not on macOS, link libgcc statically | ||
if (NOT APPLE) | ||
target_link_libraries (wamrc -static-libgcc) |
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.
Can we make this configurable?
I think static link such libraries is not a very common requirement.
@xujuntwt95329 @yamt I'm trying to make I thinks it's useful since we also provide prebuilt binary for wamrc. |
@no1wudi it sounds good to me, but it increases the wamrc binary size. Could we link the static gcc/g++ lib only for the CI prebuilt binaries and keep it unchanged for normal compilation? Not sure whether it is easy to achieve that? |
I guess libc++ is a basement for every platform. If there are compatible issues with a dynamic libc++ library, it highly likely suggests there is a real compatible issue with the platform(via libc++). Using a static library may let wamrc run, but also covers some real problems, I am afraid. |
Please refer to widely used wasi-sdk and llvm does if you have any concerns: https://github.com/WebAssembly/wasi-sdk/blob/99abb024209dc7a9a8d8f3eb6d03908a18bb0594/Makefile#L84 Static link stdc++ should be except increase the binary size, the real problem is glibc, it's can not be linked statically. The wasi-sdk build the toolchain on older version system (glibc, Ubuntu-18), so if glibc version in your system higher than it then you can run it. |
i can understand about libstdc++. also, can you answer this question? #3331 (comment) |
Maybe libgcc is not a problem for this case, but I'm not sure will it lead to compatibility issue in early test so it static linked here, we can remove it after more test. |
No description provided.