Skip to content
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

bump LLVM to 18 for focal #267

Merged
merged 9 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ jobs:
# for cross build, cross-setup.sh takes care of the toolchain
if: matrix.os == 'ubuntu-20.04' && matrix.arch == 'native'
run: |
sudo ./cross/setup-focal-proposed.sh
sudo apt-get update && sudo apt-get install -y clang-13 lld-13
sudo ./cross/setup-apt-llvm-org.sh
sudo apt-get update && sudo apt-get install -y clang-18 lld-18
sudo ./cross/setup-alternatives.sh

- name: Fix sources.list (cross)
Expand All @@ -426,7 +426,7 @@ jobs:
ARCH: ${{matrix.arch}}
EXTRA_CMAKE_OPTIONS: -G Ninja ${{env.extra_cmake_options}} -DTOYWASM_TARBALL_SUFFIX=-${{matrix.name}}
run: |
sudo ./cross/setup-focal-proposed.sh
sudo ./cross/setup-apt-llvm-org.sh
sudo -E ./cross/cross-setup.sh
sudo ./cross/setup-alternatives.sh
./cross/cross-cmake-configure.sh
Expand Down
25 changes: 15 additions & 10 deletions cmake/ToywasmConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,14 @@ if (CMAKE_C_COMPILER_ID MATCHES "Clang")
# lld doesn't seem to support s390
# ld.lld: error: unknown emulation: elf64_s390
# https://github.com/llvm/llvm-project/blob/93b7bdcda7072581ef3f5ceaae8c4f0d549a0845/lld/ELF/Driver.cpp#L142-L166
#
# lld doesn't seem to support riscv relaxizations
# ld.lld: error: /usr/bin/../lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/lib/crt1.o:(.text+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax
if(NOT TRIPLET MATCHES "s390" AND NOT TRIPLET MATCHES "riscv64")
if(NOT TRIPLET MATCHES "s390")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
else()
set(USE_IPO OFF)
endif()
endif()
endif()

# clang-13 on ubuntu/focal:
# ld.lld: error: lto.tmp: cannot link object files with different floating-point ABI
#if(TRIPLET MATCHES "riscv64")
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-plugin-opt=-target-abi=lp64d")
#endif()

if(TRIPLET MATCHES "i386")
# x87 doesn't preserve sNaN as IEEE 754 and wasm expect.
# unfortunately, clang doesn't have -mno-fp-ret-in-387.
Expand Down Expand Up @@ -338,6 +329,20 @@ endif()
if(CMAKE_C_COMPILER_ID STREQUAL GNU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin")
endif()
# Clang 18's builtin ceil() etc seems to propagate sNaN as it is.
# (ubuntu/focal, riscv64, on qemu)
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
if(TRIPLET MATCHES "riscv64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin-floor")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin-floorf")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin-ceil")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin-ceilf")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin-trunc")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin-truncf")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin-rint")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin-rintf")
endif()
endif()

set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer")
#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Xclang -fmerge-functions")
Expand Down
2 changes: 1 addition & 1 deletion cross/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Our github CI jobs also use these scripts.

Expected usage:
```
./cross/setup-focal-proposed.sh
./cross/setup-apt-llvm-org.sh
export ARCH=arm64
./cross/cross-setup.sh
./cross/setup-alternatives.sh
Expand Down
2 changes: 1 addition & 1 deletion cross/cross-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

LLVM_VERSION=13
LLVM_VERSION=18

dpkg --add-architecture ${ARCH}
apt update
Expand Down
2 changes: 1 addition & 1 deletion cross/setup-alternatives.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

LLVM_VERSION=${LLVM_VERSION:-13}
LLVM_VERSION=${LLVM_VERSION:-18}
ALT_PRIO=100

COMMANDS=${1:-clang clang++ llvm-ar llvm-ranlib ld.lld lld}
Expand Down
11 changes: 11 additions & 0 deletions cross/setup-apt-llvm-org.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/sh

# https://apt.llvm.org/

apt-get update
apt-get install -y curl gnupg1
curl https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -

cat <<EOF > /etc/apt/sources.list.d/apt-llvm-org.list
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-18 main
EOF
2 changes: 1 addition & 1 deletion lib/insn.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ get_func_indirect(struct exec_context *ectx, uint32_t tableidx,

/*
* WASM float min/max follow IEEE 754-2019 minimum/maximum
* semantics:
* semantics, which are different from C fmin/fmax functions:
*
* - If either operand is a NaN (Note: can be an sNaN), returns a qNaN.
* - -0.0 < +0.0
Expand Down
Loading