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

Instructions for compiling libclang_rt.builtins-wasm32.a? #36

Open
TerrorJack opened this issue May 22, 2019 · 5 comments
Open

Instructions for compiling libclang_rt.builtins-wasm32.a? #36

TerrorJack opened this issue May 22, 2019 · 5 comments

Comments

@TerrorJack
Copy link
Contributor

I'm trying to use clang-9 to compile and use wasi-sysroot, but additionally the libclang_rt.builtins-wasm32.a file is required to link into the final wasm module. It is not obvious how to build this file without building the llvm/clang submodules first, so it would be much appreciated if you can add relevant instructions. Thanks a lot!

@eric-nubix
Copy link

@TerrorJack Did you ever find out how to build libclang_rt.builtins-wasm32.a from source?

@sbc100
Copy link
Member

sbc100 commented Sep 20, 2021

libclang_rt.builtins-wasm32.a built a build of llvm's compiler-rt.

You can see how we build it as part of wasi-sdk here:

wasi-sdk/Makefile

Lines 98 to 124 in 1a95329

build/compiler-rt.BUILT: build/llvm.BUILT build/wasi-libc.BUILT
# Do the build, and install it.
mkdir -p build/compiler-rt
cd build/compiler-rt && cmake -G Ninja \
-DCMAKE_C_COMPILER_WORKS=ON \
-DCMAKE_CXX_COMPILER_WORKS=ON \
-DCMAKE_AR=$(BUILD_PREFIX)/bin/ar \
-DCMAKE_MODULE_PATH=$(ROOT_DIR)/cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_TOOLCHAIN_FILE=$(ROOT_DIR)/wasi-sdk.cmake \
-DCOMPILER_RT_BAREMETAL_BUILD=On \
-DCOMPILER_RT_BUILD_XRAY=OFF \
-DCOMPILER_RT_INCLUDE_TESTS=OFF \
-DCOMPILER_RT_HAS_FPIC_FLAG=OFF \
-DCOMPILER_RT_ENABLE_IOS=OFF \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=On \
-DWASI_SDK_PREFIX=$(BUILD_PREFIX) \
-DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP) --sysroot=$(BUILD_PREFIX)/share/wasi-sysroot" \
-DLLVM_CONFIG_PATH=$(ROOT_DIR)/build/llvm/bin/llvm-config \
-DCOMPILER_RT_OS_DIR=wasi \
-DCMAKE_INSTALL_PREFIX=$(PREFIX)/lib/clang/$(CLANG_VERSION)/ \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
$(LLVM_PROJ_DIR)/compiler-rt/lib/builtins
DESTDIR=$(DESTDIR) ninja $(NINJA_FLAGS) -v -C build/compiler-rt install
# Install clang-provided headers.
cp -R $(ROOT_DIR)/build/llvm/lib/clang $(BUILD_PREFIX)/lib/
touch build/compiler-rt.BUILT

@sbc100
Copy link
Member

sbc100 commented Sep 20, 2021

If you don't want to build it from source you can download a prebuilt version of this library from one of the releases. e.g. https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-12

Then can most likely just copy this library into ./lib/clang/9.0.0/lib/wasi/ inside your existing clang installation.

@turbolent
Copy link

turbolent commented Oct 9, 2022

Is it possible to build libclang_rt.builtins-wasm32.a with -phread?

@abrown
Copy link
Collaborator

abrown commented May 22, 2023

@turbolent, you mean build it manually or distribute it as a part of the release artifacts?

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

No branches or pull requests

5 participants