[PATCH] scripts: refine static linking check to better guide the user
Daniel Price
daniel.price@gmail.com
Wed Nov 21 01:02:00 GMT 2012
# HG changeset patch
# User Daniel Price <daniel.price@gmail.com>
# Date 1353459557 28800
# Node ID 163f86b5216fc08c672a687d549dd90b062c81ef
# Parent 5df2d60ca8476069f3dccf7526940058a47bc837
scripts: refine static linking check to better guide the user
scripts: fail on ':' in paths
Signed-off-by: Daniel Price <daniel.price@gmail.com>
diff -r 5df2d60ca847 -r 163f86b5216f scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in Mon Nov 19 15:23:05 2012 -0800
+++ b/scripts/crosstool-NG.sh.in Tue Nov 20 16:59:17 2012 -0800
@@ -66,6 +66,9 @@
*" "*)
CT_Abort "'CT_${d}_DIR'='${dir}' contains a space in it.\nDon't use spaces in paths, it breaks things."
;;
+ *":"*)
+ CT_Abort "'CT_${d}_DIR'='${dir}' contains a colon in it.\nDon't use colons in paths, it breaks things."
+ ;;
esac
done
@@ -421,8 +424,7 @@
where=$(CT_Which "${tool}")
fi
- # Not all tools are available for all platforms, but some are really,
- # bally needed
+ # Not all tools are available for all platforms, but some are required.
if [ -n "${where}" ]; then
CT_DoLog DEBUG " '${!v}-${tool}' -> '${where}'"
printf "#${BANG}${CT_CONFIG_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_BUILDTOOLS_PREFIX_DIR}/bin/${!v}-${tool}"
@@ -474,25 +476,13 @@
*) ;;
esac
- # Now we know our host and where to find the host tools, we can check
- # if static link was requested, but only if it was requested
- if [ "${CT_WANTS_STATIC_LINK}" = "y" ]; then
- tmp="${CT_BUILD_DIR}/.static-test"
- if ! "${CT_HOST}-gcc" -xc - -static -o "${tmp}" >/dev/null 2>&1 <<-_EOF_
- int main() { return 0; }
- _EOF_
- then
- CT_Abort "Static linking impossible on the host system '${CT_HOST}'"
- fi
- rm -f "${tmp}"
- fi
-
# Help gcc
# Explicitly optimise, else the lines below will overide the
# package's default optimisation flags
CT_CFLAGS_FOR_HOST="-O2 -g"
[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST+=" -pipe"
CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_FLAGS_FOR_HOST}"
+ CT_DoLog DEBUG "gcc CFLAGS for host compiler: ${CT_CFLAGS_FOR_HOST}"
# Set the shell to be used by ./configure scripts and by Makefiles (those
# that support it!).
@@ -510,6 +500,36 @@
[ ${CT_PARALLEL_JOBS} -gt 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}"
[ ${CT_LOAD} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -l${CT_LOAD}"
+ CT_DoLog INFO "Testing host compiler"
+ # Now that we've set up $PATH and $CT_CFLAGS_FOR_HOST, sanity test that gcc
+ # is runnable so that the user can troubleshoot problems if not.
+ CT_DoLog DEBUG "Checking that we can run gcc -v"
+ CT_DoExecLog DEBUG "${CT_HOST}-gcc" -v
+
+ # Create a simple C program for testing.
+ testc="${CT_BUILD_DIR}/.test.c"
+ printf "int main() {return 0; }\n" > "${testc}"
+ gccout="${CT_BUILD_DIR}/.gccout"
+
+ CT_DoLog DEBUG "Checking that gcc can compile a trivial program"
+ CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_HOST} -xc "${testc}" -o "${gccout}"
+ rm -f "${gccout}"
+
+ if [ "${CT_WANTS_STATIC_LINK}" = "y" ]; then
+ CT_DoLog DEBUG "Checking that gcc can compile a trivial statically linked program (CT_WANTS_STATIC_LINK)"
+ CT_DoLog DEBUG "You may need to ensure that static libraries such as libc.a are installed on your system"
+ CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_HOST} -xc "${testc}" -static -o "${gccout}"
+ rm -f "${gccout}"
+ fi
+
+ if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
+ CT_DoLog DEBUG "Checking that gcc can statically link libstdc++ (CT_CC_STATIC_LIBSTDCXX)"
+ CT_DoLog DEBUG "You may need to ensure that libstdc++.a is installed on your system"
+ CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_HOST} -xc "${testc}" -static -lstdc++ -o "${gccout}"
+ rm -f "${gccout}"
+ fi
+ rm -f "${testc}"
+
# We need to save the real .config with kconfig's value,
# not our mangled .config.2 with arrays.
CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration"
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list