mirror of
https://github.com/Relintai/osxcross.git
synced 2025-03-13 11:48:52 +01:00
build_compiler_rt.sh: Add proper Clang 3.9 support
This commit is contained in:
parent
24562a5590
commit
7a33b91a50
@ -2,33 +2,18 @@
|
||||
|
||||
pushd "${0%/*}" &>/dev/null
|
||||
|
||||
DESC=compiler-rt
|
||||
source tools/tools.sh
|
||||
eval $(tools/osxcross_conf.sh)
|
||||
|
||||
if [ $PLATFORM == "Darwin" ]; then
|
||||
exit 0
|
||||
exit 1
|
||||
fi
|
||||
|
||||
require git
|
||||
|
||||
set +e
|
||||
|
||||
which xcrun &>/dev/null
|
||||
|
||||
# Clang <= 3.4 doesn't like '-arch x86_64h'
|
||||
|
||||
if [ $? -ne 0 ] ||
|
||||
[[ $(xcrun clang -arch x86_64h --version 2>/dev/null) \
|
||||
== *Target:\ x86_64-* ]];
|
||||
then
|
||||
echo "Please re-run ./build.sh" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
CLANG_VERSION=$(echo "__clang_major__ __clang_minor__ __clang_patchlevel__" | \
|
||||
clang -xc -E - | tail -n1 | tr ' ' '.')
|
||||
xcrun clang -xc -E - | tail -n1 | tr ' ' '.')
|
||||
|
||||
# Drop patch level for <= 3.3.
|
||||
if [ $(osxcross-cmp $CLANG_VERSION "<=" 3.3) -eq 1 ]; then
|
||||
@ -49,6 +34,8 @@ fi
|
||||
CLANG_INCLUDE_DIR="${CLANG_LIB_DIR}/include"
|
||||
CLANG_DARWIN_LIB_DIR="${CLANG_LIB_DIR}/lib/darwin"
|
||||
|
||||
USE_CMAKE=0
|
||||
|
||||
case $CLANG_VERSION in
|
||||
3.2*) BRANCH=release_32 ;;
|
||||
3.3*) BRANCH=release_33 ;;
|
||||
@ -56,43 +43,14 @@ case $CLANG_VERSION in
|
||||
3.5*) BRANCH=release_35 ;;
|
||||
3.6*) BRANCH=release_36 ;;
|
||||
3.7*) BRANCH=release_37 ;;
|
||||
3.8*) BRANCH=release_38 ;;
|
||||
3.9*) BRANCH=master ;;
|
||||
* ) echo "Unsupported Clang version, must be >= 3.2 and <= 3.9" 1>&2; exit 1;
|
||||
3.8*) BRANCH=release_38; USE_CMAKE=1; ;;
|
||||
3.9*) BRANCH=release_39; USE_CMAKE=1; ;;
|
||||
4.0*) BRANCH=master; USE_CMAKE=1; ;;
|
||||
* ) echo "Unsupported Clang version, must be >= 3.2 and <= 4.0" 1>&2; exit 1;
|
||||
esac
|
||||
|
||||
pushd $OSXCROSS_BUILD_DIR &>/dev/null
|
||||
|
||||
if [ ! -e compiler-rt/.clone_complete ]; then
|
||||
rm -rf compiler-rt
|
||||
git clone http://llvm.org/git/compiler-rt.git
|
||||
fi
|
||||
|
||||
pushd compiler-rt &>/dev/null
|
||||
|
||||
git reset --hard
|
||||
|
||||
git checkout $BRANCH
|
||||
git clean -fdx
|
||||
touch .clone_complete
|
||||
git pull
|
||||
|
||||
if [ $BRANCH == "release_38" ]; then
|
||||
patch -p0 < $PATCH_DIR/compiler-rt-llvm38-makefile.patch
|
||||
fi
|
||||
|
||||
$SED -i "s/Configs += ios//g" make/platform/clang_darwin.mk
|
||||
$SED -i "s/Configs += cc_kext_ios5//g" make/platform/clang_darwin.mk
|
||||
$SED -i "s/Configs += profile_ios//g" make/platform/clang_darwin.mk
|
||||
$SED -i "s/Configs += asan_iossim_dynamic//g" make/platform/clang_darwin.mk
|
||||
|
||||
# Unbreak the -Werror build.
|
||||
if [ -f lib/asan/asan_mac.h ]; then
|
||||
$SED -i "s/ASAN__MAC_H/ASAN_MAC_H/g" lib/asan/asan_mac.h
|
||||
fi
|
||||
|
||||
if [ $(osxcross-cmp $CLANG_VERSION ">=" 3.5) -eq 1 ]; then
|
||||
export MACOSX_DEPLOYMENT_TARGET=10.7
|
||||
export MACOSX_DEPLOYMENT_TARGET=10.8 # x86_64h
|
||||
else
|
||||
export MACOSX_DEPLOYMENT_TARGET=10.4
|
||||
fi
|
||||
@ -104,23 +62,92 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EXTRA_MAKE_FLAGS="LIPO=\"$(xcrun -f lipo)\""
|
||||
pushd $OSXCROSS_BUILD_DIR &>/dev/null
|
||||
|
||||
if [ $(osxcross-cmp $CLANG_VERSION "<=" 3.3) -eq 1 ]; then
|
||||
EXTRA_MAKE_FLAGS+=" AR=\"$(xcrun -f ar)\""
|
||||
EXTRA_MAKE_FLAGS+=" RANLIB=\"$(xcrun -f ranlib)\""
|
||||
EXTRA_MAKE_FLAGS+=" CC=\"$(xcrun -f clang)\""
|
||||
if [ ! -e compiler-rt/.clone_complete ]; then
|
||||
rm -rf compiler-rt
|
||||
git clone http://llvm.org/git/compiler-rt.git
|
||||
fi
|
||||
|
||||
pushd compiler-rt &>/dev/null
|
||||
|
||||
git reset --hard
|
||||
git clean -fdx
|
||||
git checkout $BRANCH
|
||||
touch .clone_complete
|
||||
git pull
|
||||
|
||||
EXTRA_MAKE_FLAGS=""
|
||||
if [ -n "$OCDEBUG" ]; then
|
||||
EXTRA_MAKE_FLAGS+=" VERBOSE=1"
|
||||
EXTRA_MAKE_FLAGS+="VERBOSE=1 "
|
||||
fi
|
||||
|
||||
# Must eval here because of the spaces in EXTRA_MAKE_FLAGS.
|
||||
export OSXCROSS_NO_X86_64H_DEPLOYMENT_TARGET_WARNING=1
|
||||
|
||||
|
||||
if [ $USE_CMAKE -eq 1 ]; then
|
||||
|
||||
### CMAKE ###
|
||||
|
||||
require cmake
|
||||
|
||||
$SED -i 's/COMMAND xcodebuild -version -sdk ${sdk_name}.internal Path/'\
|
||||
\ \ \ \ \ \ 'COMMAND xcrun -sdk ${sdk_name}.internal --show-sdk-path/g' \
|
||||
cmake/Modules/CompilerRTDarwinUtils.cmake
|
||||
|
||||
$SED -i 's/COMMAND xcodebuild -version -sdk ${sdk_name} Path/'\
|
||||
\ \ \ \ \ \ 'COMMAND xcrun -sdk ${sdk_name} --show-sdk-path/g' \
|
||||
cmake/Modules/CompilerRTDarwinUtils.cmake
|
||||
|
||||
$SED -i "s/COMMAND lipo /COMMAND xcrun lipo /g" \
|
||||
cmake/Modules/CompilerRTDarwinUtils.cmake
|
||||
|
||||
$SED -i "s/COMMAND ld /COMMAND xcrun ld /g" \
|
||||
cmake/Modules/CompilerRTDarwinUtils.cmake
|
||||
|
||||
mkdir build
|
||||
pushd build &>/dev/null
|
||||
|
||||
CC=$(xcrun -f clang) CXX=$(xcrun -f clang++) cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Darwin \
|
||||
-DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path) -DCMAKE_AR=$(xcrun -f ar)
|
||||
|
||||
$MAKE -j $JOBS $EXTRA_MAKE_FLAGS
|
||||
|
||||
popd &>/dev/null
|
||||
|
||||
### CMAKE END ###
|
||||
|
||||
else
|
||||
|
||||
### MAKE ###
|
||||
|
||||
$SED -i "s/Configs += ios//g" make/platform/clang_darwin.mk
|
||||
$SED -i "s/Configs += cc_kext_ios5//g" make/platform/clang_darwin.mk
|
||||
$SED -i "s/Configs += profile_ios//g" make/platform/clang_darwin.mk
|
||||
$SED -i "s/Configs += asan_iossim_dynamic//g" make/platform/clang_darwin.mk
|
||||
|
||||
# Unbreak the -Werror build.
|
||||
if [ -f lib/asan/asan_mac.h ]; then
|
||||
$SED -i "s/ASAN__MAC_H/ASAN_MAC_H/g" lib/asan/asan_mac.h
|
||||
fi
|
||||
|
||||
EXTRA_MAKE_FLAGS+="LIPO=\"$(xcrun -f lipo)\""
|
||||
|
||||
if [ $(osxcross-cmp $CLANG_VERSION "<=" 3.3) -eq 1 ]; then
|
||||
EXTRA_MAKE_FLAGS+=" AR=\"$(xcrun -f ar)\""
|
||||
EXTRA_MAKE_FLAGS+=" RANLIB=\"$(xcrun -f ranlib)\""
|
||||
EXTRA_MAKE_FLAGS+=" CC=\"$(xcrun -f clang)\""
|
||||
fi
|
||||
|
||||
# Must eval here because of the spaces in EXTRA_MAKE_FLAGS.
|
||||
|
||||
eval "$MAKE clang_darwin $EXTRA_MAKE_FLAGS -j $JOBS"
|
||||
|
||||
### MAKE END ###
|
||||
|
||||
fi
|
||||
|
||||
eval \
|
||||
"OSXCROSS_NO_X86_64H_DEPLOYMENT_TARGET_WARNING=1 \
|
||||
$MAKE clang_darwin $EXTRA_MAKE_FLAGS -j $JOBS"
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
@ -130,26 +157,51 @@ echo ""
|
||||
|
||||
echo "mkdir -p ${CLANG_INCLUDE_DIR}"
|
||||
echo "mkdir -p ${CLANG_DARWIN_LIB_DIR}"
|
||||
echo "cp -r $PWD/include/sanitizer ${CLANG_INCLUDE_DIR}"
|
||||
echo "cp -rv $PWD/include/sanitizer ${CLANG_INCLUDE_DIR}"
|
||||
|
||||
pushd "clang_darwin" &>/dev/null
|
||||
|
||||
function print_install_command() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "cp $PWD/$1 ${CLANG_DARWIN_LIB_DIR}/$2"
|
||||
fi
|
||||
}
|
||||
|
||||
print_install_command "osx/libcompiler_rt.a" "libclang_rt.osx.a"
|
||||
print_install_command "10.4/libcompiler_rt.a" "libclang_rt.10.4.a"
|
||||
print_install_command "eprintf/libcompiler_rt.a" "libclang_rt.eprintf.a"
|
||||
print_install_command "cc_kext/libcompiler_rt.a" "libclang_rt.cc_kext.a"
|
||||
print_install_command "profile_osx/libcompiler_rt.a" "libclang_rt.profile_osx.a"
|
||||
if [ $USE_CMAKE -eq 1 ]; then
|
||||
|
||||
print_install_command "ubsan_osx_dynamic/libcompiler_rt.dylib" \
|
||||
"libclang_rt.ubsan_osx_dynamic.dylib"
|
||||
### CMAKE ###
|
||||
|
||||
echo "cp -v $PWD/build/lib/darwin/*.a ${CLANG_DARWIN_LIB_DIR}"
|
||||
echo "cp -v $PWD/build/lib/darwin/*.dylib ${CLANG_DARWIN_LIB_DIR}"
|
||||
|
||||
### CMAKE END ###
|
||||
|
||||
else
|
||||
|
||||
### MAKE ###
|
||||
|
||||
pushd "clang_darwin" &>/dev/null
|
||||
|
||||
function print_install_command() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "cp $PWD/$1 ${CLANG_DARWIN_LIB_DIR}/$2"
|
||||
fi
|
||||
}
|
||||
|
||||
print_install_command "osx/libcompiler_rt.a" "libclang_rt.osx.a"
|
||||
print_install_command "10.4/libcompiler_rt.a" "libclang_rt.10.4.a"
|
||||
print_install_command "eprintf/libcompiler_rt.a" "libclang_rt.eprintf.a"
|
||||
print_install_command "cc_kext/libcompiler_rt.a" "libclang_rt.cc_kext.a"
|
||||
print_install_command "profile_osx/libcompiler_rt.a" "libclang_rt.profile_osx.a"
|
||||
|
||||
|
||||
print_install_command "ubsan_osx_dynamic/libcompiler_rt.dylib" \
|
||||
"libclang_rt.ubsan_osx_dynamic.dylib"
|
||||
|
||||
print_install_command "asan_osx_dynamic/libcompiler_rt.dylib" \
|
||||
"libclang_rt.asan_osx_dynamic.dylib"
|
||||
|
||||
|
||||
popd &>/dev/null
|
||||
|
||||
### MAKE END ###
|
||||
|
||||
fi
|
||||
|
||||
print_install_command "asan_osx_dynamic/libcompiler_rt.dylib" \
|
||||
"libclang_rt.asan_osx_dynamic.dylib"
|
||||
|
||||
echo ""
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
diff --git make/platform/clang_darwin.mk make/platform/clang_darwin.mk
|
||||
index 9944481..50afa19 100644
|
||||
--- make/platform/clang_darwin.mk
|
||||
+++ make/platform/clang_darwin.mk
|
||||
@@ -17,23 +17,23 @@ CheckArches = \
|
||||
result=""; \
|
||||
if [ "X$(3)" != X ]; then \
|
||||
for arch in $(1); do \
|
||||
- if $(LD) -v 2>&1 | grep "configured to support" \
|
||||
- | tr ' ' '\n' | grep "^$$arch$$" >/dev/null 2>/dev/null; then \
|
||||
- if $(CC) -arch $$arch \
|
||||
+ if $(CC) -arch $$arch -c \
|
||||
-integrated-as \
|
||||
$(ProjSrcRoot)/make/platform/clang_darwin_test_input.c \
|
||||
-isysroot $(3) \
|
||||
-o /dev/null > /dev/null 2> /dev/null; then \
|
||||
- result="$$result$$arch "; \
|
||||
+ if $(LD) -v 2>&1 | grep "configured to support" \
|
||||
+ | tr ' ' '\n' | grep "^$$arch$$" >/dev/null 2>/dev/null; then \
|
||||
+ result="$$result$$arch "; \
|
||||
else \
|
||||
printf 1>&2 \
|
||||
- "warning: clang_darwin.mk: dropping arch '$$arch' from lib '$(2)'"; \
|
||||
- printf 1>&2 " (clang or system libraries do not support it)\n"; \
|
||||
+ "warning: clang_darwin.mk: dropping arch '$$arch' from lib '$(2)'";\
|
||||
+ printf 1>&2 " (ld does not support it)\n"; \
|
||||
fi; \
|
||||
else \
|
||||
printf 1>&2 \
|
||||
- "warning: clang_darwin.mk: dropping arch '$$arch' from lib '$(2)'";\
|
||||
- printf 1>&2 " (ld does not support it)\n"; \
|
||||
+ "warning: clang_darwin.mk: dropping arch '$$arch' from lib '$(2)'"; \
|
||||
+ printf 1>&2 " (clang does not support it)\n"; \
|
||||
fi; \
|
||||
done; \
|
||||
fi; \
|
Loading…
Reference in New Issue
Block a user