Makefile refactoring. (#106)

These changes are factored out of #89. NFC.
lto
Dan Gohman 5 years ago committed by GitHub
parent b80771e767
commit 17315135ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -20,7 +20,7 @@ clean:
build/llvm.BUILT: build/llvm.BUILT:
mkdir -p build/llvm mkdir -p build/llvm
cd build/llvm; cmake -G Ninja \ cmake -B build/llvm -G Ninja \
-DCMAKE_BUILD_TYPE=MinSizeRel \ -DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INSTALL_PREFIX=$(PREFIX) \ -DCMAKE_INSTALL_PREFIX=$(PREFIX) \
-DLLVM_TARGETS_TO_BUILD=WebAssembly \ -DLLVM_TARGETS_TO_BUILD=WebAssembly \
@ -58,8 +58,9 @@ build/wasi-libc.BUILT: build/llvm.BUILT
touch build/wasi-libc.BUILT touch build/wasi-libc.BUILT
build/compiler-rt.BUILT: build/llvm.BUILT build/compiler-rt.BUILT: build/llvm.BUILT
# Do the build, and install it.
mkdir -p build/compiler-rt mkdir -p build/compiler-rt
cd build/compiler-rt; cmake -G Ninja \ cmake -B build/compiler-rt -G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_TOOLCHAIN_FILE=$(ROOT_DIR)/wasi-sdk.cmake \ -DCMAKE_TOOLCHAIN_FILE=$(ROOT_DIR)/wasi-sdk.cmake \
-DCOMPILER_RT_BAREMETAL_BUILD=On \ -DCOMPILER_RT_BAREMETAL_BUILD=On \
@ -76,12 +77,12 @@ build/compiler-rt.BUILT: build/llvm.BUILT
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
$(LLVM_PROJ_DIR)/compiler-rt/lib/builtins $(LLVM_PROJ_DIR)/compiler-rt/lib/builtins
ninja $(NINJA_FLAGS) -v -C build/compiler-rt install ninja $(NINJA_FLAGS) -v -C build/compiler-rt install
# Install clang-provided headers.
cp -R $(ROOT_DIR)/build/llvm/lib/clang $(PREFIX)/lib/ cp -R $(ROOT_DIR)/build/llvm/lib/clang $(PREFIX)/lib/
touch build/compiler-rt.BUILT touch build/compiler-rt.BUILT
build/libcxx.BUILT: build/llvm.BUILT build/compiler-rt.BUILT build/wasi-libc.BUILT # Flags for libcxx.
mkdir -p build/libcxx LIBCXX_CMAKE_FLAGS = \
cd build/libcxx; cmake -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=$(ROOT_DIR)/wasi-sdk.cmake \ -DCMAKE_TOOLCHAIN_FILE=$(ROOT_DIR)/wasi-sdk.cmake \
-DLLVM_CONFIG_PATH=$(ROOT_DIR)/build/llvm/bin/llvm-config \ -DLLVM_CONFIG_PATH=$(ROOT_DIR)/build/llvm/bin/llvm-config \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
@ -99,18 +100,24 @@ build/libcxx.BUILT: build/llvm.BUILT build/compiler-rt.BUILT build/wasi-libc.BUI
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=$(LLVM_PROJ_DIR)/libcxxabi/include \ -DLIBCXX_CXX_ABI_INCLUDE_PATHS=$(LLVM_PROJ_DIR)/libcxxabi/include \
-DLIBCXX_HAS_MUSL_LIBC:BOOL=ON \ -DLIBCXX_HAS_MUSL_LIBC:BOOL=ON \
-DLIBCXX_ABI_VERSION=2 \ -DLIBCXX_ABI_VERSION=2 \
-DLIBCXX_LIBDIR_SUFFIX=/wasm32-wasi \
-DWASI_SDK_PREFIX=$(PREFIX) \ -DWASI_SDK_PREFIX=$(PREFIX) \
--debug-trycompile
build/libcxx.BUILT: build/llvm.BUILT build/compiler-rt.BUILT build/wasi-libc.BUILT
# Do the build.
mkdir -p build/libcxx
cmake -B build/libcxx -G Ninja $(LIBCXX_CMAKE_FLAGS) \
-DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP)" \ -DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP)" \
-DCMAKE_CXX_FLAGS="$(DEBUG_PREFIX_MAP)" \ -DCMAKE_CXX_FLAGS="$(DEBUG_PREFIX_MAP)" \
--debug-trycompile \ -DLIBCXX_LIBDIR_SUFFIX=/wasm32-wasi \
$(LLVM_PROJ_DIR)/libcxx $(LLVM_PROJ_DIR)/libcxx
ninja $(NINJA_FLAGS) -v -C build/libcxx
# Do the install.
ninja $(NINJA_FLAGS) -v -C build/libcxx install ninja $(NINJA_FLAGS) -v -C build/libcxx install
touch build/libcxx.BUILT touch build/libcxx.BUILT
build/libcxxabi.BUILT: build/libcxx.BUILT build/llvm.BUILT # Flags for libcxxabi.
mkdir -p build/libcxxabi LIBCXXABI_CMAKE_FLAGS = \
cd build/libcxxabi; cmake -G Ninja \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DCMAKE_CXX_COMPILER_WORKS=ON \ -DCMAKE_CXX_COMPILER_WORKS=ON \
-DCMAKE_C_COMPILER_WORKS=ON \ -DCMAKE_C_COMPILER_WORKS=ON \
@ -130,13 +137,20 @@ build/libcxxabi.BUILT: build/libcxx.BUILT build/llvm.BUILT
-DLIBCXXABI_LIBCXX_INCLUDES=$(PREFIX)/share/wasi-sysroot/include/c++/v1 \ -DLIBCXXABI_LIBCXX_INCLUDES=$(PREFIX)/share/wasi-sysroot/include/c++/v1 \
-DLLVM_CONFIG_PATH=$(ROOT_DIR)/build/llvm/bin/llvm-config \ -DLLVM_CONFIG_PATH=$(ROOT_DIR)/build/llvm/bin/llvm-config \
-DCMAKE_TOOLCHAIN_FILE=$(ROOT_DIR)/wasi-sdk.cmake \ -DCMAKE_TOOLCHAIN_FILE=$(ROOT_DIR)/wasi-sdk.cmake \
-DLIBCXXABI_LIBDIR_SUFFIX=/wasm32-wasi \
-DWASI_SDK_PREFIX=$(PREFIX) \ -DWASI_SDK_PREFIX=$(PREFIX) \
-DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP) -I$(PREFIX)/share/wasi-sysroot/include" \
-DCMAKE_CXX_FLAGS="$(DEBUG_PREFIX_MAP) -I$(PREFIX)/share/wasi-sysroot/include/c++/v1" \
-DUNIX:BOOL=ON \ -DUNIX:BOOL=ON \
--debug-trycompile \ --debug-trycompile
build/libcxxabi.BUILT: build/libcxx.BUILT build/llvm.BUILT
# Do the build.
mkdir -p build/libcxxabi
cmake -B build/libcxxabi -G Ninja $(LIBCXXABI_CMAKE_FLAGS) \
-DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP)" \
-DCMAKE_CXX_FLAGS="$(DEBUG_PREFIX_MAP)" \
-DLIBCXXABI_LIBDIR_SUFFIX=/wasm32-wasi \
$(LLVM_PROJ_DIR)/libcxxabi $(LLVM_PROJ_DIR)/libcxxabi
ninja $(NINJA_FLAGS) -v -C build/libcxxabi
# Do the install.
ninja $(NINJA_FLAGS) -v -C build/libcxxabi install ninja $(NINJA_FLAGS) -v -C build/libcxxabi install
touch build/libcxxabi.BUILT touch build/libcxxabi.BUILT

Loading…
Cancel
Save