diff options
author | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2015-06-05 13:01:13 -0700 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2015-06-08 20:00:11 +0200 |
commit | 14ce213901b625cabdce3c670ac1eeedbb5eeffc (patch) | |
tree | d06ba57fa6ce8a1fc0daf6fa1f70b97311031e95 /util/crossgcc | |
parent | 699ac27decfa241854ee6517d7db8d53bb2e8750 (diff) |
crossgcc: Add clang support
Add a new option -C|--clang to buildgcc to build a clang based
toolchain as opposed to a gcc based toolchain. This toolchain
comes with the required patches needed to successfully build
coreboot, and also with clang's famous scan-build script.
Change-Id: I1aea7cd6002edc4f3bb2b46dc1f69a212ad18f77
Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-on: http://review.coreboot.org/10415
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'util/crossgcc')
-rwxr-xr-x | util/crossgcc/buildgcc | 73 | ||||
-rw-r--r-- | util/crossgcc/patches/cfe-3.6.1.src_frontend.patch | 79 | ||||
-rw-r--r-- | util/crossgcc/sum/cfe-3.6.1.src.tar.xz.cksum | 1 | ||||
-rw-r--r-- | util/crossgcc/sum/clang-tools-extra-3.6.1.src.tar.xz.cksum | 1 | ||||
-rw-r--r-- | util/crossgcc/sum/compiler-rt-3.6.1.src.tar.xz.cksum | 1 | ||||
-rw-r--r-- | util/crossgcc/sum/llvm-3.6.1.src.tar.xz.cksum | 1 |
6 files changed, 147 insertions, 9 deletions
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc index 45ee3c1f8f..3f08261e6b 100755 --- a/util/crossgcc/buildgcc +++ b/util/crossgcc/buildgcc @@ -22,8 +22,8 @@ cd `dirname $0` -CROSSGCC_DATE="June 3th, 2015" -CROSSGCC_VERSION="1.28" +CROSSGCC_DATE="June 4th, 2015" +CROSSGCC_VERSION="1.29" # default settings TARGETDIR=`pwd`/xgcc @@ -42,6 +42,8 @@ GDB_VERSION=7.9 IASL_VERSION=20150204 PYTHON_VERSION=3.4.3 EXPAT_VERSION=2.1.0 +# CLANG version number +CLANG_VERSION=3.6.1 # GCC toolchain archive locations GMP_ARCHIVE="http://ftpmirror.gnu.org/gmp/gmp-${GMP_VERSION}a.tar.bz2" @@ -54,6 +56,11 @@ GDB_ARCHIVE="http://ftpmirror.gnu.org/gdb/gdb-${GDB_VERSION}.tar.xz" IASL_ARCHIVE="https://acpica.org/sites/acpica/files/acpica-unix-${IASL_VERSION}.tar.gz" PYTHON_ARCHIVE="http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz" EXPAT_ARCHIVE="http://downloads.sourceforge.net/sourceforge/expat/expat-${EXPAT_VERSION}.tar.gz" +# CLANG toolchain archive locations +LLVM_ARCHIVE="http://llvm.org/releases/${CLANG_VERSION}/llvm-${CLANG_VERSION}.src.tar.xz" +CFE_ARCHIVE="http://llvm.org/releases/${CLANG_VERSION}/cfe-${CLANG_VERSION}.src.tar.xz" +CRT_ARCHIVE="http://llvm.org/releases/${CLANG_VERSION}/compiler-rt-${CLANG_VERSION}.src.tar.xz" +CTE_ARCHIVE="http://llvm.org/releases/${CLANG_VERSION}/clang-tools-extra-${CLANG_VERSION}.src.tar.xz" # GCC toolchain directories GMP_DIR="gmp-${GMP_VERSION}" @@ -66,10 +73,16 @@ GDB_DIR="gdb-${GDB_VERSION}" IASL_DIR="acpica-unix-${IASL_VERSION}" PYTHON_DIR="Python-${PYTHON_VERSION}" EXPAT_DIR="expat-${EXPAT_VERSION}" +# CLANG toolchain directories +LLVM_DIR="llvm-${CLANG_VERSION}.src" +CFE_DIR="cfe-${CLANG_VERSION}.src" +CRT_DIR="compiler-rt-${CLANG_VERSION}.src" +CTE_DIR="clang-tools-extra-${CLANG_VERSION}.src" unset MAKELEVEL MAKEFLAGS SAVETEMPS=0 +BUILDCLANG=0 SKIPGDB=1 SKIPPYTHON=1 @@ -154,6 +167,7 @@ searchtool() TAR=`searchtool tar` || exit $? PATCH=`searchtool patch` || exit $? MAKE=`searchtool make` || exit $? +CMAKE=`searchtool cmake "cmake"` || exit $? SHA1SUM=`searchtool sha1sum` SHA512SUM=`searchtool sha512sum` CHECKSUM=$SHA1SUM @@ -244,12 +258,15 @@ cleanup() rm -rf ${PYTHON_DIR} ${BUILDDIRPREFIX}-python rm -rf ${IASL_DIR} + # CLANG + rm -rf ${LLVM_DIR} ${CFE_DIR} ${CRT_DIR} ${CTE_DIR} ${BUILDDIR} + printf "${green}ok${NC}\n" } myhelp() { - printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>] [-G] [-S]\n" + printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>] [-C] [-G] [-S]\n" printf " $0 [-V|--version]\n" printf " $0 [-h|--help]\n\n" @@ -260,14 +277,16 @@ myhelp() printf " [-t|--savetemps] don't remove temporary files after build\n" printf " [-y|--ccache] Use ccache when building cross compiler\n" printf " [-j|--jobs <num>] run <num> jobs in parallel in make\n" + printf " [-C|--clang] build CLANG toolchain" printf " [-p|--platform <platform>] target platform to build cross compiler for\n" - printf " (defaults to $TARGETARCH)\n" + printf " (defaults to $TARGETARCH) *)\n" printf " [-d|--directory <target dir>] target directory to install cross compiler to\n" printf " (defaults to $TARGETDIR)\n\n" printf " [-D|--destdir <dest dir>] destination directory to install cross compiler to\n" printf " (for RPM builds, default unset)\n" - printf " [-G|--gdb] build GNU debugger\n" - printf " [-S|--scripting] build scripting support for GDB\n\n" + printf " [-G|--gdb] build GNU debugger *)\n" + printf " [-S|--scripting] build scripting support for GDB *)\n\n" + printf " *) option only available when building GCC toolchain (not with CLANG)\n\n" } myversion() @@ -300,11 +319,11 @@ getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c getoptbrand="`getopt -V | sed -e '1!d' -e 's,^\(......\).*,\1,'`" if [ "${getoptbrand}" = "getopt" ]; then # Detected GNU getopt that supports long options. - args=`getopt -l version,help,clean,directory:,platform:,jobs:,destdir:,savetemps,skip-gdb,ccache Vhcd:p:j:D:tGy -- "$@"` + args=`getopt -l version,help,clean,directory:,platform:,jobs:,destdir:,savetemps,skip-gdb,ccache,clang Vhcd:p:j:D:tGyC -- "$@"` eval set "$args" else # Detected non-GNU getopt - args=`getopt Vhcd:p:j:D:tGy $*` + args=`getopt Vhcd:p:j:D:tGyC $*` set -- $args fi @@ -323,6 +342,7 @@ while true ; do -p|--platform) shift; TARGETARCH="$1"; shift;; -D|--destdir) shift; DESTDIR="$1"; shift;; -j|--jobs) shift; JOBS="-j $1"; shift;; + -C|--clang) shift; BUILDCLANG=1;; -G|--gdb) shift; SKIPGDB=0;; -S|--scripting) shift; SKIPPYTHON=0;; -y|--ccache) shift; USECCACHE=1;; @@ -345,11 +365,17 @@ case "$TARGETARCH" in *) printf "${red}WARNING: Unsupported architecture $TARGETARCH.${NC}\n\n"; ;; esac -echo "Target arch is now $TARGETARCH" +if [ "$BUILDCLANG" -eq 0 ]; then +echo "Target architecture is now $TARGETARCH" NAME="${TARGETARCH} cross" PACKAGES="GMP MPFR MPC LIBELF BINUTILS GCC IASL" +else +NAME=clang +PACKAGES="LLVM CFE CRT CTE" +fi BUILDDIRPREFIX=build-${TARGETARCH} +BUILDDIR=$PWD/build-clang if [ "$clean" = "1" ]; then cleanup @@ -386,6 +412,7 @@ for P in $PACKAGES; do done printf "Unpacked and patched ... ${green}ok${NC}\n" +if [[ "$PACKAGES" == *GCC* ]]; then CC=cc if [ $UNAME = "Darwin" ]; then #GCC_OPTIONS="$GCC_OPTIONS --enable-threads=posix" @@ -408,6 +435,7 @@ if [ $UNAME = "Darwin" ]; then CC=llvm-gcc fi fi +fi # GCC if [ "$USECCACHE" = 1 ]; then CC="ccache $CC" @@ -415,6 +443,7 @@ fi mkdir -p ${BUILDDIRPREFIX}-gmp ${BUILDDIRPREFIX}-mpfr ${BUILDDIRPREFIX}-mpc ${BUILDDIRPREFIX}-libelf ${BUILDDIRPREFIX}-binutils \ ${BUILDDIRPREFIX}-gcc ${BUILDDIRPREFIX}-python ${BUILDDIRPREFIX}-expat ${BUILDDIRPREFIX}-gdb +mkdir -p ${BUILDDIR} mkdir -p $DESTDIR$TARGETDIR/bin export PATH=$DESTDIR$TARGETDIR/bin:$PATH @@ -666,6 +695,32 @@ else ) 2>&1 | wait_for_build "$IASL_DIR/source/compiler" || exit 1 fi +[[ "$PACKAGES" == *CLANG* ]] && \ +if [ -f ${BUILDDIR}/.success ]; then + printf "Skipping CLANG as it is already built\n" +else + printf "Building CLANG ${CLANG_VERSION} ... " +( + ln -sf $PWD/$CFE_DIR $LLVM_DIR/tools/clang + ln -sf $PWD/$CTE_DIR $LLVM_DIR/tools/clang/tools/extra + ln -sf $PWD/$CRT_DIR $LLVM_DIR/projects/compiler-rt + + cd ${BUILDDIR} + + $CMAKE -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$DESTDIR$TARGETDIR \ + -DCMAKE_BUILD_TYPE=Release ../$LLVM_DIR || touch .failed + $MAKE $JOBS || touch .failed + $MAKE install || touch .failed + + cd - + + cp -a $CFE_DIR/tools/scan-build/* $DESTDIR$TARGETDIR/bin + cp -a $CFE_DIR/tools/scan-view/* $DESTDIR$TARGETDIR/bin + + if [ ! -f .failed ]; then touch .success; fi +) 2>&1 | wait_for_build "${BUILDDIR}" || exit 1 +fi + # Adding git information of current tree to target directory # for reproducibility PROGNAME=`basename "$0"` diff --git a/util/crossgcc/patches/cfe-3.6.1.src_frontend.patch b/util/crossgcc/patches/cfe-3.6.1.src_frontend.patch new file mode 100644 index 0000000000..d69cb44091 --- /dev/null +++ b/util/crossgcc/patches/cfe-3.6.1.src_frontend.patch @@ -0,0 +1,79 @@ +Frontend driver patch from Edward O'Callaghan + +https://llvm.org/bugs/show_bug.cgi?id=21538 + +Index: include/clang/Driver/Driver.h +=================================================================== +--- cfe-3.6.1.src/include/clang/Driver/Driver.h (revision 211898) ++++ cfe-3.6.1.src/include/clang/Driver/Driver.h (working copy) +@@ -325,6 +325,14 @@ + // FIXME: This should be in CompilationInfo. + std::string GetFilePath(const char *Name, const ToolChain &TC) const; + ++ /// GetCompilerRTPath - Find Compiler-RT library path ++ /// ++ /// \param TC - The provided tool chain for additional information on ++ /// directories to search. ++ // ++ // FIXME: This should be in CompilationInfo. ++ std::string GetCompilerRTPath(const ToolChain &TC) const; ++ + /// GetProgramPath - Lookup \p Name in the list of program search paths. + /// + /// \param TC - The provided tool chain for additional information on +Index: include/clang/Driver/Options.td +=================================================================== +--- cfe-3.6.1.src/include/clang/Driver/Options.td (revision 211898) ++++ cfe-3.6.1.src/include/clang/Driver/Options.td (working copy) +@@ -1269,6 +1269,8 @@ + HelpText<"Enable Objective-C Ivar layout bitmap print trace">; + def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">, + HelpText<"Print the library path for \"libgcc.a\"">; ++def print_librt_file_name : Flag<["-", "--"], "print-librt-file-name">, ++ HelpText<"Print the library path for \"libclang_rt.builtins-ARCH.a\"">; + def print_multi_directory : Flag<["-", "--"], "print-multi-directory">; + def print_multi_lib : Flag<["-", "--"], "print-multi-lib">; + def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">; +Index: lib/Driver/Driver.cpp +=================================================================== +--- cfe-3.6.1.src/lib/Driver/Driver.cpp (revision 211898) ++++ cfe-3.6.1.src/lib/Driver/Driver.cpp (working copy) +@@ -756,6 +756,11 @@ + return false; + } + ++ if (C.getArgs().hasArg(options::OPT_print_librt_file_name)) { ++ llvm::outs() << GetCompilerRTPath(TC) << "\n"; ++ return false; ++ } ++ + if (C.getArgs().hasArg(options::OPT_print_multi_lib)) { + const MultilibSet &Multilibs = TC.getMultilibs(); + +@@ -1820,6 +1825,26 @@ + return Name; + } + ++std::string Driver::GetCompilerRTPath(const ToolChain &TC) const { ++ // The runtimes are located in the OS-specific resource directory. ++ SmallString<128> Res(TC.getDriver().ResourceDir); ++ const llvm::Triple &Triple = TC.getTriple(); ++ ++ // TC.getOS() yield "freebsd10.0" whereas "freebsd" is expected. ++ StringRef OSLibName = (Triple.getOS() == llvm::Triple::FreeBSD) ? ++ "freebsd" : TC.getOS(); ++ llvm::sys::path::append(Res, "lib", OSLibName); ++ ++ StringRef archName = TC.getArchName(); ++ // Until ARM libraries are build separately, we have them all in one library ++ if (TC.getArch() == llvm::Triple::arm || ++ TC.getArch() == llvm::Triple::armeb) ++ archName = "arm"; ++ ++ llvm::sys::path::append(Res, Twine("libclang_rt.builtins-") + archName + ".a"); ++ return Res.str(); ++} ++ + std::string Driver::GetProgramPath(const char *Name, + const ToolChain &TC) const { + // FIXME: Needs a better variable than DefaultTargetTriple diff --git a/util/crossgcc/sum/cfe-3.6.1.src.tar.xz.cksum b/util/crossgcc/sum/cfe-3.6.1.src.tar.xz.cksum new file mode 100644 index 0000000000..661bf9cbf5 --- /dev/null +++ b/util/crossgcc/sum/cfe-3.6.1.src.tar.xz.cksum @@ -0,0 +1 @@ +b7221d8fdd27e3ed519d0281646e82e17b51122c tarballs/cfe-3.6.1.src.tar.xz diff --git a/util/crossgcc/sum/clang-tools-extra-3.6.1.src.tar.xz.cksum b/util/crossgcc/sum/clang-tools-extra-3.6.1.src.tar.xz.cksum new file mode 100644 index 0000000000..17d55cb49f --- /dev/null +++ b/util/crossgcc/sum/clang-tools-extra-3.6.1.src.tar.xz.cksum @@ -0,0 +1 @@ +d93136f56999d8ae1ffebb9cd0cd7f3c27ba77c4 tarballs/clang-tools-extra-3.6.1.src.tar.xz diff --git a/util/crossgcc/sum/compiler-rt-3.6.1.src.tar.xz.cksum b/util/crossgcc/sum/compiler-rt-3.6.1.src.tar.xz.cksum new file mode 100644 index 0000000000..51e426b333 --- /dev/null +++ b/util/crossgcc/sum/compiler-rt-3.6.1.src.tar.xz.cksum @@ -0,0 +1 @@ +85dccdc6ccd9675e871dfd2786b45fbf53518485 tarballs/compiler-rt-3.6.1.src.tar.xz diff --git a/util/crossgcc/sum/llvm-3.6.1.src.tar.xz.cksum b/util/crossgcc/sum/llvm-3.6.1.src.tar.xz.cksum new file mode 100644 index 0000000000..5ca7065d96 --- /dev/null +++ b/util/crossgcc/sum/llvm-3.6.1.src.tar.xz.cksum @@ -0,0 +1 @@ +01ecab99adc9030ee34e9a2e19e65dfe64e1affe tarballs/llvm-3.6.1.src.tar.xz |