Convert makefiles to build LLVM/compiler-rt with CMake
This commit is contained in:
parent
fe96928d7d
commit
59db95b499
@ -19,6 +19,7 @@ Read ["Installing Rust"] from [The Book].
|
||||
* `g++` 4.7 or later or `clang++` 3.x
|
||||
* `python` 2.7 (but not 3.x)
|
||||
* GNU `make` 3.81 or later
|
||||
* `cmake` 2.8.8 or later
|
||||
* `curl`
|
||||
* `git`
|
||||
|
||||
|
316
configure
vendored
316
configure
vendored
@ -775,6 +775,9 @@ probe CFG_BISON bison
|
||||
probe CFG_GDB gdb
|
||||
probe CFG_LLDB lldb
|
||||
|
||||
# For building LLVM
|
||||
probe_need CFG_CMAKE cmake
|
||||
|
||||
# On MacOS X, invoking `javac` pops up a dialog if the JDK is not
|
||||
# installed. Since `javac` is only used if `antlr4` is available,
|
||||
# probe for it only in this case.
|
||||
@ -1233,9 +1236,6 @@ $ pacman -R python2 && pacman -S mingw-w64-x86_64-python2
|
||||
"
|
||||
fi
|
||||
|
||||
# MSVC requires cmake because that's how we're going to build LLVM
|
||||
probe_need CFG_CMAKE cmake
|
||||
|
||||
# There are three builds of cmake on windows: MSVC, MinGW and Cygwin
|
||||
# The Cygwin build does not have generators for Visual Studio, so
|
||||
# detect that here and error.
|
||||
@ -1508,27 +1508,16 @@ do
|
||||
elif [ -z $CFG_LLVM_ROOT ]
|
||||
then
|
||||
LLVM_BUILD_DIR=${CFG_BUILD_DIR}$t/llvm
|
||||
if [ -n "$CFG_DISABLE_OPTIMIZE_LLVM" ]
|
||||
then
|
||||
LLVM_DBG_OPTS="--enable-debug-symbols --disable-optimized"
|
||||
# Just use LLVM straight from its build directory to
|
||||
# avoid 'make install' time
|
||||
LLVM_INST_DIR=$LLVM_BUILD_DIR/Debug
|
||||
else
|
||||
LLVM_DBG_OPTS="--enable-optimized"
|
||||
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release
|
||||
fi
|
||||
if [ -z "$CFG_ENABLE_LLVM_ASSERTIONS" ]
|
||||
then
|
||||
LLVM_ASSERTION_OPTS="--disable-assertions"
|
||||
else
|
||||
LLVM_ASSERTION_OPTS="--enable-assertions"
|
||||
|
||||
# Apparently even if we request assertions be enabled for MSVC,
|
||||
# LLVM's CMake build system ignore this and outputs in `Release`
|
||||
# anyway.
|
||||
if [ ${is_msvc} -eq 0 ]; then
|
||||
LLVM_INST_DIR=${LLVM_INST_DIR}+Asserts
|
||||
LLVM_INST_DIR=$LLVM_BUILD_DIR
|
||||
# For some crazy reason the MSVC output dir is different than Unix
|
||||
if [ ${is_msvc} -ne 0 ]; then
|
||||
if [ -n "$CFG_DISABLE_OPTIMIZE_LLVM" ]
|
||||
then
|
||||
# Just use LLVM straight from its build directory to
|
||||
# avoid 'make install' time
|
||||
LLVM_INST_DIR=$LLVM_BUILD_DIR/Debug
|
||||
else
|
||||
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release
|
||||
fi
|
||||
fi
|
||||
else
|
||||
@ -1586,88 +1575,60 @@ do
|
||||
err "can only build LLVM for x86 platforms"
|
||||
;;
|
||||
esac
|
||||
CFG_CMAKE_GENERATOR=$generator
|
||||
putvar CFG_CMAKE_GENERATOR
|
||||
else
|
||||
generator="Unix Makefiles"
|
||||
fi
|
||||
CFG_CMAKE_GENERATOR=$generator
|
||||
putvar CFG_CMAKE_GENERATOR
|
||||
|
||||
if [ ${do_reconfigure} -ne 0 ] && [ ${is_msvc} -ne 0 ]
|
||||
then
|
||||
msg "configuring LLVM for $t with cmake"
|
||||
msg "configuring LLVM for $t"
|
||||
|
||||
CMAKE_ARGS="-DLLVM_INCLUDE_TESTS=OFF"
|
||||
if [ -n "$CFG_DISABLE_OPTIMIZE_LLVM" ]; then
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug"
|
||||
else
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release"
|
||||
fi
|
||||
if [ -z "$CFG_ENABLE_LLVM_ASSERTIONS" ]
|
||||
then
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_ASSERTIONS=OFF"
|
||||
else
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_ASSERTIONS=ON"
|
||||
fi
|
||||
LLVM_CFLAGS_32=""
|
||||
LLVM_CXXFLAGS_32=""
|
||||
LLVM_LDFLAGS_32=""
|
||||
LLVM_CFLAGS_64=""
|
||||
LLVM_CXXFLAGS_64=""
|
||||
LLVM_LDFLAGS_64=""
|
||||
|
||||
msg "configuring LLVM with:"
|
||||
msg "$CMAKE_ARGS"
|
||||
case "$CFG_CC" in
|
||||
("ccache clang")
|
||||
LLVM_CXX_32="ccache"
|
||||
LLVM_CC_32="ccache"
|
||||
LLVM_CXX_32_ARG1="clang++"
|
||||
LLVM_CC_32_ARG1="clang"
|
||||
LLVM_CFLAGS_32="-Qunused-arguments"
|
||||
LLVM_CXXFLAGS_32="-Qunused-arguments"
|
||||
|
||||
(cd $LLVM_BUILD_DIR && "$CFG_CMAKE" $CFG_LLVM_SRC_DIR \
|
||||
-G "$CFG_CMAKE_GENERATOR" \
|
||||
$CMAKE_ARGS)
|
||||
need_ok "LLVM cmake configure failed"
|
||||
fi
|
||||
|
||||
if [ ${do_reconfigure} -ne 0 ] && [ ${is_msvc} -eq 0 ]
|
||||
then
|
||||
# LLVM's configure doesn't recognize the new Windows triples yet
|
||||
gnu_t=$(to_gnu_triple $t)
|
||||
|
||||
msg "configuring LLVM for $gnu_t"
|
||||
|
||||
LLVM_TARGETS="--enable-targets=x86,x86_64,arm,aarch64,mips,powerpc"
|
||||
LLVM_BUILD="--build=$gnu_t"
|
||||
LLVM_HOST="--host=$gnu_t"
|
||||
LLVM_TARGET="--target=$gnu_t"
|
||||
|
||||
# Disable unused LLVM features
|
||||
LLVM_OPTS="$LLVM_DBG_OPTS $LLVM_ASSERTION_OPTS --disable-docs --enable-bindings=none"
|
||||
# Disable term-info, linkage of which comes in multiple forms,
|
||||
# making our snapshots incompatible (#9334)
|
||||
LLVM_OPTS="$LLVM_OPTS --disable-terminfo"
|
||||
# Try to have LLVM pull in as few dependencies as possible (#9397)
|
||||
LLVM_OPTS="$LLVM_OPTS --disable-zlib --disable-libffi"
|
||||
|
||||
# Use win32 native thread/lock apis instead of pthread wrapper.
|
||||
# (llvm's configure tries to find pthread first, so we have to disable it explicitly.)
|
||||
# Also note that pthreads works badly on mingw-w64 systems: #8996
|
||||
case "$CFG_BUILD" in
|
||||
(*-windows-gnu)
|
||||
LLVM_OPTS="$LLVM_OPTS --disable-pthreads"
|
||||
LLVM_CXX_64="ccache"
|
||||
LLVM_CC_64="ccache"
|
||||
LLVM_CXX_64_ARG1="clang++"
|
||||
LLVM_CC_64_ARG1="clang"
|
||||
LLVM_CFLAGS_64="-Qunused-arguments"
|
||||
LLVM_CXXFLAGS_64="-Qunused-arguments"
|
||||
;;
|
||||
esac
|
||||
("clang")
|
||||
LLVM_CXX_32="clang++"
|
||||
LLVM_CC_32="clang"
|
||||
LLVM_CFLAGS_32="-Qunused-arguments"
|
||||
LLVM_CXXFLAGS_32="-Qunused-arguments"
|
||||
|
||||
case "$CFG_CC" in
|
||||
("ccache clang")
|
||||
LLVM_CXX_32="ccache clang++ -Qunused-arguments"
|
||||
LLVM_CC_32="ccache clang -Qunused-arguments"
|
||||
|
||||
LLVM_CXX_64="ccache clang++ -Qunused-arguments"
|
||||
LLVM_CC_64="ccache clang -Qunused-arguments"
|
||||
LLVM_CXX_64="clang++"
|
||||
LLVM_CC_64="clang"
|
||||
LLVM_CFLAGS_64="-Qunused-arguments"
|
||||
LLVM_CXXFLAGS_64="-Qunused-arguments"
|
||||
;;
|
||||
("clang")
|
||||
LLVM_CXX_32="clang++ -Qunused-arguments"
|
||||
LLVM_CC_32="clang -Qunused-arguments"
|
||||
("ccache gcc")
|
||||
LLVM_CXX_32="ccache"
|
||||
LLVM_CC_32="ccache"
|
||||
LLVM_CXX_32_ARG1="clang++"
|
||||
LLVM_CC_32_ARG1="clang"
|
||||
|
||||
LLVM_CXX_64="clang++ -Qunused-arguments"
|
||||
LLVM_CC_64="clang -Qunused-arguments"
|
||||
LLVM_CXX_64="ccache"
|
||||
LLVM_CC_64="ccache"
|
||||
LLVM_CXX_64_ARG1="g++"
|
||||
LLVM_CC_64_ARG1="gcc"
|
||||
;;
|
||||
("ccache gcc")
|
||||
LLVM_CXX_32="ccache g++"
|
||||
LLVM_CC_32="ccache gcc"
|
||||
|
||||
LLVM_CXX_64="ccache g++"
|
||||
LLVM_CC_64="ccache gcc"
|
||||
;;
|
||||
("gcc")
|
||||
("gcc")
|
||||
LLVM_CXX_32="g++"
|
||||
LLVM_CC_32="gcc"
|
||||
|
||||
@ -1675,7 +1636,7 @@ do
|
||||
LLVM_CC_64="gcc"
|
||||
;;
|
||||
|
||||
(*)
|
||||
(*)
|
||||
msg "inferring LLVM_CXX/CC from CXX/CC = $CXX/$CC"
|
||||
if [ -n "$CFG_ENABLE_CCACHE" ]
|
||||
then
|
||||
@ -1684,11 +1645,15 @@ do
|
||||
err "ccache requested but not found"
|
||||
fi
|
||||
|
||||
LLVM_CXX_32="ccache $CXX"
|
||||
LLVM_CC_32="ccache $CC"
|
||||
LLVM_CXX_32="ccache"
|
||||
LLVM_CC_32="ccache"
|
||||
LLVM_CXX_32_ARG1="$CXX"
|
||||
LLVM_CC_32_ARG1="$CC"
|
||||
|
||||
LLVM_CXX_64="ccache $CXX"
|
||||
LLVM_CC_64="ccache $CC"
|
||||
LLVM_CXX_64="ccache"
|
||||
LLVM_CC_64="ccache"
|
||||
LLVM_CXX_64_ARG1="$CXX"
|
||||
LLVM_CC_64_ARG1="$CC"
|
||||
else
|
||||
LLVM_CXX_32="$CXX"
|
||||
LLVM_CC_32="$CC"
|
||||
@ -1698,86 +1663,101 @@ do
|
||||
fi
|
||||
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
|
||||
case "$CFG_CPUTYPE" in
|
||||
(x86*)
|
||||
LLVM_CXX_32="$LLVM_CXX_32 -m32"
|
||||
LLVM_CC_32="$LLVM_CC_32 -m32"
|
||||
case "$CFG_CPUTYPE" in
|
||||
(x86*)
|
||||
LLVM_CFLAGS_32="$LLVM_CFLAGS_32 -m32"
|
||||
LLVM_CXXFLAGS_32="$LLVM_CXXFLAGS_32 -m32"
|
||||
LLVM_LDFLAGS_32="$LLVM_LDFLAGS_32 -m32"
|
||||
;;
|
||||
esac
|
||||
|
||||
LLVM_CFLAGS_32="-m32"
|
||||
LLVM_CXXFLAGS_32="-m32"
|
||||
LLVM_LDFLAGS_32="-m32"
|
||||
if echo $t | grep -q x86_64
|
||||
then
|
||||
LLVM_CXX=$LLVM_CXX_64
|
||||
LLVM_CC=$LLVM_CC_64
|
||||
LLVM_CXX_ARG1=$LLVM_CXX_64_ARG1
|
||||
LLVM_CC_ARG1=$LLVM_CC_64_ARG1
|
||||
LLVM_CFLAGS=$LLVM_CFLAGS_64
|
||||
LLVM_CXXFLAGS=$LLVM_CXXFLAGS_64
|
||||
LLVM_LDFLAGS=$LLVM_LDFLAGS_64
|
||||
else
|
||||
LLVM_CXX=$LLVM_CXX_32
|
||||
LLVM_CC=$LLVM_CC_32
|
||||
LLVM_CXX_ARG1=$LLVM_CXX_32_ARG1
|
||||
LLVM_CC_ARG1=$LLVM_CC_32_ARG1
|
||||
LLVM_CFLAGS=$LLVM_CFLAGS_32
|
||||
LLVM_CXXFLAGS=$LLVM_CXXFLAGS_32
|
||||
LLVM_LDFLAGS=$LLVM_LDFLAGS_32
|
||||
fi
|
||||
|
||||
LLVM_CFLAGS_64=""
|
||||
LLVM_CXXFLAGS_64=""
|
||||
LLVM_LDFLAGS_64=""
|
||||
if [ "$CFG_USING_LIBCPP" != "0" ]; then
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_LIBCXX=ON"
|
||||
fi
|
||||
|
||||
LLVM_CXX_32="$LLVM_CXX_32 -m32"
|
||||
LLVM_CC_32="$LLVM_CC_32 -m32"
|
||||
;;
|
||||
# Turn off things we don't need
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_INCLUDE_TESTS=OFF"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_INCLUDE_EXAMPLES=OFF"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_INCLUDE_DOCS=OFF"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_ZLIB=OFF"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DWITH_POLY=OFF"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_TERMINFO=OFF"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_LIBEDIT=OFF"
|
||||
|
||||
(*)
|
||||
LLVM_CFLAGS_32=""
|
||||
LLVM_CXXFLAGS_32=""
|
||||
LLVM_LDFLAGS_32=""
|
||||
arch="$(echo "$t" | cut -d - -f 1)"
|
||||
|
||||
LLVM_CFLAGS_64=""
|
||||
LLVM_CXXFLAGS_64=""
|
||||
LLVM_LDFLAGS_64=""
|
||||
;;
|
||||
esac
|
||||
if [ "$arch" = i686 ]; then
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_BUILD_32_BITS=ON"
|
||||
fi
|
||||
|
||||
if echo $t | grep -q x86_64
|
||||
then
|
||||
LLVM_CXX=$LLVM_CXX_64
|
||||
LLVM_CC=$LLVM_CC_64
|
||||
LLVM_CFLAGS=$LLVM_CFLAGS_64
|
||||
LLVM_CXXFLAGS=$LLVM_CXXFLAGS_64
|
||||
LLVM_LDFLAGS=$LLVM_LDFLAGS_64
|
||||
else
|
||||
LLVM_CXX=$LLVM_CXX_32
|
||||
LLVM_CC=$LLVM_CC_32
|
||||
LLVM_CFLAGS=$LLVM_CFLAGS_32
|
||||
LLVM_CXXFLAGS=$LLVM_CXXFLAGS_32
|
||||
LLVM_LDFLAGS=$LLVM_LDFLAGS_32
|
||||
if [ "$t" != "$CFG_BUILD" ]; then
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CROSSCOMPILING=True"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_TARGET_ARCH=$arch"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_TABLEGEN=$LLVM_INST_DIR/bin/llvm-tablegen"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=$t"
|
||||
fi
|
||||
|
||||
# MSVC handles compiler business itself
|
||||
if [ ${is_msvc} -eq 0 ]; then
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER=$LLVM_CC"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_COMPILER=$LLVM_CXX"
|
||||
CMAKE_ARGS="$CMAKE_ARGS '-DCMAKE_C_FLAGS=$LLVM_CFLAGS'"
|
||||
CMAKE_ARGS="$CMAKE_ARGS '-DCMAKE_CXX_FLAGS=$LLVM_CXXFLAGS'"
|
||||
if [ -n "$LLVM_CC_ARG1" ]; then
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER_ARG1=$LLVM_CC_ARG1"
|
||||
fi
|
||||
|
||||
CXX=$LLVM_CXX
|
||||
CC=$LLVM_CC
|
||||
CFLAGS="$CFLAGS $LLVM_CFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $LLVM_CXXFLAGS"
|
||||
LDFLAGS="$LDFLAGS $LLVM_LDFLAGS"
|
||||
|
||||
if [ "$CFG_USING_LIBCPP" != "0" ]; then
|
||||
LLVM_OPTS="$LLVM_OPTS --enable-libcpp"
|
||||
if [ -n "$LLVM_CXX_ARG1" ]; then
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_COMPILER_ARG1=$LLVM_CXX_ARG1"
|
||||
fi
|
||||
# FIXME: What about LDFLAGS?
|
||||
fi
|
||||
|
||||
LLVM_FLAGS="$LLVM_TARGETS $LLVM_OPTS $LLVM_BUILD \
|
||||
$LLVM_HOST $LLVM_TARGET --with-python=$CFG_PYTHON"
|
||||
if [ -n "$CFG_DISABLE_OPTIMIZE_LLVM" ]; then
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug"
|
||||
else
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release"
|
||||
fi
|
||||
if [ -z "$CFG_ENABLE_LLVM_ASSERTIONS" ]
|
||||
then
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_ASSERTIONS=OFF"
|
||||
else
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_ASSERTIONS=ON"
|
||||
fi
|
||||
|
||||
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_TARGETS_TO_BUILD='X86;ARM;AArch64;Mips;PowerPC'"
|
||||
CMAKE_ARGS="$CMAKE_ARGS -G '$CFG_CMAKE_GENERATOR'"
|
||||
CMAKE_ARGS="$CMAKE_ARGS $CFG_LLVM_SRC_DIR"
|
||||
|
||||
if [ ${do_reconfigure} -ne 0 ]
|
||||
then
|
||||
msg "configuring LLVM for $t with cmake"
|
||||
|
||||
msg "configuring LLVM with:"
|
||||
msg "$LLVM_FLAGS"
|
||||
msg "$CMAKE_ARGS"
|
||||
|
||||
export CXX
|
||||
export CC
|
||||
export CFLAGS
|
||||
export CXXFLAGS
|
||||
export LDFLAGS
|
||||
|
||||
cd $LLVM_BUILD_DIR
|
||||
case $CFG_SRC_DIR in
|
||||
/* | [a-z]:* | [A-Z]:*)
|
||||
${CFG_LLVM_SRC_DIR}configure $LLVM_FLAGS
|
||||
;;
|
||||
*)
|
||||
${CFG_BUILD_DIR}${CFG_LLVM_SRC_DIR}configure \
|
||||
$LLVM_FLAGS
|
||||
;;
|
||||
esac
|
||||
need_ok "LLVM configure failed"
|
||||
|
||||
cd $CFG_BUILD_DIR
|
||||
(cd $LLVM_BUILD_DIR && eval "$CFG_CMAKE" $CMAKE_ARGS)
|
||||
need_ok "LLVM cmake configure failed"
|
||||
fi
|
||||
|
||||
# Construct variables for LLVM build and install directories for
|
||||
|
@ -1,6 +1,6 @@
|
||||
# i686-unknown-linux-musl configuration
|
||||
CC_i686-unknown-linux-musl=$(CFG_MUSL_ROOT)/bin/musl-gcc
|
||||
CXX_i686-unknown-linux-musl=notaprogram
|
||||
CXX_i686-unknown-linux-musl=$(CXX)
|
||||
CPP_i686-unknown-linux-musl=$(CFG_MUSL_ROOT)/bin/musl-gcc -E
|
||||
AR_i686-unknown-linux-musl=$(AR)
|
||||
CFG_INSTALL_ONLY_RLIB_i686-unknown-linux-musl = 1
|
||||
|
@ -1,6 +1,6 @@
|
||||
# x86_64-unknown-linux-musl configuration
|
||||
CC_x86_64-unknown-linux-musl=$(CFG_MUSL_ROOT)/bin/musl-gcc
|
||||
CXX_x86_64-unknown-linux-musl=notaprogram
|
||||
CXX_x86_64-unknown-linux-musl=$(CXX)
|
||||
CPP_x86_64-unknown-linux-musl=$(CFG_MUSL_ROOT)/bin/musl-gcc -E
|
||||
AR_x86_64-unknown-linux-musl=$(AR)
|
||||
CFG_INSTALL_ONLY_RLIB_x86_64-unknown-linux-musl = 1
|
||||
|
16
mk/llvm.mk
16
mk/llvm.mk
@ -32,27 +32,17 @@ ifeq ($(CFG_LLVM_ROOT),)
|
||||
|
||||
LLVM_STAMP_$(1) = $$(CFG_LLVM_BUILD_DIR_$(1))/llvm-auto-clean-stamp
|
||||
|
||||
ifeq ($$(findstring msvc,$(1)),msvc)
|
||||
|
||||
$$(LLVM_CONFIG_$(1)): $$(LLVM_DEPS) $$(LLVM_STAMP_$(1))
|
||||
@$$(call E, cmake: llvm)
|
||||
ifeq ($$(findstring msvc,$(1)),msvc)
|
||||
$$(Q)$$(CFG_CMAKE) --build $$(CFG_LLVM_BUILD_DIR_$(1)) \
|
||||
--config $$(LLVM_BUILD_CONFIG_MODE)
|
||||
$$(Q)touch $$(LLVM_CONFIG_$(1))
|
||||
|
||||
clean-llvm$(1):
|
||||
|
||||
else
|
||||
|
||||
$$(LLVM_CONFIG_$(1)): $$(LLVM_DEPS) $$(LLVM_STAMP_$(1))
|
||||
@$$(call E, make: llvm)
|
||||
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1)) $$(CFG_LLVM_BUILD_ENV_$(1)) ONLY_TOOLS="$$(LLVM_TOOLS)"
|
||||
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1))
|
||||
endif
|
||||
$$(Q)touch $$(LLVM_CONFIG_$(1))
|
||||
|
||||
clean-llvm$(1):
|
||||
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1)) clean
|
||||
|
||||
endif
|
||||
|
||||
else
|
||||
clean-llvm$(1):
|
||||
|
159
mk/rt.mk
159
mk/rt.mk
@ -233,35 +233,98 @@ COMPRT_DEPS := $(wildcard \
|
||||
$(S)src/compiler-rt/*/*/*/*)
|
||||
endif
|
||||
|
||||
# compiler-rt's build system is a godawful mess. Here we figure out
|
||||
# the ridiculous platform-specific values and paths necessary to get
|
||||
# useful artifacts out of it.
|
||||
|
||||
COMPRT_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
|
||||
COMPRT_LIB_$(1) := $$(RT_OUTPUT_DIR_$(1))/$$(COMPRT_NAME_$(1))
|
||||
COMPRT_BUILD_DIR_$(1) := $$(RT_OUTPUT_DIR_$(1))/compiler-rt
|
||||
|
||||
ifeq ($$(findstring msvc,$(1)),msvc)
|
||||
$$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS) $$(MKFILE_DEPS) $$(LLVM_CONFIG_$$(CFG_BUILD))
|
||||
@$$(call E, cmake: compiler-rt)
|
||||
$$(Q)cd "$$(COMPRT_BUILD_DIR_$(1))"; $$(CFG_CMAKE) "$(S)src/compiler-rt" \
|
||||
-DCMAKE_BUILD_TYPE=$$(LLVM_BUILD_CONFIG_MODE) \
|
||||
-DLLVM_CONFIG_PATH=$$(LLVM_CONFIG_$$(CFG_BUILD)) \
|
||||
-G"$$(CFG_CMAKE_GENERATOR)"
|
||||
$$(Q)$$(CFG_CMAKE) --build "$$(COMPRT_BUILD_DIR_$(1))" \
|
||||
--target lib/builtins/builtins \
|
||||
--config $$(LLVM_BUILD_CONFIG_MODE) \
|
||||
-- //v:m //nologo
|
||||
$$(Q)cp $$(COMPRT_BUILD_DIR_$(1))/lib/windows/$$(LLVM_BUILD_CONFIG_MODE)/clang_rt.builtins-$$(HOST_$(1)).lib $$@
|
||||
else
|
||||
COMPRT_CC_$(1) := $$(CC_$(1))
|
||||
COMPRT_AR_$(1) := $$(AR_$(1))
|
||||
# We chomp -Werror here because GCC warns about the type signature of
|
||||
# builtins not matching its own and the build fails. It's a bit hacky,
|
||||
# but what can we do, we're building libclang-rt using GCC ......
|
||||
COMPRT_CFLAGS_$(1) := $$(CFG_GCCISH_CFLAGS_$(1)) -Wno-error -std=c99
|
||||
COMPRT_ARCH_$(1) := $$(word 1,$$(subst -, ,$(1)))
|
||||
|
||||
# All this is to figure out the path to the compiler-rt bin
|
||||
ifeq ($$(findstring windows-msvc,$(1)),windows-msvc)
|
||||
COMPRT_DIR_$(1) := windows/Release
|
||||
COMPRT_LIB_NAME_$(1) := clang_rt.builtins-$$(patsubst i%86,i386,$$(COMPRT_ARCH_$(1)))
|
||||
endif
|
||||
|
||||
ifeq ($$(findstring windows-gnu,$(1)),windows-gnu)
|
||||
COMPRT_DIR_$(1) := windows
|
||||
COMPRT_LIB_NAME_$(1) := clang_rt.builtins-$$(COMPRT_ARCH_$(1))
|
||||
endif
|
||||
|
||||
ifeq ($$(findstring darwin,$(1)),darwin)
|
||||
COMPRT_DIR_$(1) := builtins
|
||||
COMPRT_LIB_NAME_$(1) := clang_rt.builtins_$$(patsubst i686,i386,$$(COMPRT_ARCH_$(1)))_osx
|
||||
endif
|
||||
|
||||
ifeq ($$(findstring ios,$(1)),ios)
|
||||
COMPRT_DIR_$(1) := builtins
|
||||
COMPRT_ARCH_$(1) := $$(patsubst armv7s,armv7em,$$(COMPRT_ARCH_$(1)))
|
||||
COMPRT_LIB_NAME_$(1) := clang_rt.hard_pic_$$(COMPRT_ARCH_$(1))_macho_embedded
|
||||
ifeq ($$(COMPRT_ARCH_$(1)),aarch64)
|
||||
COMPRT_LIB_NAME_$(1) := clang_rt.builtins_arm64_ios
|
||||
endif
|
||||
COMPRT_DEFINES_$(1) := -DCOMPILER_RT_ENABLE_IOS=ON
|
||||
endif
|
||||
|
||||
ifndef COMPRT_DIR_$(1)
|
||||
# NB: FreeBSD and NetBSD output to "linux"...
|
||||
COMPRT_DIR_$(1) := linux
|
||||
COMPRT_ARCH_$(1) := $$(patsubst i586,i386,$$(COMPRT_ARCH_$(1)))
|
||||
|
||||
ifeq ($$(findstring android,$(1)),android)
|
||||
ifeq ($$(findstring arm,$$(COMPRT_ARCH_$(1))),arm)
|
||||
COMPRT_ARCH_$(1) := armhf
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($$(findstring eabihf,$(1)),eabihf)
|
||||
ifeq ($$(findstring armv7,$(1)),)
|
||||
COMPRT_LIB_NAME_$(1) := clang_rt.builtins-armhf
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef COMPRT_LIB_NAME_$(1)
|
||||
COMPRT_LIB_NAME_$(1) := clang_rt.builtins-$$(COMPRT_ARCH_$(1))
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($$(findstring windows-gnu,$(1)),windows-gnu)
|
||||
COMPRT_LIB_FILE_$(1) := lib$$(COMPRT_LIB_NAME_$(1)).a
|
||||
endif
|
||||
|
||||
ifeq ($$(findstring android,$(1)),android)
|
||||
ifeq ($$(findstring arm,$(1)),arm)
|
||||
COMPRT_LIB_FILE_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),$$(COMPRT_LIB_NAME_$(1))-android)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef COMPRT_LIB_FILE_$(1)
|
||||
COMPRT_LIB_FILE_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),$$(COMPRT_LIB_NAME_$(1)))
|
||||
endif
|
||||
|
||||
COMPRT_OUTPUT_$(1) := $$(COMPRT_BUILD_DIR_$(1))/lib/$$(COMPRT_DIR_$(1))/$$(COMPRT_LIB_FILE_$(1))
|
||||
|
||||
ifeq ($$(findstring windows-msvc,$(1)),windows-msvc)
|
||||
COMPRT_BUILD_ARGS_$(1) := //v:m //nologo
|
||||
COMPRT_BUILD_TARGET_$(1) := lib/builtins/builtins
|
||||
COMPRT_BUILD_CC_$(1) :=
|
||||
else
|
||||
COMPRT_BUILD_ARGS_$(1) :=
|
||||
ifndef COMPRT_BUILD_TARGET_$(1)
|
||||
COMPRT_BUILD_TARGET_$(1) := $$(COMPRT_LIB_NAME_$(1))
|
||||
endif
|
||||
COMPRT_BUILD_CC_$(1) := -DCMAKE_C_COMPILER=$$(call FIND_COMPILER,$$(CC_$(1))) \
|
||||
-DCMAKE_CXX_COMPILER=$$(call FIND_COMPILER,$$(CXX_$(1)))
|
||||
|
||||
ifeq ($$(findstring ios,$(1)),)
|
||||
COMPRT_BUILD_CC_$(1) := $$(COMPRT_BUILD_CC_$(1)) \
|
||||
-DCMAKE_C_FLAGS="$$(CFG_GCCISH_CFLAGS_$(1)) -Wno-error"
|
||||
endif
|
||||
|
||||
# FreeBSD Clang's packaging is problematic; it doesn't copy unwind.h to
|
||||
# the standard include directory. This should really be in our changes to
|
||||
# compiler-rt, but we override the CFLAGS here so there isn't much choice
|
||||
ifeq ($$(findstring freebsd,$(1)),freebsd)
|
||||
COMPRT_CFLAGS_$(1) += -I/usr/include/c++/v1
|
||||
endif
|
||||
|
||||
ifeq ($$(findstring emscripten,$(1)),emscripten)
|
||||
@ -273,20 +336,26 @@ $$(COMPRT_LIB_$(1)):
|
||||
|
||||
else
|
||||
|
||||
$$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS) $$(MKFILE_DEPS)
|
||||
@$$(call E, make: compiler-rt)
|
||||
$$(Q)$$(MAKE) -C "$(S)src/compiler-rt" \
|
||||
ProjSrcRoot="$(S)src/compiler-rt" \
|
||||
ProjObjRoot="$$(abspath $$(COMPRT_BUILD_DIR_$(1)))" \
|
||||
CC='$$(COMPRT_CC_$(1))' \
|
||||
AR='$$(COMPRT_AR_$(1))' \
|
||||
RANLIB='$$(COMPRT_AR_$(1)) s' \
|
||||
CFLAGS="$$(COMPRT_CFLAGS_$(1))" \
|
||||
TargetTriple=$(1) \
|
||||
triple-builtins
|
||||
$$(Q)cp $$(COMPRT_BUILD_DIR_$(1))/triple/builtins/libcompiler_rt.a $$@
|
||||
$$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS) $$(MKFILE_DEPS) $$(LLVM_CONFIG_$$(CFG_BUILD))
|
||||
@$$(call E, cmake: compiler-rt)
|
||||
$$(Q)rm -rf $$(COMPRT_BUILD_DIR_$(1))
|
||||
$$(Q)mkdir $$(COMPRT_BUILD_DIR_$(1))
|
||||
$$(Q)cd "$$(COMPRT_BUILD_DIR_$(1))"; \
|
||||
$$(CFG_CMAKE) "$(S)src/compiler-rt" \
|
||||
-DCMAKE_BUILD_TYPE=$$(LLVM_BUILD_CONFIG_MODE) \
|
||||
-DLLVM_CONFIG_PATH=$$(LLVM_CONFIG_$$(CFG_BUILD)) \
|
||||
-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=$(1) \
|
||||
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
|
||||
-DCOMPILER_RT_BUILD_EMUTLS=OFF \
|
||||
$$(COMPRT_DEFINES_$(1)) \
|
||||
$$(COMPRT_BUILD_CC_$(1)) \
|
||||
-G"$$(CFG_CMAKE_GENERATOR)"
|
||||
$$(Q)$$(CFG_CMAKE) --build "$$(COMPRT_BUILD_DIR_$(1))" \
|
||||
--target $$(COMPRT_BUILD_TARGET_$(1)) \
|
||||
--config $$(LLVM_BUILD_CONFIG_MODE) \
|
||||
-- $$(COMPRT_BUILD_ARGS_$(1)) $$(MFLAGS)
|
||||
$$(Q)cp "$$(COMPRT_OUTPUT_$(1))" $$@
|
||||
|
||||
endif # if emscripten
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
@ -310,20 +379,15 @@ ifeq ($$(findstring darwin,$$(OSTYPE_$(1))),darwin)
|
||||
$$(BACKTRACE_LIB_$(1)):
|
||||
touch $$@
|
||||
|
||||
else
|
||||
ifeq ($$(findstring ios,$$(OSTYPE_$(1))),ios)
|
||||
else ifeq ($$(findstring ios,$$(OSTYPE_$(1))),ios)
|
||||
# See comment above
|
||||
$$(BACKTRACE_LIB_$(1)):
|
||||
touch $$@
|
||||
else
|
||||
|
||||
ifeq ($$(findstring msvc,$(1)),msvc)
|
||||
else ifeq ($$(findstring msvc,$(1)),msvc)
|
||||
# See comment above
|
||||
$$(BACKTRACE_LIB_$(1)):
|
||||
touch $$@
|
||||
else
|
||||
|
||||
ifeq ($$(findstring emscripten,$(1)),emscripten)
|
||||
else ifeq ($$(findstring emscripten,$(1)),emscripten)
|
||||
# FIXME: libbacktrace doesn't understand the emscripten triple
|
||||
$$(BACKTRACE_LIB_$(1)):
|
||||
touch $$@
|
||||
@ -376,10 +440,7 @@ $$(BACKTRACE_LIB_$(1)): $$(BACKTRACE_BUILD_DIR_$(1))/Makefile $$(MKFILE_DEPS)
|
||||
INCDIR=$(S)src/libbacktrace
|
||||
$$(Q)cp $$(BACKTRACE_BUILD_DIR_$(1))/.libs/libbacktrace.a $$@
|
||||
|
||||
endif # endif for emscripten
|
||||
endif # endif for msvc
|
||||
endif # endif for ios
|
||||
endif # endif for darwin
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
# libc/libunwind for musl
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 57315f7e07d09b6f0341ebbcd50dded6c20d782f
|
||||
Subproject commit a1ef94b76029780a510bc2dc9c6a791bd091ff19
|
@ -19,7 +19,13 @@ FROM ubuntu:xenial
|
||||
RUN apt-get update && apt-get -y install \
|
||||
curl g++ git make \
|
||||
libedit-dev zlib1g-dev \
|
||||
llvm-3.7-tools
|
||||
llvm-3.7-tools cmake
|
||||
|
||||
# When we compile compiler-rt we pass it the llvm-config we just installed on
|
||||
# the system, but unfortunately it doesn't infer correctly where
|
||||
# LLVMConfig.cmake is so we need to coerce it a bit...
|
||||
RUN mkdir -p /usr/lib/llvm-3.7/build/share/llvm
|
||||
RUN ln -s /usr/share/llvm-3.7/cmake /usr/lib/llvm-3.7/build/share/llvm/cmake
|
||||
|
||||
RUN mkdir /build
|
||||
WORKDIR /build
|
||||
|
Loading…
x
Reference in New Issue
Block a user