1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/wasi-compiler-rt/wasi-compiler-rt.conf
3 # Copyright (C) 2022 - 2024 The T2 SDE Project
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2.
10 # --- T2-COPYRIGHT-NOTE-END ---
14 # TODO: sync w/ wasi-libc
15 [ $prefix_auto = 1 ] && prefix=opt/wasi && set_confopt
21 tar $taropt `match_source_file -p llvm-cmake-$ver`
24 hook_add preconf 5 prepare_sources
26 . $base/package/*/*/wasi.in
28 export CC=clang CXX=clang++ # LD=clang
29 export CFLAGS="-fno-exceptions --sysroot=$root/opt/wasi"
30 export CXXFLAGS="-fno-exceptions --sysroot=$root/opt/wasi"
34 var_append cmakeopt " " "-DUNIX=ON \
35 -DCMAKE_TOOLCHAIN_FILE=$confdir/../wasi-libc/wasi-sdk.cmake \
36 -DCMAKE_C_COMPILER_WORKS=ON -DCMAKE_CXX_COMPILER_WORKS=ON \
37 -DCMAKE_STAGING_PREFIX=/opt/wasi"
39 var_append cmakeopt " " "-DCOMPILER_RT_BAREMETAL_BUILD=ON \
40 -DCOMPILER_RT_INCLUDE_TESTS=OFF \
41 -DCOMPILER_RT_HAS_FPIC_FLAG=OFF \
42 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
43 -DCOMPILER_RT_OS_DIR=wasi"
45 # TODO: why does the camke module seach only fail for native builds?
46 atstage native && var_append cmakeopt " " -DLLVM_CMAKE_DIR=$(pkgprefix libdir llvm)/cmake
49 eval cmake -B objs $cmakeopt compiler-rt-*/lib/builtins
55 mkdir -p $root/usr/${libdir##*/}/clang/$clangver/lib/wasi/
56 cp -arv $root/$prefix/lib/wasi/libclang_rt.builtins-wasm32.a $root/usr/${libdir##*/}/clang/$clangver/lib/wasi/
58 if ! atstage native; then
59 mkdir -p $root/TOOLCHAIN/cross/lib/clang/$clangver/lib/wasi/
60 cp -arv $root/$prefix/lib/wasi/libclang_rt.builtins-wasm32.a \
61 $root/TOOLCHAIN/cross/lib/clang/$clangver/lib/wasi/
64 hook_add inmake 5 build_compiler_rt