fi
}
+validate_opt () {
+ for arg in $CFG_CONFIGURE_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ done
+}
+
valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
local OP=$1
local DEFAULT=$2
shift
}
opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
local OP=$1
local DEFAULT=$2
shift
need_cmd mkdir
need_cmd printf
need_cmd cut
+need_cmd head
need_cmd grep
need_cmd xargs
need_cmd cp
err "unknown CPU type: $CFG_CPUTYPE"
esac
+# Detect 64 bit linux systems with 32 bit userland and force 32 bit compilation
+if [ $CFG_OSTYPE = unknown-linux-gnu -a $CFG_CPUTYPE = x86_64 ]
+then
+ file -L "$SHELL" | grep -q "x86[_-]64"
+ if [ $? != 0 ]; then
+ CFG_CPUTYPE=i686
+ fi
+fi
+
+
DEFAULT_HOST_TRIPLE="${CFG_CPUTYPE}-${CFG_OSTYPE}"
CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
step_msg "processing $CFG_SELF args"
fi
+BOOL_OPTIONS=""
+VAL_OPTIONS=""
+
opt sharedstd 1 "build libstd as a shared library"
-opt valgrind 1 "run tests with valgrind (memcheck by default)"
+opt valgrind 0 "run tests with valgrind (memcheck by default)"
opt helgrind 0 "run tests with helgrind instead of memcheck"
opt docs 1 "build documentation"
opt optimize 1 "build optimized rust code"
opt mingw-cross 0 "cross-compile for win32 using mingw"
opt clang 0 "prefer clang to gcc for building the runtime"
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
+opt pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched kernels)"
valopt prefix "/usr/local" "set installation prefix"
valopt local-rust-root "/usr/local" "set prefix for local rust binary"
valopt llvm-root "" "set LLVM root"
valopt host-triple "${DEFAULT_HOST_TRIPLE}" "LLVM host triple"
valopt target-triples "${CFG_HOST_TRIPLE}" "LLVM target triples"
+# Validate Options
+step_msg "validating $CFG_SELF args"
+validate_opt
+
if [ $HELP -eq 1 ]
then
echo ""
probe CFG_CLANG clang++
probe CFG_GCC gcc
probe CFG_LD ld
-probe CFG_LLVM_CONFIG llvm-config
probe CFG_VALGRIND valgrind
probe CFG_PERF perf
probe CFG_ISCC iscc
probe CFG_XETEX xetex
probe CFG_LUATEX luatex
probe CFG_NODE nodejs node
+if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ]
+then
+ probe CFG_PAXCTL paxctl /sbin/paxctl
+ probe CFG_ZCAT zcat
+fi
if [ ! -z "$CFG_PANDOC" ]
then
- PV=$(pandoc --version | awk '/^pandoc/ {print $2}')
- if [ "$PV" \< "1.8" ]
+ PANDOC_VER_LINE=$(pandoc --version | grep '^pandoc ')
+ PANDOC_VER=${PANDOC_VER_LINE#pandoc }
+ PV_MAJOR_MINOR=${PANDOC_VER%.[0-9]*}
+ PV_MAJOR=${PV_MAJOR_MINOR%%[.][0-9]*}
+ PV_MINOR=${PV_MAJOR_MINOR#[0-9]*[.]}
+ PV_MINOR=${PV_MINOR%%[.][0-9]*}
+ if [ "$PV_MAJOR" -lt "1" ] || [ "$PV_MINOR" -lt "8" ]
then
- step_msg "pandoc $PV is too old. disabling"
- BAD_PANDOC=1
+ step_msg "pandoc $PV_MAJOR.$PV_MINOR is too old. disabling"
+ BAD_PANDOC=1
+ fi
+fi
+
+if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ]
+then
+ if [ ! -z "$CFG_ENABLE_PAX_FLAGS" -a -z "$CFG_PAXCTL" ]
+ then
+ err "enabled PaX markings but no paxctl binary found"
+ fi
+
+ if [ -z "$CFG_DISABLE_PAX_FLAGS" ]
+ then
+ # GRSecurity/PaX detection. This can be very flaky.
+ GRSEC_DETECTED=
+
+ # /dev/grsec only exists if CONFIG_GRKERNSEC_NO_RBAC is not set.
+ # /proc/sys/kernel/grsecurity is not available if ÇONFIG_GRKERNSEC_SYSCTL is not set.
+ if [ -e /dev/grsec -o -d /proc/sys/kernel/grsecurity ]
+ then
+ GRSEC_DETECTED=1
+ # /proc/config.gz is normally only available to root, and only if CONFIG_IKCONFIG_PROC has been set.
+ elif [ -r /proc/config.gz -a ! -z "$CFG_ZCAT" ]
+ then
+ if "$CFG_ZCAT" /proc/config.gz | grep --quiet "CONFIG_GRKERNSEC=y"
+ then
+ GRSEC_DETECTED=1
+ fi
+ # Flaky.
+ elif grep --quiet grsec /proc/version
+ then
+ GRSEC_DETECTED=1
+ fi
+
+ if [ ! -z "$GRSEC_DETECTED" ]
+ then
+ step_msg "GRSecurity: yes"
+ if [ ! -z "$CFG_PAXCTL" ]
+ then
+ CFG_ENABLE_PAX_FLAGS=1
+ else
+ warn "GRSecurity kernel detected but no paxctl binary found: not setting CFG_ENABLE_PAX_FLAGS"
+ fi
+ else
+ step_msg "GRSecurity: no"
+ fi
fi
fi
fi
fi
+# Force freebsd to build with clang; gcc doesn't like us there
+if [ $CFG_OSTYPE = unknown-freebsd ]
+then
+ step_msg "on FreeBSD, forcing use of clang"
+ CFG_ENABLE_CLANG=1
+ putvar CFG_ENABLE_CLANG
+fi
+
+
if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
then
err "either clang or gcc is required"
| cut -d ' ' -f 2)
case $CFG_CLANG_VERSION in
- (3.0svn | 3.0 | 3.1 | 4.0)
+ (3.0svn | 3.0 | 3.1* | 3.2* | 4.0* | 4.1* | 4.2*)
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
CFG_C_COMPILER="clang"
;;
do
make_dir rt/$t
for i in \
- isaac bigint sync test arch/i386 arch/x86_64 \
+ isaac linenoise sync test arch/i386 arch/x86_64 \
libuv libuv/src/ares libuv/src/eio libuv/src/ev
do
make_dir rt/$t/$i
make_dir $h/test/perf
make_dir $h/test/pretty
make_dir $h/test/doc-tutorial
+ make_dir $h/test/doc-tutorial-ffi
+ make_dir $h/test/doc-tutorial-macros
+ make_dir $h/test/doc-tutorial-borrowed-ptr
+ make_dir $h/test/doc-tutorial-tasks
make_dir $h/test/doc-ref
done
msg "git: submodule sync"
"${CFG_GIT}" submodule --quiet sync
+ msg "git: submodule update"
+ "${CFG_GIT}" submodule --quiet update --init
+ need_ok "git failed"
+
+ msg "git: submodule foreach sync"
+ "${CFG_GIT}" submodule --quiet foreach --recursive 'if test -e .gitmodules; then git submodule sync; fi'
+ need_ok "git failed"
+
+ msg "git: submodule foreach update"
+ "${CFG_GIT}" submodule --quiet update --init --recursive
+ need_ok "git failed"
+
# NB: this is just for the sake of getting the submodule SHA1 values
# and status written into the build log.
msg "git: submodule status"
"${CFG_GIT}" submodule status --recursive
- msg "git: submodule update"
- "${CFG_GIT}" submodule --quiet update --init --recursive
- need_ok "git failed"
-
msg "git: submodule clobber"
"${CFG_GIT}" submodule --quiet foreach --recursive git clean -dxf
need_ok "git failed"
then
msg "configuring LLVM for $t"
- LLVM_TARGETS="--enable-targets=x86,x86_64"
+ LLVM_TARGETS="--enable-targets=x86,x86_64,arm"
LLVM_BUILD="--build=$t"
LLVM_HOST="--host=$t"
LLVM_TARGET="--target=$t"
putvar CFG_LIBDIR
putvar CFG_DISABLE_MANAGE_SUBMODULES
+if [ ! -z "$CFG_ENABLE_PAX_FLAGS" ]
+then
+ putvar CFG_ENABLE_PAX_FLAGS
+ putvar CFG_PAXCTL
+fi
+
if [ ! -z $BAD_PANDOC ]
then
CFG_PANDOC=