summaryrefslogtreecommitdiff
path: root/scripts/crosstool-NG.sh.in
diff options
context:
space:
mode:
authorDaniel Price <daniel.price@gmail.com>2012-11-21 00:59:17 (GMT)
committerDaniel Price <daniel.price@gmail.com>2012-11-21 00:59:17 (GMT)
commit77705cdfe1a9cc404846ab848f2dfadd3acee7bb (patch)
tree069692fcd6aba267cea83e8b64327f227efb00d5 /scripts/crosstool-NG.sh.in
parentb9d836e9e01dfe9a7bf75d68570e1623d4d34ab2 (diff)
scripts: refine static linking check to better guide the user
The current mechanism to check if static linking is possible, and the mesage displayed on failure, can be puzzling to the unsuspecting user. Also, the current implementation is not using the existing infrastructure, and is thus difficult to enhance with new tests. So, switch to using the standard CT_DoExecLog infra, and use four tests to check for the host compiler: - check we can run it - check it can build a trivial program - check it can statically link that program - check if it statically link with libstdc++ That should cover most of the problems. Hopefully. (At the same time, fix a typo in a comment) Signed-off-by: Daniel Price <daniel.price@gmail.com> [yann.morin.1998@free.fr: split original patch for self-contained changes] [yann.morin.1998@free.fr: use steps to better see gcc's output] [yann.morin.1998@free.fr: commit log] Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Message-Id: <163f86b5216fc08c672a.1353459722@nipigon.dssd.com> Patchwork-Id: 200536
Diffstat (limited to 'scripts/crosstool-NG.sh.in')
-rw-r--r--scripts/crosstool-NG.sh.in51
1 files changed, 36 insertions, 15 deletions
diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in
index ae725eb..c15415b 100644
--- a/scripts/crosstool-NG.sh.in
+++ b/scripts/crosstool-NG.sh.in
@@ -423,8 +423,7 @@ if [ -z "${CT_RESTART}" ]; then
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}"
@@ -476,19 +475,6 @@ if [ -z "${CT_RESTART}" ]; then
*) ;;
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 build gcc
# Explicitly optimise, else the lines below will overide the
# package's default optimisation flags
@@ -505,6 +491,8 @@ if [ -z "${CT_RESTART}" ]; then
CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_CFLAGS_FOR_HOST}"
CT_LDFLAGS_FOR_HOST=
CT_LDFLAGS_FOR_HOST+=" ${CT_EXTRA_LDFLAGS_FOR_HOST}"
+ CT_DoLog DEBUG "CFLAGS for host compiler: '${CT_CFLAGS_FOR_HOST}'"
+ CT_DoLog DEBUG "LDFLAGS for host compiler: '${CT_LDFLAGS_FOR_HOST}'"
# Set the shell to be used by ./configure scripts and by Makefiles (those
# that support it!).
@@ -522,6 +510,39 @@ if [ -z "${CT_RESTART}" ]; then
[ ${CT_PARALLEL_JOBS} -gt 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}"
[ ${CT_LOAD} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -l${CT_LOAD}"
+ # 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_DoStep DEBUG "Checking that we can run gcc -v"
+ CT_DoExecLog DEBUG "${CT_HOST}-gcc" -v
+ CT_EndStep
+
+ # 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_DoStep DEBUG "Checking that gcc can compile a trivial program"
+ CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST} "${testc}" -o "${gccout}"
+ rm -f "${gccout}"
+ CT_EndStep
+
+ if [ "${CT_WANTS_STATIC_LINK}" = "y" ]; then
+ CT_DoStep 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} ${CT_LDFLAGS_FOR_HOST} "${testc}" -static -o "${gccout}"
+ rm -f "${gccout}"
+ CT_EndStep
+ fi
+
+ if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
+ CT_DoStep 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} ${CT_LDFLAGS_FOR_HOST} "${testc}" -static -lstdc++ -o "${gccout}"
+ rm -f "${gccout}"
+ CT_EndStep
+ 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"