Skip to content

Commit

Permalink
some fixes + fixed clang build
Browse files Browse the repository at this point in the history
  • Loading branch information
niXman committed Jan 13, 2014
1 parent bb482f8 commit b947439
Show file tree
Hide file tree
Showing 43 changed files with 445 additions and 184 deletions.
175 changes: 89 additions & 86 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,37 @@ readonly RUN_ARGS="$@"

while [[ $# > 0 ]]; do
case $1 in
--mode=*)
[[ ! -f $TOP_DIR/scripts/${1/--mode=/}.sh ]] && {
die "bad mode. Script ${1/--mode=/}.sh not found. terminate."
}
readonly BUILD_MODE_VERSION=${1/--mode=/}
readonly BUILD_VERSION=${BUILD_MODE_VERSION#*-}
readonly BUILD_MODE=${BUILD_MODE_VERSION%%-*}
readonly GCC_NAME=$BUILD_MODE_VERSION
[[ $BUILD_MODE != gcc && $BUILD_MODE != clang && $BUILD_MODE != python ]] && {
die "Unsupported mode: \"$BUILD_MODE.\" terminate."
}
[[ $BUILD_MODE == clang ]] && USE_MULTILIB=no
;;
--arch=*)
readonly BUILD_ARCHITECTURE=${1/--arch=/}
case $BUILD_ARCHITECTURE in
i686)
case $EXCEPTIONS_MODEL in
dwarf|sjlj) ;;
*) die "\"$BUILD_ARCHITECTURE\" is not valid architecture model for exception model \"$EXCEPTIONS_MODEL\". terminate." ;;
esac
;;
x86_64)
case $EXCEPTIONS_MODEL in
seh|sjlj) ;;
*) die "\"$BUILD_ARCHITECTURE\" is not valid architecture model for exception model \"$EXCEPTIONS_MODEL\". terminate." ;;
esac
;;
*) die "Unsupported architecture: \"$BUILD_ARCHITECTURE\". terminate." ;;
esac
;;
--march-x32=*) PROCESSOR_OPTIMIZATION_ARCH_32=${1/--march-x32=/} ;;
--mtune-x32=*) PROCESSOR_OPTIMIZATION_TUNE_32=${1/--mtune-x32=/} ;;
--march-x64=*) PROCESSOR_OPTIMIZATION_ARCH_64=${1/--march-x64=/} ;;
Expand Down Expand Up @@ -202,43 +233,6 @@ while [[ $# > 0 ]]; do
;;
esac
;;
--mode=*)
[[ ! -f $TOP_DIR/scripts/${1/--mode=/}.sh ]] && {
die "bad mode. Script ${1/--mode=/}.sh not found. terminate."
}
readonly BUILD_MODE_VERSION=${1/--mode=/}
readonly BUILD_VERSION=${BUILD_MODE_VERSION#*-}
readonly BUILD_MODE=${BUILD_MODE_VERSION%%-*}
readonly GCC_NAME=$BUILD_MODE_VERSION
[[ $BUILD_MODE != gcc && $BUILD_MODE != clang && $BUILD_MODE != python ]] && {
die "Unsupported mode: \"$BUILD_MODE.\" terminate."
}
;;
--arch=*)
readonly BUILD_ARCHITECTURE=${1/--arch=/}
case $BUILD_ARCHITECTURE in
i686)
case $EXCEPTIONS_MODEL in
dwarf|sjlj)
;;
*)
die "\"$BUILD_ARCHITECTURE\" is not valid architecture model for exception model \"$EXCEPTIONS_MODEL\". terminate."
;;
esac
;;
x86_64)
case $EXCEPTIONS_MODEL in
seh|sjlj)
;;
*)
die "\"$BUILD_ARCHITECTURE\" is not valid architecture model for exception model \"$EXCEPTIONS_MODEL\". terminate."
;;
esac
;;
*) die "Unsupported architecture: \"$BUILD_ARCHITECTURE\". terminate."
;;
esac
;;
--rev=*)
REV_NUM=${1/--rev=/}
;;
Expand Down Expand Up @@ -298,57 +292,41 @@ mkdir -p \

source $TOP_DIR/library/os_detect.sh

# **************************************************************************
# Install host toolchains
# **************************************************************************

mkdir -p $TOOLCHAINS_DIR
[[ $? != 0 ]] && {
die "can't create toolchains directory. terminate."
}

func_install_toolchain \
$TOOLCHAINS_DIR \
$i686_HOST_MINGW_PATH \
$x86_64_HOST_MINGW_PATH \
$( echo $i686_HOST_MINGW_PATH_URL | sed "s|{exceptions}|$EXCEPTIONS_MODEL|g" ) \
$( echo $x86_64_HOST_MINGW_PATH_URL | sed "s|{exceptions}|$EXCEPTIONS_MODEL|g" )

# **************************************************************************

[[ -z ${BUILD_ARCHITECTURE} ]] && {
die "Build architecture is not specified. terminate."
}

[[ $BUILD_MODE == gcc ]] && {
[[ $IS_64BIT_HOST == no ]] && {
[[ $BUILD_ARCHITECTURE == x86_64 ]] && {
die "you can't build 64-bit toolchain using 32-bit OS. terminate."
}
[[ $USE_MULTILIB == yes ]] && {
die "you can't build multitarget MinGW using 32-bit OS. terminate."
}
[[ $IS_64BIT_HOST == no ]] && {
[[ $BUILD_ARCHITECTURE == x86_64 ]] && {
die "you can't build 64-bit toolchain using 32-bit OS. terminate."
}
case $EXCEPTIONS_MODEL in
dwarf)
[[ ${BUILD_ARCHITECTURE} == x86_64 ]] && {
die "DWARF exceptions not allowed on x86_64 architecture. terminate."
}
;;
seh)
[[ ${BUILD_ARCHITECTURE} == i686 ]] && {
die "SEH exceptions not allowed on i686 architecture. terminate."
}
;;
sjlj)

;;
esac
[[ $EXCEPTIONS_MODEL != sjlj && $USE_MULTILIB == yes ]] && {
die "\"$EXCEPTIONS_MODEL\" exceptions not allowed on multilib architecture. terminate."
[[ $USE_MULTILIB == yes ]] && {
die "you can't build multitarget MinGW using 32-bit OS. terminate."
}
}

case $EXCEPTIONS_MODEL in
dwarf)
[[ ${BUILD_ARCHITECTURE} == x86_64 ]] && {
die "DWARF exceptions not allowed on x86_64 architecture. terminate."
}
;;
seh)
[[ ${BUILD_ARCHITECTURE} == i686 ]] && {
die "SEH exceptions not allowed on i686 architecture. terminate."
}
;;
sjlj)

;;
esac

[[ $EXCEPTIONS_MODEL != sjlj && $USE_MULTILIB == yes ]] && {
die "\"$EXCEPTIONS_MODEL\" exceptions not allowed on multilib architecture. terminate."
}

[[ $[ $COMPRESSING_BINS == yes || $COMPRESSING_SRCS == yes ] == 1 ]] && {
func_check_program "7za"
}
Expand All @@ -357,11 +335,26 @@ func_install_toolchain \
die "compressing sources for \"$BUILD_MODE\" mode is currently unimplemented. terminate."
}

# **************************************************************************
# Install host toolchains

mkdir -p $TOOLCHAINS_DIR
[[ $? != 0 ]] && {
die "can't create toolchains directory. terminate."
}

func_install_toolchain \
$TOOLCHAINS_DIR \
$i686_HOST_MINGW_PATH \
$x86_64_HOST_MINGW_PATH \
${i686_HOST_MINGW_PATH_URL//"{exceptions}"/$EXCEPTIONS_MODEL} \
${x86_64_HOST_MINGW_PATH_URL//"{exceptions}"/$EXCEPTIONS_MODEL}

# **************************************************************************
# Creating necessary directories

[[ -n $REV_NUM ]] && {
readonly REV_STRING="-r$REV_NUM"
readonly REV_STRING="-rev${REV_NUM}"
} || {
readonly REV_STRING=""
}
Expand Down Expand Up @@ -476,7 +469,7 @@ readonly COMMON_LDFLAGS="$BASE_LDFLAGS -L$LIBS_DIR/lib -L$PREREQ_DIR/${BUILD_ARC
[[ $BUILD_MODE == gcc ]] && {
echo "-> start building $MINGW_BUILD_NAME with \"$ENABLE_LANGUAGES\" languages supported"
} || {
echo "-> start building ${BUILD_MODE_VERSION}-${BUILD_ARCHITECTURE} with \"$ENABLE_LANGUAGES\" languages supported"
echo "-> start building $BUILD_MODE_VERSION-$BUILD_ARCHITECTURE"
}
}

Expand All @@ -485,7 +478,7 @@ readonly COMMON_LDFLAGS="$BASE_LDFLAGS -L$LIBS_DIR/lib -L$PREREQ_DIR/${BUILD_ARC
source $TOP_DIR/library/subtargets.sh

readonly SUBTARGETS=( \
$(fun_get_subtargets \
$(func_get_subtargets \
$BUILD_MODE \
$BUILD_VERSION \
) \
Expand Down Expand Up @@ -545,10 +538,25 @@ for rule in ${SUBTARGETS[@]}; do
func_download \
PKG_URLS[@]

[[ ${#PKG_EXECUTE_AFTER_DOWNLOAD[@]} >0 ]] && {
func_execute \
$SRCS_DIR \
$PKG_DIR_NAME \
"execute commands..." \
"after_download" \
$CURR_LOGS_DIR \
PKG_EXECUTE_AFTER_DOWNLOAD[@]
}

func_uncompress \
PKG_URLS[@]

[[ $FETCH_MODE == no ]] && {
[[ -z $PKG_LNDIR ]] && { PKG_LNDIR=no; }
[[ -z $PKG_CONFIGURE_SCRIPT ]] && { PKG_CONFIGURE_SCRIPT=configure; }
[[ -z $PKG_MAKE_PROG ]] && { PKG_MAKE_PROG=/bin/make; }
[[ -z $PKG_CONFIGURE_PROG ]] && { PKG_CONFIGURE_PROG=/bin/sh; }

[[ ${#PKG_EXECUTE_AFTER_UNCOMPRESS[@]} >0 ]] && {
func_execute \
$SRCS_DIR \
Expand Down Expand Up @@ -576,11 +584,6 @@ for rule in ${SUBTARGETS[@]}; do
PKG_EXECUTE_AFTER_PATCH[@]
}

[[ -z $PKG_LNDIR ]] && { PKG_LNDIR=no; }
[[ -z $PKG_CONFIGURE_SCRIPT ]] && { PKG_CONFIGURE_SCRIPT=configure; }
[[ -z $PKG_MAKE_PROG ]] && { PKG_MAKE_PROG=/bin/make; }
[[ -z $PKG_CONFIGURE_PROG ]] && { PKG_CONFIGURE_PROG=/bin/sh; }

[[ ${#PKG_CONFIGURE_FLAGS[@]} >0 ]] && {
configure_flags="${PKG_CONFIGURE_FLAGS[@]}"
func_configure \
Expand Down
4 changes: 2 additions & 2 deletions library/config-win.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

# **************************************************************************

readonly i686_HOST_MINGW_PATH_URL="http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.8.2/threads-posix/{exceptions}/i686-4.8.2-release-posix-{exceptions}-rt_v3-rev0.7z"
readonly x86_64_HOST_MINGW_PATH_URL="http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.8.2/threads-posix/{exceptions}/x86_64-4.8.2-release-posix-{exceptions}-rt_v3-rev0.7z"
readonly i686_HOST_MINGW_PATH_URL="http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.8.2/threads-posix/{exceptions}/i686-4.8.2-release-posix-{exceptions}-rt_v3-rev2.7z"
readonly x86_64_HOST_MINGW_PATH_URL="http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.8.2/threads-posix/{exceptions}/x86_64-4.8.2-release-posix-{exceptions}-rt_v3-rev2.7z"

# **************************************************************************

Expand Down
4 changes: 3 additions & 1 deletion library/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -819,21 +819,23 @@ function func_test {
}

# **************************************************************************

function func_abstract_toolchain {
# $1 - toolchains top directory
# $2 - toolchain URL
# $3 - install path
# $4 - toolchain arch
local -a _url=( "$2|root:$1" )
local _filename=$(basename $2)
local _do_install=no

echo -e "-> \E[32;40m$4 toolchain\E[37;40m"
[[ ! -f $1/${_filename}-unpack.marker ]] && {
[[ -d $3 ]] && {
echo "--> Found previously installed $4 toolchain."
echo -n "---> Remove previous $4 toolchain..."
rm -rf $3
rm $(dirname $3)/$4-*-unpack.log
rm $(dirname $3)/$4-*-unpack.marker
echo " done"
} || {
echo -n "--> $4 toolchain is not installed "
Expand Down
20 changes: 10 additions & 10 deletions library/subtargets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

# **************************************************************************

function fun_get_subtargets {
function func_get_subtargets {
# $1 - mode (gcc, clang, python)
# $2 - version

Expand Down Expand Up @@ -119,15 +119,6 @@ function fun_get_subtargets {
)

case $1 in
clang)
local readonly SUBTARGETS=(
${CLANG_SUBTARGETS[@]}
cleanup
licenses
build-info
$([[ $COMPRESSING_BINS == yes ]] && echo mingw-compress)
)
;;
gcc)
[[ $USE_MULTILIB == yes ]] && {
local readonly SUBTARGETS=(
Expand All @@ -141,6 +132,15 @@ function fun_get_subtargets {
)
}
;;
clang)
local readonly SUBTARGETS=(
${CLANG_SUBTARGETS[@]}
cleanup
licenses
build-info
$([[ $COMPRESSING_BINS == yes ]] && echo mingw-compress)
)
;;
python)
local readonly SUBTARGETS=(
zlib
Expand Down
20 changes: 20 additions & 0 deletions patches/clang/clang-3.4-enable-tls.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- llvm-3.4/tools/clang/lib/Basic/Targets.cpp.orig 2014-01-10 22:53:00.287255800 +0000
+++ llvm-3.4/tools/clang/lib/Basic/Targets.cpp 2014-01-10 23:21:16.717407800 +0000
@@ -3061,7 +3061,7 @@
public:
WindowsX86_32TargetInfo(const llvm::Triple &Triple)
: WindowsTargetInfo<X86_32TargetInfo>(Triple) {
- TLSSupported = false;
+ TLSSupported = true;
WCharType = UnsignedShort;
DoubleAlign = LongLongAlign = 64;
DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
@@ -3286,7 +3286,7 @@
public:
WindowsX86_64TargetInfo(const llvm::Triple &Triple)
: WindowsTargetInfo<X86_64TargetInfo>(Triple) {
- TLSSupported = false;
+ TLSSupported = true;
WCharType = UnsignedShort;
LongWidth = LongAlign = 32;
DoubleAlign = LongLongAlign = 64;
Loading

0 comments on commit b947439

Please sign in to comment.