mirror of
https://github.com/darlinghq/cctools-port.git
synced 2025-02-16 23:28:02 +00:00
attempt to build libcxx from source if it is not installed on the system
remove unneeded ld/Makefile ld64 *should* now also build without llvm-devel (but disables LTO then)
This commit is contained in:
parent
ba0f464b50
commit
e837833872
@ -7,7 +7,7 @@ Originally ported by cjacker from the [ios-toolchain-for-linux](https://code.goo
|
||||
|
||||
Make sure you have the following installed on your Linux box:
|
||||
|
||||
`Clang 3.2+`, `libc++-devel`, `llvm-devel`, `automake`, `autogen`,
|
||||
`Clang 3.2+`, `llvm-devel`, `automake`, `autogen`,
|
||||
`libtool`, `libuuid-devel` and `openssl-devel`.
|
||||
|
||||
Then type:
|
||||
|
@ -1,2 +1,5 @@
|
||||
SUBDIRS=libstuff ar as misc libobjc2 otool ld64 $(LD_CLASSIC)
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
install-exec-hook:
|
||||
(test -f tmp/install_libcxx.sh && mkdir -p $(DESTDIR)$(libdir) && ./tmp/install_libcxx.sh $(DESTDIR)$(libdir)) || true
|
||||
|
@ -1,15 +1,26 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
eval `find_lto_header.sh`
|
||||
# set -x
|
||||
|
||||
../tools/find_lto_header.sh || echo "llvm-devel seems not to be installed - disabling LTO support"
|
||||
|
||||
echo "#include <vector>"|clang++ -stdlib=libc++ -xc++ -c -S -o- - &>/dev/null
|
||||
|
||||
test $? -eq 0 || { echo "libc++-devel is required" && exit 1; }
|
||||
if [ $? -ne 0 ]; then
|
||||
|
||||
if [ ! -f tmp/have_libcxx ]; then
|
||||
echo ""
|
||||
echo "no working libc++ found, will build it from source ..."
|
||||
echo ""
|
||||
sleep 2
|
||||
../tools/build_libcxx.sh || exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
grep -n "__block," /usr/include/unistd.h &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "applying workaround for buggy unistd.h"
|
||||
./fix_unistd_issue.sh
|
||||
../tools/fix_unistd_issue.sh
|
||||
fi
|
||||
|
||||
mkdir -p m4
|
||||
|
@ -9,7 +9,11 @@ AC_ARG_PROGRAM
|
||||
#force compiler to clang
|
||||
CC=clang
|
||||
CXX=clang++
|
||||
CXXFLAGS=-stdlib=libc++
|
||||
|
||||
CFLAGS="`cat tmp/cflags 2>/dev/null` -O3"
|
||||
CXXFLAGS="`cat tmp/libcxx-conf 2>/dev/null || echo -stdlib=libc++` `cat tmp/cxxflags 2>/dev/null` -O3"
|
||||
LDFLAGS="`cat tmp/ldflags 2>/dev/null`"
|
||||
|
||||
CPP="clang -E"
|
||||
|
||||
AM_INIT_AUTOMAKE([1.10 no-define no-dist-gzip dist-bzip2 tar-ustar])
|
||||
@ -245,32 +249,6 @@ AC_SUBST(CRYPT_LIBS)
|
||||
AC_C_BIGENDIAN([AC_SUBST([ENDIAN_FLAG],[-D__BIG_ENDIAN__=1])],
|
||||
[AC_SUBST([ENDIAN_FLAG],[-D__LITTLE_ENDIAN__=1])])
|
||||
|
||||
# Check LTO
|
||||
AC_CHECK_PROG(HAVE_LLVM_CONFIG, llvm-config, true, false)
|
||||
|
||||
if test "x$HAVE_LLVM_CONFIG" = "xfalse"; then
|
||||
AC_CHECK_PROG(HAVE_LLVM_CONFIG_32, llvm-config-3.2, true, false)
|
||||
if test "x$HAVE_LLVM_CONFIG_32" = "xfalse"; then
|
||||
AC_MSG_ERROR([llvm-config or llvm-config-3.2 not found on your system,please install related packages])
|
||||
else
|
||||
LLVM_LIBDIR=`llvm-config-3.2 --libdir`
|
||||
if test -f $LLVM_LIBDIR/libLTO.so;then
|
||||
LTO_LIBS="-L`llvm-config-3.2 --libdir` -lLTO"
|
||||
LTO_DEFS="-DLTO_SUPPORT=1"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
LLVM_LIBDIR=`llvm-config --libdir`
|
||||
if test -f $LLVM_LIBDIR/libLTO.so;then
|
||||
LTO_LIBS="-L`llvm-config --libdir` -lLTO"
|
||||
LTO_DEFS="-DLTO_SUPPORT=1"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
AC_SUBST(LTO_LIBS)
|
||||
AC_SUBST(LTO_DEFS)
|
||||
|
||||
#compile ld_classic or not. only for 32bit.
|
||||
LD_CLASSIC=""
|
||||
cat > conftest.c <<EOF
|
||||
|
1111
cctools/ld/Makefile
1111
cctools/ld/Makefile
File diff suppressed because it is too large
Load Diff
52
tools/build_libcxx.sh
Executable file
52
tools/build_libcxx.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export LC_ALL="C"
|
||||
|
||||
set -e
|
||||
# set -x
|
||||
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
|
||||
SCRIPTDIR=$(cd $(dirname "$0"); pwd)
|
||||
|
||||
mkdir -p tmp
|
||||
|
||||
pushd tmp
|
||||
rm -rf *libcxx*
|
||||
|
||||
wget -c https://launchpad.net/ubuntu/+archive/primary/+files/libc%2B%2B_1.0~svn181765.orig.tar.gz
|
||||
tar xzfv libc++*.tar.gz
|
||||
|
||||
pushd libcxx*
|
||||
|
||||
INCDIR=`pwd`/include/v1
|
||||
LIB=`pwd`/lib/libc++.a
|
||||
|
||||
pushd lib
|
||||
|
||||
./buildit
|
||||
rm libc++.so
|
||||
ln -sf libc++.so* libc++.so
|
||||
|
||||
echo -n "-nostdinc++ -stdlib=libc++ -cxx-isystem `pwd`/../include -L`pwd` -Qunused-arguments" > ../../libcxx-conf
|
||||
|
||||
echo "#!/usr/bin/env bash" > ../../install_libcxx.sh
|
||||
echo "cp `pwd`/libc++.so \$1/libc++.so.1" >> ../../install_libcxx.sh
|
||||
|
||||
popd
|
||||
popd
|
||||
|
||||
pushd libcxxabi*
|
||||
pushd lib
|
||||
|
||||
patch -p0 < $SCRIPTDIR/libcxxabi.patch
|
||||
./buildit
|
||||
|
||||
echo -n " -cxx-isystem `pwd`/../include -L`pwd` -lc++abi" >> ../../libcxx-conf
|
||||
echo "cp `pwd`/libc++abi.so \$1/libc++abi.so.1" >> ../../install_libcxx.sh
|
||||
chmod +x ../../install_libcxx.sh
|
||||
touch ../../have_libcxx
|
||||
|
||||
popd
|
||||
|
@ -10,9 +10,10 @@ function try()
|
||||
LLVM_INC_DIR=`$LLVM_CONFIG --includedir`
|
||||
LLVM_LIB_DIR=`$LLVM_CONFIG --libdir`
|
||||
ln -sf "$LLVM_INC_DIR/llvm-c/lto.h" "include/llvm-c/lto.h"
|
||||
echo -n "export LDFLAGS+=\" -L$LLVM_LIB_DIR -lLTO \" "
|
||||
echo -n "export CFLAGS+=\" -DLTO_SUPPORT=1 \" "
|
||||
echo -n "export CXXFLAGS+=\" -DLTO_SUPPORT=1 \""
|
||||
mkdir -p tmp
|
||||
echo -n "-L$LLVM_LIB_DIR -lLTO " > tmp/ldflags
|
||||
echo -n "-DLTO_SUPPORT=1 " > tmp/cflags
|
||||
echo -n "-DLTO_SUPPORT=1 " > tmp/cxxflags
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
@ -23,5 +24,4 @@ try "-3.3"
|
||||
try "-3.4"
|
||||
try "-3.5"
|
||||
|
||||
echo "echo \"can not find lto.h - make sure llvm-devel is installed on your system\""
|
||||
exit 1
|
19
tools/libcxxabi.patch
Normal file
19
tools/libcxxabi.patch
Normal file
@ -0,0 +1,19 @@
|
||||
--- buildit 2013-12-08 16:36:25.552841502 +0100
|
||||
+++ buildit 2013-12-08 16:37:01.648843150 +0100
|
||||
@@ -27,7 +27,7 @@
|
||||
RC_ProjectSourceVersion=1
|
||||
fi
|
||||
|
||||
-EXTRA_FLAGS="-std=c++0x -stdlib=libc++ -fstrict-aliasing -Wstrict-aliasing=2 \
|
||||
+EXTRA_FLAGS="-std=c++0x `cat ../../libcxx-conf` -fstrict-aliasing -Wstrict-aliasing=2 \
|
||||
-Wsign-conversion -Wshadow -Wconversion -Wunused-variable \
|
||||
-Wmissing-field-initializers -Wchar-subscripts -Wmismatched-tags \
|
||||
-Wmissing-braces -Wshorten-64-to-32 -Wsign-compare \
|
||||
@@ -92,6 +92,7 @@
|
||||
;;
|
||||
esac
|
||||
$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS
|
||||
+ar rs libc++abi.a *.o && ln -sf libc++abi.so* libc++abi.so
|
||||
|
||||
if [ -z $RC_XBS ]
|
||||
then
|
Loading…
x
Reference in New Issue
Block a user