WebAssembly / wasi-sdk

WASI-enabled WebAssembly C/C++ toolchain
Apache License 2.0
1.28k stars 192 forks source link

I am trying to include llvm-19rc2 in wasi-sdk-24 version #475

Open subhakr opened 3 months ago

subhakr commented 3 months ago

Hi, I am trying to include llvm-19rc2 version in wasi-sdk-24 version.

while running this command i am getting below errors . cmake --build build/sysroot --target install

mkdir -p "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/share/wasm32-wasi"
/home/admin1/Music/wasi-sdk/build/install/bin/llvm-ar crs build/wasm32-wasi/libwasi-emulated-signal.so.a 
/home/admin1/Music/wasi-sdk/build/install/bin/llvm-ar crs build/wasm32-wasi/libdl.so.a 
/home/admin1/Music/wasi-sdk/build/install/bin/llvm-ar crs build/wasm32-wasi/libsetjmp.so.a 
#
/home/admin1/Music/wasi-sdk/build/install/bin/clang --target=wasm32-wasi -nodefaultlibs -shared --sysroot=/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot \
-o /home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi/libwasi-emulated-mman.so -Wl,--whole-archive build/wasm32-wasi/libwasi-emulated-mman.so.a -Wl,--no-whole-archive /home/admin1/Music/wasi-sdk/build/sysroot/install/wasi-resource-dir/lib/wasi/libclang_rt.builtins-wasm32.a
# Collect symbol information.
#
/home/admin1/Music/wasi-sdk/build/install/bin/clang --target=wasm32-wasi -nodefaultlibs -shared --sysroot=/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot \
-o /home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi/libwasi-emulated-process-clocks.so -Wl,--whole-archive build/wasm32-wasi/libwasi-emulated-process-clocks.so.a -Wl,--no-whole-archive /home/admin1/Music/wasi-sdk/build/sysroot/install/wasi-resource-dir/lib/wasi/libclang_rt.builtins-wasm32.a
wasm-ld: warning: creating shared libraries, with -shared, is not yet stable
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: errno
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: errno
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: errno
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: errno
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: malloc
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: errno
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: pread
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: errno
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: memset
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: errno
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: free
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-mman.so.a(mman.pic.o): undefined symbol: errno
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:613: /home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi/libwasi-emulated-mman.so] Error 1
make: *** Waiting for unfinished jobs....
"/home/admin1/Music/wasi-sdk/build/install/bin/llvm-nm" --defined-only "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi"/libc.a "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi"/libwasi-emulated-*.a "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi"/*.o \
    |grep ' [[:upper:]] ' |sed 's/.* [[:upper:]] //' |LC_ALL=C sort |uniq > "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/share/wasm32-wasi/defined-symbols.txt"
wasm-ld: warning: creating shared libraries, with -shared, is not yet stable
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-process-clocks.so.a(clock.pic.o): undefined symbol: __wasi_clock_time_get
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-process-clocks.so.a(clock.pic.o): undefined symbol: __wasi_clock_time_get
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-process-clocks.so.a(getrusage.pic.o): undefined symbol: errno
wasm-ld: error: build/wasm32-wasi/libwasi-emulated-process-clocks.so.a(times.pic.o): undefined symbol: __wasi_clock_time_get
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:613: /home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi/libwasi-emulated-process-clocks.so] Error 1
for undef_sym in $("/home/admin1/Music/wasi-sdk/build/install/bin/llvm-nm" --undefined-only "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi"/libc.a "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi"/libc-*.a "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi"/*.o |grep ' U ' |sed 's/.* U //' |LC_ALL=C sort |uniq); do \
    grep -q '\<'$undef_sym'\>' "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/share/wasm32-wasi/defined-symbols.txt" || echo $undef_sym; \
done | grep -E -v "^__mul|__memory_base|__indirect_function_table|__tls_base" > "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/share/wasm32-wasi/undefined-symbols.txt"
grep '^_*imported_wasi_' "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/share/wasm32-wasi/undefined-symbols.txt" \
    > "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi/libc.imports"
#
# Generate a test file that includes all public C header files.
#
# setjmp.h is excluded because it requires a different compiler option
#
cd "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/include/wasm32-wasi" && \
  for header in $(find . -type f -not -name mman.h -not -name signal.h -not -name times.h -not -name resource.h -not -name setjmp.h -not -name wasip2.h -not -name descriptor_table.h |grep -v /bits/ |grep -v /c++/); do \
      echo '#include <'$header'>' | sed 's/\.\///' ; \
done |LC_ALL=C sort >/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/share/wasm32-wasi/include-all.c ; \
cd - >/dev/null
#
# Test that it compiles.
#
/home/admin1/Music/wasi-sdk/build/install/bin/clang -fdebug-prefix-map=/home/admin1/Music/wasi-sdk=wasisdk://v24.2gb416e2beb40b -resource-dir /home/admin1/Music/wasi-sdk/build/sysroot/install/wasi-resource-dir -O2 -g -DNDEBUG --target=wasm32-wasi -fno-trapping-math -Wall -Wextra -Werror -Wno-null-pointer-arithmetic -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-unused-function -Wno-ignored-attributes -Wno-missing-braces -Wno-ignored-pragmas -Wno-unused-but-set-variable -Wno-unknown-warning-option -mthread-model single -isystem "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/include/wasm32-wasi" -fsyntax-only "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/share/wasm32-wasi/include-all.c" -Wno-\#warnings
#
# Collect all the predefined macros, except for compiler version macros
# which we don't need to track here.
#
/home/admin1/Music/wasi-sdk/build/install/bin/clang -fdebug-prefix-map=/home/admin1/Music/wasi-sdk=wasisdk://v24.2gb416e2beb40b -resource-dir /home/admin1/Music/wasi-sdk/build/sysroot/install/wasi-resource-dir -O2 -g -DNDEBUG --target=wasm32-wasi -fno-trapping-math -Wall -Wextra -Werror -Wno-null-pointer-arithmetic -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-unused-function -Wno-ignored-attributes -Wno-missing-braces -Wno-ignored-pragmas -Wno-unused-but-set-variable -Wno-unknown-warning-option -mthread-model single -isystem "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/include/wasm32-wasi" "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/share/wasm32-wasi/include-all.c" \
    -isystem /home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/include/wasm32-wasi \
    -std=gnu17 \
    -E -dM -Wno-\#warnings \
    -D_ALL_SOURCE \
    -U__llvm__ \
    -U__clang__ \
    -U__clang_major__ \
    -U__clang_minor__ \
    -U__clang_patchlevel__ \
    -U__clang_version__ \
    -U__clang_literal_encoding__ \
    -U__clang_wide_literal_encoding__ \
    -U__wasm_mutable_globals__ \
    -U__wasm_sign_ext__ \
    -U__wasm_multivalue__ \
    -U__wasm_reference_types__ \
    -U__GNUC__ \
    -U__GNUC_MINOR__ \
    -U__GNUC_PATCHLEVEL__ \
    -U__VERSION__ \
    -U__NO_MATH_ERRNO__ \
    -U__BITINT_MAXWIDTH__ \
    -U__FLT_EVAL_METHOD__ -Wno-builtin-macro-redefined \
    | sed -e 's/__[[:upper:][:digit:]]*_ATOMIC_\([[:upper:][:digit:]_]*\)_LOCK_FREE/__compiler_ATOMIC_\1_LOCK_FREE/' \
    | sed -e 's/__GNUC_VA_LIST $/__GNUC_VA_LIST 1/' \
    | grep -v '^#define __\(BOOL\|INT_\(LEAST\|FAST\)\(8\|16\|32\|64\)\|INT\|LONG\|LLONG\|SHRT\)_WIDTH__' \
    | grep -v '^#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_\(1\|2\|4\|8\)' \
    | grep -v '^#define __FPCLASS_' \
    | grep -v '^#define __FLT128_' \
    | grep -v '^#define __MEMORY_SCOPE_' \
    | grep -v '^#define __GCC_\(CON\|DE\)STRUCTIVE_SIZE' \
    | grep -v '^#define __STDC_EMBED_' \
    | grep -v '^#define __\(DBL\|FLT\|LDBL\)_NORM_MAX__' \
    | grep -v '^#define NDEBUG' \
    | grep -v '^#define __OPTIMIZE__' \
    | grep -v '^#define assert' \
    | grep -v '^#define __NO_INLINE__' \
    > "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/share/wasm32-wasi/predefined-macros.txt"
# Check that the computed metadata matches the expected metadata.
# This ignores whitespace because on Windows the output has CRLF line endings.
diff -wur "expected/wasm32-wasip1" "/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot/share/wasm32-wasi"
make: Leaving directory '/home/admin1/Music/wasi-sdk/build/sysroot/wasi-libc-wasm32-wasi'
FAILED: wasi-libc-wasm32-wasi-build-prefix/src/wasi-libc-wasm32-wasi-build-stamp/wasi-libc-wasm32-wasi-build-build /home/admin1/Music/wasi-sdk/build/sysroot/wasi-libc-wasm32-wasi-build-prefix/src/wasi-libc-wasm32-wasi-build-stamp/wasi-libc-wasm32-wasi-build-build 
cd /home/admin1/Music/wasi-sdk/build/sysroot/wasi-libc-wasm32-wasi-build-prefix/src/wasi-libc-wasm32-wasi-build-build && /usr/bin/make -j8 -C /home/admin1/Music/wasi-sdk/build/sysroot/wasi-libc-wasm32-wasi CC=/home/admin1/Music/wasi-sdk/build/install/bin/clang AR=/home/admin1/Music/wasi-sdk/build/install/bin/llvm-ar NM=/home/admin1/Music/wasi-sdk/build/install/bin/llvm-nm SYSROOT=/home/admin1/Music/wasi-sdk/build/sysroot/install/share/wasi-sysroot "EXTRA_CFLAGS= -fdebug-prefix-map=/home/admin1/Music/wasi-sdk=wasisdk://v24.2gb416e2beb40b -resource-dir /home/admin1/Music/wasi-sdk/build/sysroot/install/wasi-resource-dir -O2 -g -DNDEBUG" TARGET_TRIPLE=wasm32-wasi default libc_so && /opt/cmake-3.26.0/bin/cmake -E touch /home/admin1/Music/wasi-sdk/build/sysroot/wasi-libc-wasm32-wasi-build-prefix/src/wasi-libc-wasm32-wasi-build-stamp/wasi-libc-wasm32-wasi-build-build
ninja: build stopped: subcommand failed.

I would like to use below functions for my appalication which sysbennch benchmark. i am trying to compile sysbench with wasi-sdk24. its compiled properly but when i am running with WAMR its giving errors like

admin1@admin1-VivoBook-ASUSLaptop-X515EA-P1511CEA:~/sysbench_main$ /home/admin1/Documents/wasm-micro-runtime/product-mini/platforms/linux/build/iwasm --max-threads=64 src/sysbench_with_setjmp_errors  cpu --threads=10 --cpu-max-prime=100000 run
[14:03:18:939 - 7B717C342740]: warning: failed to link import function (env, __wasm_longjmp)
[14:03:18:939 - 7B717C342740]: warning: failed to link import function (env, saveSetjmp)
[14:03:18:939 - 7B717C342740]: warning: failed to link import function (env, getTempRet0)
[14:03:18:939 - 7B717C342740]: warning: failed to link import function (env, testSetjmp)

so to solve these errors i need to use llvm-19 version thats why i have included llvm-19 source code in wasi-sdk-24 version. There i am getting above errors.

is it possible to solve the errors what i am getting.

Thanks in advance.

yamt commented 3 months ago

see https://github.com/WebAssembly/wasi-libc/pull/526 https://github.com/WebAssembly/wasi-sdk/pull/474

maybe you can just use the CI asserts from https://github.com/WebAssembly/wasi-sdk/pull/474

subhakr commented 3 months ago

see WebAssembly/wasi-libc#526 #474

maybe you can just use the CI asserts from #474

sorry to bother you, i am unable to understand those conversations. can you help me to solve this errors in this issue it self.

thanks in advance.

subhakr commented 3 months ago

see WebAssembly/wasi-libc#526 #474

maybe you can just use the CI asserts from #474

may i know form #526 and #474 will my issue resolve. if it is , then i will try to replicate that procedure only.

Thanks in advance.

yamt commented 3 months ago

if you don't understand, i guess it's easier for you to wait a release with llvm 19. i guess it won't be too far away.