-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Disable shared libraries when building with emscripten #118262
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
Your org has enabled the Graphite merge queue for merging into mainAdd the label “FP Bundles” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
Emscripten doesn't yet support dynamic linking as per what cmake expects so we can't build and use Hence we could maybe have this instead to resolve the numerous warnings that show up while building against emscripten as shown in the issue. Another way might be to have the following in all files that give warnings.
|
@sbc100 this might be ready |
I know there are other folks who are focused on building llvm for Wasm. I wonder why they haven't found a need to do this? Can you not perhaps globally configure llvm for static linking perhaps? |
I mean I've seen people build it with warnings. The recipe hosted on emscripten-forge also has warnings but just ignores it. I just thought of addressing it here.
I am guessing if there is a way to do this. It should be suggested maybe in the docs for llvm (does a section for building llvm for wasm already exist or do we need one in the first place ? .... if something like this exists in that case we might end up with such a suggestion. ) |
@whitequark WDYT about this? IIUC you have been doing work making LLVM build for wasm. |
@sbc100 Seems reasonable, although I will note that I've focused on building LLVM for bare WASI since I need it to run on both JS-ful and JS-less platforms. As such I've never really used Emscripten much; pure-WASI takes different code paths here. |
Thanks for the discussion here. I would just say that I have been playing around with building llvm for wasm through emscripten. And I see few errors when I do that, hence I raised this and #118051 (approved needs merge). This would add more convinience rather than the long list of warnings that occur during the build. If we know we need to go for a static build, I guess we can possibly force it like what has been done here. |
Also I had a question. Are there docs on how to build llvm (possibly clang, lld) for web assembly ? |
I have a script building LLVM, Clang, and LLD here: https://github.com/YoWASP/clang |
cc @sbc100 Do these changes look reasonable to you now ? I think @whitequark approves. I mean I see different setting based on checks like But if that's not the case, whatever workaround is there should be well documented somewhere I guess. I've not had problems building llvm but then I see too warnings to ignore, hence in favour of such a change. |
And were you able to build without disabling shared libraries at the core level like this? (I assume you are not using any shared libraries in WASI since that is not really a thing yet). |
If there are existing build settings that effectively disable shared libraries then we should probably just rely on them. Are you able to make the build work without this patch using settings like these ones: https://github.com/YoWASP/clang/blob/0e0259397c85ba52b7370f6be0f52ae08ba3f4d5/build.sh#L72-L221 Can you update "web assembly" => "WebAssembly". Perhaps a better title might be "Disable shared libraries when building with emscripten" |
cc @sbc100 I see the following variable responsible for building shared libs. llvm-project/llvm/docs/CMake.rst Line 314 in 1b9805c
I think that might be enough to get stuff working.
EDIT: Oops sorry I thought this helped but actually this doesn't. I still see the warnings when building locally
|
Absolutely. The build is being hosted on emscripten-forge (which uses version 3.1.45 on main)
I realize why the above patch is required though. During llvm build process, if
But the approach I am using in emscripten-forge doesn't rely on the above. |
It seems perfectly reasonable to me to build tblgen for the host before compiling llvm for emscripten. Trying to pretend that emscripten is not a cross target is probably not worth the effort in this case. |
You could report an error if EMSCRIPTEN is incomaptible with BUILD_SHARED_LIBS=on. |
Seconding @MaskRay, if Emscripten doesn't support shared libraries we could error when you pass options like You might want to make a change to CMake to detect the Emscrpiten target and error out if the Emscripten toolchain doesn't support shared libraries, but that should be done in CMake not LLVM's build system. |
Fixes #118048