mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-21 21:57:48 +00:00
scripts: check host features with host compiler
Currently, we check host feature in ./configure. This works only for cross toolchains, but not for canadian toolchains. ./configure has absolutely no way to know what the host for the toolchain will be; only the build scripts know. So, move the headers & libraries checks from ./configure to the build scripts, early enough in the build, but not before we know the host compiler and other tools. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
This commit is contained in:
parent
6e00f49ab4
commit
e2b9a81da3
@ -44,9 +44,8 @@ config CC_STATIC_LIBSTDCXX
|
|||||||
bool
|
bool
|
||||||
prompt "Link libstdc++ statically into the gcc binary"
|
prompt "Link libstdc++ statically into the gcc binary"
|
||||||
default y
|
default y
|
||||||
depends on CONFIGURE_static_link_ok
|
|
||||||
depends on CONFIGURE_has_static_libstdcxx
|
|
||||||
depends on CC_GCC_4_4_or_later
|
depends on CC_GCC_4_4_or_later
|
||||||
|
select WANTS_STATIC_LINK
|
||||||
help
|
help
|
||||||
Newer gcc versions use the PPL library which is C++ code. Statically
|
Newer gcc versions use the PPL library which is C++ code. Statically
|
||||||
linking libstdc++ increases the likeliness that the gcc binary will
|
linking libstdc++ increases the likeliness that the gcc binary will
|
||||||
|
@ -3,18 +3,10 @@
|
|||||||
config STATIC_TOOLCHAIN
|
config STATIC_TOOLCHAIN
|
||||||
select GDB_CROSS_STATIC if GDB_CROSS
|
select GDB_CROSS_STATIC if GDB_CROSS
|
||||||
|
|
||||||
comment "Cross-gdb - disabled (requires expat; re-run ./configure to enable)"
|
|
||||||
depends on !CONFIGURE_has_expat
|
|
||||||
|
|
||||||
comment "Static cross-gdb - disabled (requires static expat; re-run ./configure to enable)"
|
|
||||||
depends on STATIC_TOOLCHAIN && !CONFIGURE_has_static_expat
|
|
||||||
|
|
||||||
config GDB_CROSS
|
config GDB_CROSS
|
||||||
bool
|
bool
|
||||||
prompt "Cross-gdb"
|
prompt "Cross-gdb"
|
||||||
default y
|
default y
|
||||||
depends on CONFIGURE_has_expat
|
|
||||||
depends on !STATIC_TOOLCHAIN || CONFIGURE_has_static_expat
|
|
||||||
select GDB_GDBSERVER if ! BARE_METAL
|
select GDB_GDBSERVER if ! BARE_METAL
|
||||||
help
|
help
|
||||||
Build and install a cross-gdb for the target, to run on host.
|
Build and install a cross-gdb for the target, to run on host.
|
||||||
@ -24,8 +16,7 @@ if GDB_CROSS
|
|||||||
config GDB_CROSS_STATIC
|
config GDB_CROSS_STATIC
|
||||||
bool
|
bool
|
||||||
prompt "Build a static cross gdb"
|
prompt "Build a static cross gdb"
|
||||||
depends on CONFIGURE_static_link_ok
|
select WANTS_STATIC_LINK
|
||||||
depends on CONFIGURE_has_static_expat
|
|
||||||
help
|
help
|
||||||
A static cross gdb can be usefull if you debug on a machine that is
|
A static cross gdb can be usefull if you debug on a machine that is
|
||||||
not the one that is used to compile the toolchain.
|
not the one that is used to compile the toolchain.
|
||||||
@ -36,7 +27,6 @@ config GDB_CROSS_STATIC
|
|||||||
config GDB_CROSS_PYTHON
|
config GDB_CROSS_PYTHON
|
||||||
bool
|
bool
|
||||||
prompt "Enable python scripting"
|
prompt "Enable python scripting"
|
||||||
depends on CONFIGURE_has_python
|
|
||||||
depends on ! GDB_CROSS_STATIC
|
depends on ! GDB_CROSS_STATIC
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
|
@ -10,13 +10,9 @@ config GDB_NATIVE
|
|||||||
|
|
||||||
if GDB_NATIVE
|
if GDB_NATIVE
|
||||||
|
|
||||||
config GDB_NATIVE_NO_STATIC
|
|
||||||
bool
|
|
||||||
|
|
||||||
config GDB_NATIVE_STATIC
|
config GDB_NATIVE_STATIC
|
||||||
bool
|
bool
|
||||||
prompt "Build a static native gdb"
|
prompt "Build a static native gdb"
|
||||||
depends on ! GDB_NATIVE_NO_STATIC
|
|
||||||
help
|
help
|
||||||
In case you have trouble with dynamic loading of shared libraries,
|
In case you have trouble with dynamic loading of shared libraries,
|
||||||
you will find that a static gdb comes in handy.
|
you will find that a static gdb comes in handy.
|
||||||
|
@ -46,20 +46,14 @@ config SYSROOT_DIR_PREFIX
|
|||||||
In fact, the sysroot path is constructed as:
|
In fact, the sysroot path is constructed as:
|
||||||
${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/${CT_SYSROOT_NAME}
|
${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/${CT_SYSROOT_NAME}
|
||||||
|
|
||||||
# In case we need to add more conditions to enable static
|
config WANTS_STATIC_LINK
|
||||||
# toolchain, we'll be adding them here
|
|
||||||
config STATIC_TOOLCHAIN_POSSIBLE
|
|
||||||
bool
|
bool
|
||||||
default y
|
|
||||||
depends on CONFIGURE_static_link_ok
|
|
||||||
depends on CONFIGURE_has_static_libstdcxx
|
|
||||||
# Add new deps here! :-)
|
|
||||||
|
|
||||||
config STATIC_TOOLCHAIN
|
config STATIC_TOOLCHAIN
|
||||||
bool
|
bool
|
||||||
prompt "Build Static Toolchain (EXPERIMENTAL)"
|
prompt "Build Static Toolchain (EXPERIMENTAL)"
|
||||||
depends on EXPERIMENTAL
|
depends on EXPERIMENTAL
|
||||||
depends on STATIC_TOOLCHAIN_POSSIBLE
|
select WANTS_STATIC_LINK
|
||||||
help
|
help
|
||||||
Build static host binaries.
|
Build static host binaries.
|
||||||
|
|
||||||
@ -68,8 +62,9 @@ config STATIC_TOOLCHAIN
|
|||||||
you can say 'Y' here, and all the host tools will be linked statically.
|
you can say 'Y' here, and all the host tools will be linked statically.
|
||||||
|
|
||||||
The impacted tools are:
|
The impacted tools are:
|
||||||
- the GNU binutils
|
- the cross-binutils (GNU binutils, elf2flt)
|
||||||
- the cross-gdb
|
- the cross-compiler (gcc)
|
||||||
|
- the cross-debugger (gdb)
|
||||||
|
|
||||||
The default is 'N', to build dynamicaly-linked host binaries.
|
The default is 'N', to build dynamicaly-linked host binaries.
|
||||||
|
|
||||||
|
70
configure
vendored
70
configure
vendored
@ -534,36 +534,8 @@ case "${host}" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
printf "Checking if static linking is possible... "
|
|
||||||
static_link_ok=""
|
|
||||||
case "${host}" in
|
|
||||||
Darwin) ;;
|
|
||||||
*) tmp=.static.tmp
|
|
||||||
if gcc -xc - -static -o "${tmp}" >/dev/null 2>&1 <<-_EOF_
|
|
||||||
int main() { return 0; }
|
|
||||||
_EOF_
|
|
||||||
then
|
|
||||||
static_link_ok="y"
|
|
||||||
fi
|
|
||||||
rm -f "${tmp}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if [ "${static_link_ok}" = "y" ]; then
|
|
||||||
static_link_ko=""
|
|
||||||
printf "yes\n"
|
|
||||||
else
|
|
||||||
static_link_ko="y"
|
|
||||||
printf "no\n"
|
|
||||||
printf " * An optional host feature is missing, some features will be disabled:\n"
|
|
||||||
printf " * - It will not be possible to statically link toolchain's binaries\n"
|
|
||||||
fi
|
|
||||||
add_to_kconfig_list static_link_ok
|
|
||||||
|
|
||||||
# Library checks
|
# Library checks
|
||||||
libs_exts="so dylib"
|
libs_exts="so dylib a"
|
||||||
if [ "${static_link_ok}" = "y" ]; then
|
|
||||||
libs_exts="${libs_exts} a"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ncurses_hdrs="ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h"
|
ncurses_hdrs="ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h"
|
||||||
ncurses_libs="libncursesw libncurses libcurses"
|
ncurses_libs="libncursesw libncurses libcurses"
|
||||||
@ -572,46 +544,6 @@ has_or_abort lib="${ncurses_libs}" \
|
|||||||
inc="${ncurses_hdrs}" \
|
inc="${ncurses_hdrs}" \
|
||||||
err="The 'ncurses' library is needed fo the menuconfig frontend"
|
err="The 'ncurses' library is needed fo the menuconfig frontend"
|
||||||
|
|
||||||
has_or_abort lib="libstdc++" \
|
|
||||||
lib_exts="${libs_exts}" \
|
|
||||||
err="The 'libstdc++' library is needed to build gcc"
|
|
||||||
|
|
||||||
# Yes, we may be checking twice for libstdc++.a
|
|
||||||
# The first is because we need one instance of libstdc++ (shared or static)
|
|
||||||
# because it is needed for PPL; the second is because the static version is
|
|
||||||
# required for static-linking, and if missing, the option is removed.
|
|
||||||
has_or_warn lib="libstdc++" \
|
|
||||||
lib_exts="a" \
|
|
||||||
err="static 'libstdc++' is needed to statically link the toolchain's executables" \
|
|
||||||
kconfig=has_static_libstdcxx \
|
|
||||||
skip="${static_link_ko}"
|
|
||||||
|
|
||||||
has_or_warn inc="expat.h" \
|
|
||||||
lib="libexpat" \
|
|
||||||
lib_exts="${libs_exts}" \
|
|
||||||
err="The 'expat' header file and library are needed to link cross-gdb's executables" \
|
|
||||||
kconfig=has_expat
|
|
||||||
|
|
||||||
# Yes, we may be checking twice for libexpat.a
|
|
||||||
# The first is because we need one instance of libexpat (shared or static)
|
|
||||||
# because it is needed for cross-gdb; the second is because the static version
|
|
||||||
# is required for static-linking, and if missing, the option is removed.
|
|
||||||
has_or_warn lib="libexpat" \
|
|
||||||
lib_exts="a" \
|
|
||||||
err="static 'expat' is needed to statically link cross-gdb's executables" \
|
|
||||||
kconfig=has_static_expat \
|
|
||||||
skip="${static_link_ko}"
|
|
||||||
|
|
||||||
for v in 7 6 5 4; do
|
|
||||||
python_incs="${python_incs} python2.${v}/Python.h"
|
|
||||||
python_libs="${python_libs} libpython2.${v}"
|
|
||||||
done
|
|
||||||
has_or_warn inc="${python_incs}" \
|
|
||||||
lib="${python_libs}" \
|
|
||||||
lib_exts="${libs_exts}" \
|
|
||||||
kconfig=has_python \
|
|
||||||
err="The 'python' header file and library are needed for some features of cross-gdb"
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------
|
#---------------------------------------------------------------------
|
||||||
# Compute the version string
|
# Compute the version string
|
||||||
|
|
||||||
|
@ -464,6 +464,19 @@ if [ -z "${CT_RESTART}" ]; then
|
|||||||
*) ;;
|
*) ;;
|
||||||
esac
|
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
|
# Help gcc
|
||||||
CT_CFLAGS_FOR_HOST=
|
CT_CFLAGS_FOR_HOST=
|
||||||
[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST+=" -pipe"
|
[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST+=" -pipe"
|
||||||
|
Loading…
Reference in New Issue
Block a user