Skip to content

build-scripts/build_llvm.py: bump to llvm 18 #4259

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

Merged
merged 3 commits into from
May 9, 2025

Conversation

yamt
Copy link
Collaborator

@yamt yamt commented May 8, 2025

cf. #4210

why not 20?
because, as of writing this, 19 is the latest released version for
the xtensa fork of llvm: https://github.com/espressif/llvm-project

why not 19?
because of a bug in the xtensa fork of llvm:
espressif/llvm-project#112

while we can use different versions for different targets,
it's nicer to use the same version everywhere when possible.

cf. bytecodealliance#4210

why not 20?
because, as of writing this, 19 is the latest released version for
the xtensa fork of llvm: https://github.com/espressif/llvm-project

why not 19?
because of a bug in the xtensa fork of llvm:
espressif/llvm-project#112

while we can use different versions for different targets,
it's nicer to use the same version everywhere when possible.
yamt added 2 commits May 8, 2025 15:22
with the recent version of LLVM, wamrc --size-level=1 often
generates R_X86_64_32S relocations which fail on load with
the infamous error:

"relocation truncated to fit R_X86_64_32S failed"

it seems that these relocations are often for jump tables.

this commit workarounds it with --size-level=0.

an alternative is to disable jump tables. (although it seems that
jump tables are not the only source of these relocations.)

cf. bytecodealliance#3035

it might be better to do this in wamrc itself. however, currently
target info is not available there in case of native compilation.
related: bytecodealliance#3356
@yamt yamt changed the title test llvm 18 for xtensa build-scripts/build_llvm.py: bump to llvm 18 May 8, 2025
@yamt yamt marked this pull request as ready for review May 8, 2025 08:01
Copy link
Collaborator

@lum1n0us lum1n0us left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@TianlongLiang TianlongLiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lum1n0us lum1n0us merged commit 908838a into bytecodealliance:main May 9, 2025
402 checks passed
@lum1n0us
Copy link
Collaborator

@yamt

I made a test run on my forked repository and encountered two failures related to LLVM compilation:

@yamt
Copy link
Collaborator Author

yamt commented May 12, 2025

@yamt

I made a test run on my forked repository and encountered two failures related to LLVM compilation:

* https://github.com/lum1n0us/wasm-micro-runtime/actions/runs/14962486268/job/42026672520. Like: _clang: error: no such file or directory: '/Users/runner/work/wasm-micro-runtime/wasm-micro-runtime/core/deps/llvm-project/build/tools/lldb/tools/debugserver/source/mach_excUser.c'_

i'm not sure how it can happen off hand.
those files are expected to be generated at:
https://github.com/lum1n0us/wasm-micro-runtime/actions/runs/14962486268/job/42026672520#step:14:26302

* https://github.com/lum1n0us/wasm-micro-runtime/actions/runs/14962486268/job/42028726543. Like: _D:\a\wasm-micro-runtime\wasm-micro-runtime\core\deps\llvm\build\include\llvm\ADT\STLForwardCompat.h(46,35): error C2039: 'optional': is not a member of 'std'_

maybe #4269 ?
just a wild guess, i haven't used wamr on windows.

@lum1n0us
Copy link
Collaborator

https://github.com/lum1n0us/wasm-micro-runtime/actions/runs/14967033117/job/42039634773

Maybe we missed a part that needs to adapt build-scripts/lldb_wasm.patch to LLVM 18?

In my personal repository, I have updated LLVM in .github/workflows/build_wamr_lldb.yml to 18.1.8, and the step "apply WAMR patch" failed.

      - name: download llvm
        if: steps.lldb_build_cache.outputs.cache-hit != 'true'
        run: |
          wget -O llvm-project.tar.xz --progress=dot:giga https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/llvm-project-18.1.8.src.tar.xz
          tar -xzf llvm-project.tar.xz
          mv llvm-project-18.1.8.src llvm-project
        working-directory: core/deps/

@yamt
Copy link
Collaborator Author

yamt commented May 12, 2025

https://github.com/lum1n0us/wasm-micro-runtime/actions/runs/14967033117/job/42039634773

Maybe we missed a part that needs to adapt build-scripts/lldb_wasm.patch to LLVM 18?

In my personal repository, I have updated LLVM in .github/workflows/build_wamr_lldb.yml to 18.1.8, and the step "apply WAMR patch" failed.

      - name: download llvm
        if: steps.lldb_build_cache.outputs.cache-hit != 'true'
        run: |
          wget -O llvm-project.tar.xz --progress=dot:giga https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/llvm-project-18.1.8.src.tar.xz
          tar -xzf llvm-project.tar.xz
          mv llvm-project-18.1.8.src llvm-project
        working-directory: core/deps/

oops, i have completely forgotten that patch. :-)

@xujuntwt95329 do you remember what's the status of llvm/llvm-project#77949
and https://github.com/xujuntwt95329/wasm-micro-runtime/tree/wasm_debug_2024 ?

@lum1n0us
Copy link
Collaborator

i'm not sure how it can happen off hand.those files are expected to be generated at:

Those files are not able to be generated.

set(generated_mach_interfaces
  ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
  ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
  ${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c
  )

#...

add_custom_command(OUTPUT ${generated_mach_interfaces}
  VERBATIM COMMAND mig ${MIG_ARCH_FLAGS_SEPARTED} -isysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
  )

Based on the running command. from https://github.com/lum1n0us/wasm-micro-runtime/actions/runs/14988324213/job/42106372313#step:12:10024. ${CMAKE_OS_SYSROOT} isn't set properly. It will let mach/mach_exc.defs can't be found which is imported by dbgnub-mig.defs.

[368/407] cd /Users/runner/work/wasm-micro-runtime/wasm-micro-runtime/core/deps/llvm-project/build/tools/lldb/tools/debugserver/source && mig -isysroot /Users/runner/work/wasm-micro-runtime/wasm-micro-runtime/core/deps/llvm-project/lldb/tools/debugserver/source/MacOSX/dbgnub-mig.defs

@lum1n0us
Copy link
Collaborator

lum1n0us commented May 13, 2025

It is a known issue with CMake 4.0. llvm/llvm-project#138020

#4274

sjamesr pushed a commit to sjamesr/wasm-micro-runtime that referenced this pull request May 13, 2025
* build-scripts/build_llvm.py: bump to llvm 18

cf. bytecodealliance#4210

why not 20?
because, as of writing this, 19 is the latest released version for
the xtensa fork of llvm: https://github.com/espressif/llvm-project

why not 19?
because of a bug in the xtensa fork of llvm:
espressif/llvm-project#112

while we can use different versions for different targets,
it's nicer to use the same version everywhere when possible.

* spec-test-script/runtest.py: --size-level=0 for x86-64

with the recent version of LLVM, wamrc --size-level=1 often
generates R_X86_64_32S relocations which fail on load with
the infamous error:

"relocation truncated to fit R_X86_64_32S failed"

it seems that these relocations are often for jump tables.

this commit workarounds it with --size-level=0.

an alternative is to disable jump tables. (although it seems that
jump tables are not the only source of these relocations.)

cf. bytecodealliance#3035

it might be better to do this in wamrc itself. however, currently
target info is not available there in case of native compilation.
related: bytecodealliance#3356

* wamr-compiler: size_level=0 for sgx mode

cf. bytecodealliance#3035
@lum1n0us
Copy link
Collaborator

@yamt @xujuntwt95329 Is there any chance that we can skip lldb in the v2.3.0 release? I've learned that upgrading lldb_wasm.patch to LLVM 18 will not be a quick and smooth process. Maybe we shouldn't let v2.3.0 wait for it?

@yamt
Copy link
Collaborator Author

yamt commented May 14, 2025

@yamt @xujuntwt95329 Is there any chance that we can skip lldb in the v2.3.0 release? I've learned that upgrading lldb_wasm.patch to LLVM 18 will not be a quick and smooth process. Maybe we shouldn't let v2.3.0 wait for it?

maybe just leave it as it is? (ie llvm 13)
iirc, it's what we did when upgrading to llvm 15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants