X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=configure;h=9813f0ec6b6f8e56e905b0197ad72f44ee2b1630;hb=2c46bf7e318f585947c2146ce42c249fba3bc326;hp=70ea7d4b4e2a2aee778510237ce683b21acb01c5;hpb=93a082149ac8735013313604637029659da9ea45;p=rust.git diff --git a/configure b/configure index 70ea7d4b4e2..9813f0ec6b6 100755 --- a/configure +++ b/configure @@ -71,7 +71,7 @@ putvar() { then printf "configure: %-20s := %.35s ...\n" $1 "$T" else - printf "configure: %-20s := %s\n" $1 "$T" + printf "configure: %-20s := %s %s\n" $1 "$T" "$2" fi printf "%-20s := %s\n" $1 "$T" >>config.tmp } @@ -86,13 +86,22 @@ probe() { T=$(which $P 2>&1) if [ $? -eq 0 ] then + VER0=$($P --version 2>/dev/null | head -1 \ + | sed -e 's/[^0-9]*\([vV]\?[0-9.]\+[^ ]*\).*/\1/' ) + if [ $? -eq 0 -a "x${VER0}" != "x" ] + then + VER="($VER0)" + else + VER="" + fi break else + VER="" T="" fi done eval $V=\$T - putvar $V + putvar $V "$VER" } probe_need() { @@ -105,7 +114,38 @@ probe_need() { 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 @@ -136,6 +176,8 @@ valopt() { } opt() { + BOOL_OPTIONS="$BOOL_OPTIONS $1" + local OP=$1 local DEFAULT=$2 shift @@ -178,6 +220,7 @@ need_cmd cmp need_cmd mkdir need_cmd printf need_cmd cut +need_cmd head need_cmd grep need_cmd xargs need_cmd cp @@ -248,11 +291,21 @@ case $CFG_CPUTYPE in 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_SELF=$(echo $0 | tr '\\' '/') -CFG_SRC_DIR=${CFG_SELF%${CFG_SELF##*/}} -CFG_BUILD_DIR=$(echo $PWD | tr '\\' '/') +CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/" +CFG_BUILD_DIR="$(pwd)/" +CFG_SELF=${CFG_SRC_DIR}$(basename $0) CFG_CONFIGURE_ARGS="$@" OPTIONS="" @@ -273,22 +326,33 @@ else 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 optimize-cxx 1 "build optimized C++ code" opt optimize-llvm 1 "build optimized LLVM" +opt debug 0 "build with extra debug fun" opt fast-make 0 "use .gitmodules as timestamp for submodule deps" opt manage-submodules 1 "let the build manage the git submodules" 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 "" @@ -299,8 +363,13 @@ fi step_msg "looking for build programs" probe_need CFG_PERL perl -probe_need CFG_PYTHON python python2.6 python2 python3 probe_need CFG_CURL curl +probe_need CFG_PYTHON python2.7 python2.6 python2 python + +python_version=$($CFG_PYTHON -V 2>&1) +if [ $(echo $python_version | grep -c '^Python 2\.[4567]') -ne 1 ]; then + err "Found $python_version, but LLVM requires Python 2.4-2.7" +fi # If we have no git directory then we are probably a tarball distribution # and shouldn't attempt to load submodules @@ -315,7 +384,7 @@ fi probe CFG_CLANG clang++ probe CFG_GCC gcc -probe CFG_LLVM_CONFIG llvm-config +probe CFG_LD ld probe CFG_VALGRIND valgrind probe CFG_PERF perf probe CFG_ISCC iscc @@ -325,18 +394,92 @@ probe CFG_PDFLATEX pdflatex 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_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 + +if [ ! -z "$CFG_ENABLE_LOCAL_RUST" ] +then + if [ ! -f ${CFG_LOCAL_RUST_ROOT}/bin/rustc ] then - step_msg "pandoc $PV is too old. disabling" - BAD_PANDOC=1 + err "no local rust to use" + else + LRV=`${CFG_LOCAL_RUST_ROOT}/bin/rustc --version` + step_msg "using rustc at: ${CFG_LOCAL_RUST_ROOT} with version: " $LRV 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" @@ -350,7 +493,7 @@ then LLVM_VERSION=$($LLVM_CONFIG --version) case $LLVM_VERSION in - (3.1svn) + (3.1svn|3.1|3.0svn|3.0) msg "found ok version of LLVM: $LLVM_VERSION" ;; (*) @@ -372,7 +515,7 @@ then | cut -d ' ' -f 2) case $CFG_CLANG_VERSION in - (3.0svn | 3.0 | 3.1) + (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" ;; @@ -434,7 +577,7 @@ for t in $CFG_TARGET_TRIPLES 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 @@ -470,12 +613,18 @@ do done make_dir $h/test/run-pass + make_dir $h/test/run-pass-fulldeps make_dir $h/test/run-fail make_dir $h/test/compile-fail make_dir $h/test/bench 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 # Configure submodules @@ -485,45 +634,46 @@ step_msg "configuring submodules" if [ -z $CFG_DISABLE_MANAGE_SUBMODULES ] then cd ${CFG_SRC_DIR} + msg "git: submodule sync" - "${CFG_GIT}" submodule sync --quiet - SUBMODULES=$("${CFG_GIT}" submodule status | awk '{print $2}') - for s in $SUBMODULES - do - msg "git: submodule status ${s}" - status=$("${CFG_GIT}" submodule status ${s} | awk '{print $1}') - case ${status} in - -*) - msg "${s} is not initialized, initializing" - "${CFG_GIT}" submodule init --quiet ${s} - need_ok "git failed" - msg "${s} updating" - "${CFG_GIT}" submodule update --quiet ${s} - need_ok "git failed" - ;; - +*) - msg "${s} is not up to date, updating" - "${CFG_GIT}" submodule update --quiet ${s} - need_ok "git failed" - ;; - *) - msg "${s} is clean" - ;; - esac - done + "${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 clobber" + "${CFG_GIT}" submodule --quiet foreach --recursive git clean -dxf + need_ok "git failed" + "${CFG_GIT}" submodule --quiet foreach --recursive git checkout . + need_ok "git failed" + cd ${CFG_BUILD_DIR} fi # Configure llvm, only if necessary step_msg "looking at LLVM" -CFG_LLVM_SRC_DIR=${CFG_SRC_DIR}src/llvm +CFG_LLVM_SRC_DIR=${CFG_SRC_DIR}src/llvm/ for t in $CFG_TARGET_TRIPLES do do_reconfigure=1 if [ -z $CFG_LLVM_ROOT ] then - LLVM_BUILD_DIR=$CFG_BUILD_DIR/llvm/$t + LLVM_BUILD_DIR=${CFG_BUILD_DIR}llvm/$t if [ ! -z "$CFG_DISABLE_OPTIMIZE_LLVM" ] then LLVM_DBG_OPTS="" @@ -551,7 +701,7 @@ do index2="${CFG_SRC_DIR}src/llvm/.git/index" for index in ${index1} ${index2} do - config_status="${CFG_BUILD_DIR}/llvm/$t/config.status" + config_status="${CFG_BUILD_DIR}llvm/$t/config.status" if test -e ${index} -a \ -e ${config_status} -a \ ${config_status} -nt ${index} @@ -566,13 +716,13 @@ do 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" # Disable unused LLVM features - LLVM_OPTS="$LLVM_DBG_OPTS --disable-docs --disable-jit \ + LLVM_OPTS="$LLVM_DBG_OPTS --disable-docs \ --enable-bindings=none --disable-threads \ --disable-pthreads" @@ -635,10 +785,10 @@ do cd $LLVM_BUILD_DIR case $CFG_SRC_DIR in /* | [a-z]:* | [A-Z]:*) - ${CFG_LLVM_SRC_DIR}/configure $LLVM_FLAGS + ${CFG_LLVM_SRC_DIR}configure $LLVM_FLAGS ;; *) - ${CFG_BUILD_DIR}/${CFG_LLVM_SRC_DIR}/configure \ + ${CFG_BUILD_DIR}${CFG_LLVM_SRC_DIR}configure \ $LLVM_FLAGS ;; esac @@ -672,6 +822,12 @@ putvar CFG_C_COMPILER 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= @@ -704,7 +860,6 @@ do putvar $CFG_LLVM_INST_DIR done - # Munge any paths that appear in config.mk back to posix-y perl -i.bak -p -e 's@ ([a-zA-Z]):[/\\]@ /\1/@go;' \ -e 's@\\@/@go;' config.tmp @@ -714,5 +869,6 @@ msg copy_if_changed ${CFG_SRC_DIR}Makefile.in ./Makefile move_if_changed config.tmp config.mk rm -f config.tmp +touch config.stamp step_msg "complete"