Skip to content

Request: Update libc++ to LLVM 13 #15396

Closed

Description

@Urfoex

Activity

  1. changed the title [-]Request: Update to LLVM 13[/-] [+]Request: Update libc++ to LLVM 13[/+] on Nov 1, 2021
  2. kripken commented on Nov 1, 2021

    @kripken
    Member

    Updated title to focus on libc++, as this is special to that (the emsdk already uses newer LLVM, but not libc++ yet).

  3. kripken commented on Nov 1, 2021

    @kripken
    Member

    If someone is interested to work on this, Emscripten has a bundled version of libc++ in system/lib/libcxx/. I believe to upgrade libc++ the first step would be to open a PR with LLVM 13's libc++ replaced there, and then to work through any issues with tests if there are any.

  4. kripken commented on Nov 2, 2021

    @kripken
    Member

    Yes, it may make sense to look at the diff before, then apply it afterwards.

  5. sbc100 commented on Nov 4, 2021

    @sbc100
    Collaborator

    My idea (which I admit is still being thought through, and not documented) is that all the patches for llvm libraries will live in our llvm fork at: https://github.com/emscripten-core/llvm-project

    I do mention this in the readme for libcxx, libcxxabi, compiler-rt, but I don't talk about how we maintain them there:

    llvm's compiler-rt
    ------------------
    These files are from the llvm-project based on release 12.0.0.
    We maintain a local fork of llvm-project that contains any emscripten
    specific patches:
    https://github.com/emscripten-core/llvm-project

    The idea is that for each major llvm release we maintain a branch in our llvm fork, and we periodically update it by copying the emscipten-files back to the fork. For example, for llvm 12.0.0 I we a branch called emscripten-libs-12.0.0. Comparing this branch with llvmorg-12.0.0 gives is the complete set of emscripten patches for llvm 12.0.0:

    emscripten-core/llvm-project@llvmorg-12.0.0...emscripten-core:emscripten-libs-12.0.0

    The idea is that when one wants to upgrade to llvm-13 one could rebase all of the llvm-12 changes onto the llvm-13 branch. At this point any conflicts could be resolved and the resulting branch in the llvm repo could then be copied back into the emscripten repo.

    I'll see if I can take care of documenting/automating/improving this process as part of the llvm-13 upgrade,

  6. Urfoex commented on Nov 4, 2021

    @Urfoex
    Author

    Tried building LLVM.
    Run into some RAM problems when linking.
    Changing the linker from ld to ldd helped a lot. (Gold might also work.)
    Release instead of Debug might also have helped.

    CMAKE_BUILD_TYPE: Release
    CMAKE_LINKER: /usr/bin/ld.lld
    GOLD_EXECUTABLE: /usr/bin/ld.lld
    

    I created a pull request against main to update it to latest upstream. (If that was ok. Sounded sensible before branching off its tag: llvmorg-13.0.0 )

  7. sbc100 commented on Nov 4, 2021

    @sbc100
    Collaborator

    Hopefully updating libc++/libc++abi/compiler-rt in emscripten will not actually require the building of llvm. Is there some reason you need to build it that I'm missing?

  8. Urfoex commented on Nov 4, 2021

    @Urfoex
    Author

    I guess I just had all projects enabled.
    This one should do better in my case:
    cmake -S llvm -B build -G Ninja -DLLVM_ENABLE_PROJECTS='clang;compiler-rt;libcxx;libcxxabi' -DCMAKE_LINKER=/usr/bin/ld.lld -DGOLD_EXECUTABLE=/usr/bin/ld.lld -DCMAKE_BUILD_TYPE=Debug
    or
    cmake -S llvm -B build -G Ninja -DLLVM_ENABLE_PROJECTS='clang;compiler-rt;libcxx;libcxxabi' -DCMAKE_LINKER=/usr/bin/ld.lld -DGOLD_EXECUTABLE=/usr/bin/ld.lld -DCMAKE_BUILD_TYPE=Release

    cmake --build build
    cmake --build build -- check-all
    
  9. sbc100 commented on Nov 4, 2021

    @sbc100
    Collaborator

    There should be no need to configure or build llvm to update emscripten's library code. IIUC, all compiling and testing of these library copies is done in the emscripten tree. The llvm tree is just the place where the upstream sources live, and where we hope to one day upstream all out changes (#15097)

  10. Urfoex commented on Nov 4, 2021

    @Urfoex
    Author

    You don't want to at least test compile the code to see if it might has problems?

    Ah!
    I see.
    Inside the emscripten tree.
    That would make sense.
    As I was now missing out on wasi/api.h. And installing wasi-libc didn't directly help...

  11. sbc100 commented on Nov 4, 2021

    @sbc100
    Collaborator

    I'm afraid there might be a lot of internal implementation of knowledge required to do this update. The process is (sadly) not well documented. Unless you are keen to learn a lot of how all this fits together it might not be good task to take on as new contributor.

    The wasi/api.h file should remain intact during this update, it comes from wasi-sdk originally. The file lives in system/include/wasi/api.h which should not be effected by this change.

  12. Urfoex commented on Nov 4, 2021

    @Urfoex
    Author

    I'm afraid there might be a lot of internal implementation of knowledge required to do this update. The process is (sadly) not well documented. Unless you are keen to learn a lot of how all this fits together it might not be good task to take on as new contributor.

    I'm afraid you are very much right.
    I dug through emsdk and emscripten, trying to get the tests running, as I thought, maybe after copying the new lib-versions over it would be good to see, that it still works. But I also didn't get them to work. Step by step hitting one roadblock after another. Frustrating. So, I'll better stop here and wait for some experienced people to solve this. Sorry.

  13. added a commit that references this issue on Jan 7, 2022
    afa122c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions