summaryrefslogtreecommitdiff
path: root/scripts/build
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/build')
-rw-r--r--scripts/build/arch.sh51
-rw-r--r--scripts/build/arch/arc.sh50
-rw-r--r--scripts/build/arch/arm.sh7
-rw-r--r--scripts/build/arch/c6x.sh79
-rw-r--r--scripts/build/arch/microblaze.sh15
-rw-r--r--scripts/build/arch/mips.sh11
-rw-r--r--scripts/build/arch/moxie.sh16
-rw-r--r--scripts/build/arch/msp430.sh5
-rw-r--r--scripts/build/arch/nios2.sh10
-rw-r--r--scripts/build/arch/powerpc.sh12
-rw-r--r--scripts/build/arch/pru.sh5
-rw-r--r--scripts/build/arch/riscv.sh5
-rw-r--r--scripts/build/arch/sh.sh191
-rw-r--r--scripts/build/arch/sparc.sh41
-rw-r--r--scripts/build/arch/x86.sh8
-rw-r--r--scripts/build/arch/xtensa.sh72
-rw-r--r--scripts/build/binutils/binutils-ld.in11
-rw-r--r--scripts/build/binutils/binutils.sh165
-rw-r--r--scripts/build/cc.sh58
-rw-r--r--scripts/build/cc/gcc.sh (renamed from scripts/build/cc/100-gcc.sh)685
-rw-r--r--scripts/build/companion_libs/050-zlib.sh55
-rw-r--r--scripts/build/companion_libs/100-gmp.sh59
-rw-r--r--scripts/build/companion_libs/110-mpfr.sh14
-rw-r--r--scripts/build/companion_libs/121-isl.sh21
-rw-r--r--scripts/build/companion_libs/130-cloog.sh24
-rw-r--r--scripts/build/companion_libs/140-mpc.sh13
-rw-r--r--scripts/build/companion_libs/200-libelf.sh11
-rw-r--r--[-rwxr-xr-x]scripts/build/companion_libs/210-expat.sh14
-rw-r--r--scripts/build/companion_libs/220-ncurses.sh52
-rw-r--r--scripts/build/companion_libs/320-libiconv.sh10
-rw-r--r--scripts/build/companion_libs/330-gettext.sh32
-rw-r--r--scripts/build/companion_libs/340-picolibc.sh171
-rw-r--r--scripts/build/companion_libs/350-newlib_nano.sh276
-rw-r--r--scripts/build/companion_libs/400-gnuprumcu.sh88
-rw-r--r--scripts/build/companion_tools.sh2
-rw-r--r--scripts/build/companion_tools/050-make.sh38
-rw-r--r--scripts/build/companion_tools/100-m4.sh31
-rw-r--r--scripts/build/companion_tools/200-autoconf.sh24
-rw-r--r--scripts/build/companion_tools/300-automake.sh24
-rw-r--r--scripts/build/companion_tools/400-libtool.sh24
-rw-r--r--scripts/build/companion_tools/500-dtc.sh87
-rw-r--r--scripts/build/companion_tools/510-bison.sh66
-rw-r--r--scripts/build/debug.sh2
-rw-r--r--scripts/build/debug/000-template.sh34
-rw-r--r--scripts/build/debug/200-duma.sh23
-rw-r--r--scripts/build/debug/300-gdb.sh530
-rw-r--r--scripts/build/debug/400-ltrace.sh47
-rw-r--r--scripts/build/debug/500-strace.sh34
-rw-r--r--scripts/build/internals.sh76
-rw-r--r--scripts/build/kernel/bare-metal.sh12
-rw-r--r--scripts/build/kernel/linux.sh128
-rw-r--r--scripts/build/kernel/windows.sh13
-rw-r--r--scripts/build/libc.sh39
-rw-r--r--scripts/build/libc/avr-libc.sh45
-rw-r--r--scripts/build/libc/bionic.sh34
-rw-r--r--scripts/build/libc/glibc.sh474
-rw-r--r--scripts/build/libc/mingw-w64.sh220
-rw-r--r--scripts/build/libc/mingw.sh178
-rw-r--r--scripts/build/libc/moxiebox.sh79
-rw-r--r--scripts/build/libc/musl.sh140
-rw-r--r--scripts/build/libc/newlib.sh76
-rw-r--r--scripts/build/libc/none.sh18
-rw-r--r--scripts/build/libc/uClibc-ng.sh (renamed from scripts/build/libc/uClibc.sh)295
-rw-r--r--scripts/build/test_suite.sh3
-rw-r--r--scripts/build/test_suite/gcc.sh2
65 files changed, 2932 insertions, 2203 deletions
diff --git a/scripts/build/arch.sh b/scripts/build/arch.sh
index 75d3e21..e7a2efe 100644
--- a/scripts/build/arch.sh
+++ b/scripts/build/arch.sh
@@ -1,20 +1,36 @@
# This file provides the default implementations of arch-specific functions.
# Set up the target tuple
-CT_DoArchTupleValues() {
- :;
+CT_DoArchTupleValues()
+{
+ :
+}
+
+# Adjust the list of multilibs for the target
+CT_DoArchMultilibList()
+{
+ :
}
# Multilib: change the target triplet according to CFLAGS
# Usage: CT_DoArchGlibcAdjustTuple <variable-name> <CFLAGS>
-CT_DoArchMultilibTarget() {
- :;
+CT_DoArchMultilibTarget()
+{
+ :
}
# Multilib: Adjust target tuple for GLIBC
# Usage: CT_DoArchGlibcAdjustTuple <variable-name>
-CT_DoArchGlibcAdjustTuple() {
- :;
+CT_DoArchGlibcAdjustTuple()
+{
+ :
+}
+
+# Multilib: Adjust configure arguments for GLIBC
+# Usage: CT_DoArchGlibcAdjustConfigure <configure-args-array-name> <cflags>
+CT_DoArchGlibcAdjustConfigure()
+{
+ :
}
# Helper for uClibc configurators: select the architecture
@@ -30,20 +46,22 @@ CT_DoArchUClibcSelectArch() {
# uClibc: Adjust configuration file according to the CT-NG configuration
# Usage: CT_DoArchUClibcConfig <config-file>
-CT_DoArchUClibcConfig() {
+CT_DoArchUClibcConfig()
+{
CT_DoLog WARN "Support for '${CT_ARCH}' is not implemented in uClibc config tweaker."
CT_DoLog WARN "Exact configuration file must be provided."
}
# Multilib/uClibc: Adjust configuration file for given CFLAGS
# Usage: CT_DoArchUClibcCflags <config-file> <cflags>
-CT_DoArchUClibcCflags() {
+CT_DoArchUClibcCflags()
+{
local cfg="${1}"
local cflags="${2}"
# Likely, any non-default cflags need to be reflected into the config.
# It may work if we just pass them into EXTRA_CFLAGS, but we have no
- # idea as they might interact with the CFLAGS inferred by uClibc from
+ # idea how they might interact with the CFLAGS inferred by uClibc from
# the configuration file.
if [ "${cflags}" != "" ]; then
CT_DoLog WARN "Multilib configuration not supported for uClibc/${CT_ARCH}"
@@ -52,21 +70,24 @@ CT_DoArchUClibcCflags() {
# Multilib/uClibc: Adjust header installation path for given CFLAGS
# Usage: CT_DoArchUClibcHeaderDir <path-variable> <cflags>
-CT_DoArchUClibcHeaderDir() {
+CT_DoArchUClibcHeaderDir()
+{
# Only needed if a given architecture may select different uClibc architectures.
- :;
+ :
}
# Multilib/MUSL: Adjust header installation path for given CFLAGS
# Usage: CT_DoArchMUSLHeaderDir <path-variable> <cflags>
-CT_DoArchMUSLHeaderDir() {
+CT_DoArchMUSLHeaderDir()
+{
# Only needed if a given architecture may select different MUSL architectures.
- :;
+ :
}
# MUSL: Perform any final adjustments on the installed libc/headers
-CT_DoArchMUSLPostInstall() {
- :;
+CT_DoArchMUSLPostInstall()
+{
+ :
}
# Override from the actual arch implementation as needed.
diff --git a/scripts/build/arch/arc.sh b/scripts/build/arch/arc.sh
new file mode 100644
index 0000000..2312c77
--- /dev/null
+++ b/scripts/build/arch/arc.sh
@@ -0,0 +1,50 @@
+# Compute ARC-specific values
+
+CT_DoArchTupleValues()
+{
+ # The architecture part of the tuple:
+ CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX:-${target_endian_eb}}"
+}
+
+CT_DoArchUClibcConfig()
+{
+ local cfg="${1}"
+
+ CT_DoArchUClibcSelectArch "${cfg}" "arc"
+}
+
+# Multilib: Adjust configure arguments for GLIBC
+# Usage: CT_DoArchGlibcAdjustConfigure <configure-args-array-name> <cflags>
+#
+# From GCC's standpoint ARC's multilib items are defined by "mcpu" values
+# which we have quite a few and for all of them might be built optimized
+# cross-toolchain.
+#
+# From Glibc's standpoint multilib is multi-ABI and so very limited
+# versions are supposed to co-exist.
+#
+# Here we force Glibc to install libraries in per-multilib folder to create
+# a universal cross-toolchain that has libs optimized for multiple CPU types.
+CT_DoArchGlibcAdjustConfigure() {
+ local -a add_args
+ local array="${1}"
+ local cflags="${2}"
+ local opt
+ local mcpu
+
+ # If building for multilib, set proper installation paths
+ if [ "${CT_MULTILIB}" = "y" ]; then
+ for opt in ${cflags}; do
+ case "${opt}" in
+ -mcpu=*)
+ mcpu="${opt#*=}"
+ add_args+=( "libc_cv_rtlddir=/lib/${mcpu}" )
+ add_args+=( "libc_cv_slibdir=/lib/${mcpu}" )
+ add_args+=( "--libdir=/usr/lib/${mcpu}" )
+ ;;
+ esac
+ done
+ fi
+
+ eval "${array}+=( \"\${add_args[@]}\" )"
+}
diff --git a/scripts/build/arch/arm.sh b/scripts/build/arch/arm.sh
index eeffc7d..01a40bd 100644
--- a/scripts/build/arch/arm.sh
+++ b/scripts/build/arch/arm.sh
@@ -15,9 +15,10 @@ CT_DoArchTupleValues() {
# The system part of the tuple:
case "${CT_LIBC},${CT_ARCH_ARM_EABI}" in
- *glibc,y) CT_TARGET_SYS=gnueabi;;
- uClibc,y) CT_TARGET_SYS=uclibc${CT_LIBC_UCLIBC_USE_GNU_SUFFIX:+gnu}eabi;;
+ glibc,y) CT_TARGET_SYS=gnueabi;;
+ uClibc-ng,y)CT_TARGET_SYS=uclibc${CT_LIBC_UCLIBC_USE_GNU_SUFFIX:+gnu}eabi;;
musl,y) CT_TARGET_SYS=musleabi;;
+ bionic,y) CT_TARGET_SYS=androideabi;;
*,y) CT_TARGET_SYS=eabi;;
esac
@@ -69,6 +70,7 @@ CT_DoArchUClibcConfig() {
;;
thumb)
CT_KconfigEnableOption "COMPILE_IN_THUMB_MODE" "${cfg}"
+ CT_KconfigDisableOption "UCLIBC_HAS_CONTEXT_FUNCS" "${cfg}"
;;
esac
# FIXME: CONFIG_ARM_OABI does not exist in neither uClibc/uClibc-ng
@@ -95,6 +97,7 @@ CT_DoArchUClibcCflags() {
case "${f}" in
-mthumb)
CT_KconfigEnableOption "COMPILE_IN_THUMB_MODE" "${cfg}"
+ CT_KconfigDisableOption "UCLIBC_HAS_CONTEXT_FUNCS" "${cfg}"
;;
-marm)
CT_KconfigDisableOption "COMPILE_IN_THUMB_MODE" "${cfg}"
diff --git a/scripts/build/arch/c6x.sh b/scripts/build/arch/c6x.sh
new file mode 100644
index 0000000..3eb40e4
--- /dev/null
+++ b/scripts/build/arch/c6x.sh
@@ -0,0 +1,79 @@
+# Compute c6x-specific values
+
+CT_DoArchUClibcConfig() {
+ local cfg="${1}"
+
+ CT_DoArchUClibcSelectArch "${cfg}" "c6x"
+}
+
+CT_DoArchTupleValues() {
+ CT_TARGET_ARCH="tic6x"
+ #binutils does not like uclibc in the tuple
+ if [ "${CT_TARGET_SYS}" = "uclibc" ]; then
+ CT_TARGET_SYS=
+ fi
+}
+
+CT_DoArchUClibcHeaderDir() {
+ local dir_var="${1}"
+ local cflags="${2}"
+
+ # If it is non-default multilib, add a suffix with architecture (reported by gcc)
+ # to the headers installation path.
+ if [ -n "${cflags}" ]; then
+ eval "${dir_var}="$( ${CT_TARGET}-${CT_CC} -print-multiarch ${cflags} )
+ fi
+}
+
+CT_DoArchUClibcCflags() {
+ local cfg="${1}"
+ local cflags="${2}"
+ local f
+
+ # Set default little endian options
+ CT_KconfigDisableOption "ARCH_BIG_ENDIAN" "${cfg}"
+ CT_KconfigDisableOption "ARCH_WANTS_BIG_ENDIAN" "${cfg}"
+ CT_KconfigEnableOption "ARCH_LITTLE_ENDIAN" "${cfg}"
+ CT_KconfigEnableOption "ARCH_WANTS_LITTLE_ENDIAN" "${cfg}"
+
+ # Set arch options based on march switch
+ CT_KconfigDisableOption "CONFIG_TMS320C674X" "${cfg}"
+ CT_KconfigDisableOption "CONFIG_TMS320C64XPLUS" "${cfg}"
+ CT_KconfigDisableOption "CONFIG_TMS320C64X" "${cfg}"
+ CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}"
+ CT_KconfigEnableOption "CONFIG_GENERIC_C6X" "${cfg}"
+
+ for f in ${cflags}; do
+ case "${f}" in
+ -march=*)
+ case "${f#-march=}" in
+ c674x)
+ CT_KconfigEnableOption "CONFIG_TMS320C674X" "${cfg}"
+ CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${cfg}"
+ CT_KconfigDisableOption "CONFIG_GENERIC_C6X" "${cfg}"
+ ;;
+ c64x+)
+ CT_KconfigEnableOption "CONFIG_TMS320C64XPLUS" "${cfg}"
+ CT_KconfigDisableOption "CONFIG_GENERIC_C6X" "${cfg}"
+ ;;
+ c64x)
+ CT_KconfigEnableOption "CONFIG_TMS320C64X" "${cfg}"
+ CT_KconfigDisableOption "CONFIG_GENERIC_C6X" "${cfg}"
+ ;;
+ c67x)
+ CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${cfg}"
+ ;;
+ c62x)
+ ;;
+ *) CT_Abort "Unsupported architecture: ${f#-march=}";;
+ esac
+ ;;
+ -mbig-endian)
+ CT_KconfigEnableOption "ARCH_BIG_ENDIAN" "${cfg}"
+ CT_KconfigEnableOption "ARCH_WANTS_BIG_ENDIAN" "${cfg}"
+ CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${cfg}"
+ CT_KconfigDisableOption "ARCH_WANTS_LITTLE_ENDIAN" "${cfg}"
+ ;;
+ esac
+ done
+}
diff --git a/scripts/build/arch/microblaze.sh b/scripts/build/arch/microblaze.sh
index e9d9811..5b85012 100644
--- a/scripts/build/arch/microblaze.sh
+++ b/scripts/build/arch/microblaze.sh
@@ -3,21 +3,6 @@
CT_DoArchTupleValues () {
# The architecture part of the tuple:
CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX:-${target_endian_el}}"
-
- # gcc ./configure flags
- CT_ARCH_WITH_ARCH=
- CT_ARCH_WITH_ABI=
- CT_ARCH_WITH_CPU=
- CT_ARCH_WITH_TUNE=
- CT_ARCH_WITH_FPU=
- CT_ARCH_WITH_FLOAT=
-
- # CFLAGS
- case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
- y,) CT_ARCH_FLOAT_CFLAG="-mhard-float" ;;
- ,y) CT_ARCH_FLOAT_CFLAG="-msoft-float" ;;
- esac
-
}
CT_DoArchUClibcConfig() {
diff --git a/scripts/build/arch/mips.sh b/scripts/build/arch/mips.sh
index f91a80a..acb8851 100644
--- a/scripts/build/arch/mips.sh
+++ b/scripts/build/arch/mips.sh
@@ -48,6 +48,17 @@ CT_DoArchUClibcConfig() {
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64R2" "${cfg}"
}
+CT_DoArchUClibcHeaderDir() {
+ local dir_var="${1}"
+ local cflags="${2}"
+
+ # If it is non-default multilib, add a suffix with architecture (reported by gcc)
+ # to the headers installation path.
+ if [ -n "${cflags}" ]; then
+ eval "${dir_var}="$( ${CT_TARGET}-${CT_CC} -print-multiarch ${cflags} )
+ fi
+}
+
CT_DoArchUClibcCflags() {
local cfg="${1}"
local cflags="${2}"
diff --git a/scripts/build/arch/moxie.sh b/scripts/build/arch/moxie.sh
new file mode 100644
index 0000000..9545d19
--- /dev/null
+++ b/scripts/build/arch/moxie.sh
@@ -0,0 +1,16 @@
+# Moxie-specific arch callbacks
+
+# No arch-specific overrides yet
+CT_DoArchTupleValues()
+{
+ case "${CT_ARCH_ENDIAN}" in
+ big) CT_ARCH_ENDIAN_CFLAG=-meb;;
+ little) CT_ARCH_ENDIAN_CFLAG=-mel;;
+ esac
+
+ case "${CT_LIBC}" in
+ moxiebox)
+ CT_TARGET_SYS=moxiebox
+ ;;
+ esac
+}
diff --git a/scripts/build/arch/msp430.sh b/scripts/build/arch/msp430.sh
new file mode 100644
index 0000000..8edb72a
--- /dev/null
+++ b/scripts/build/arch/msp430.sh
@@ -0,0 +1,5 @@
+# Compute MSP430-specific values
+
+CT_DoArchTupleValues() {
+ CT_TARGET_ARCH="${CT_ARCH}"
+}
diff --git a/scripts/build/arch/nios2.sh b/scripts/build/arch/nios2.sh
index 24c556b..afd73ec 100644
--- a/scripts/build/arch/nios2.sh
+++ b/scripts/build/arch/nios2.sh
@@ -1,12 +1,6 @@
# Compute NIOS2-specific values
CT_DoArchTupleValues() {
- # gcc ./configure flags
- CT_ARCH_WITH_ARCH=
- CT_ARCH_WITH_ABI=
- CT_ARCH_WITH_CPU=
- CT_ARCH_WITH_TUNE=
- CT_ARCH_WITH_FPU=
- CT_ARCH_WITH_FLOAT=
- CT_TARGET_SYS=elf
+ # Do nothing here. Default values are sane.
+ :;
}
diff --git a/scripts/build/arch/powerpc.sh b/scripts/build/arch/powerpc.sh
index 52f3f8b..245adbe 100644
--- a/scripts/build/arch/powerpc.sh
+++ b/scripts/build/arch/powerpc.sh
@@ -7,23 +7,23 @@ CT_DoArchTupleValues () {
# Only override values when ABI is not the default
case "${CT_ARCH_powerpc_ABI}" in
eabi)
- # EABI is only for bare-metal, so libc ∈ [none,newlib]
+ # EABI is only for bare-metal, so libc ∈ [none,newlib,picolibc]
CT_TARGET_SYS="eabi"
;;
spe)
case "${CT_LIBC}" in
- none|newlib) CT_TARGET_SYS="spe";;
+ none|newlib|picolibc) CT_TARGET_SYS="elfspe";;
*glibc) CT_TARGET_SYS="gnuspe";;
- uClibc) CT_TARGET_SYS="uclibcgnuspe";;
+ uClibc-ng) CT_TARGET_SYS="uclibcgnuspe";;
esac
;;
esac
- # Add extra flags for SPE if needed
+ # Add extra flags for SPE if needed. SPE is obsolete in GCC8.
if [ "${CT_ARCH_powerpc_ABI_SPE}" = "y" ]; then
CT_ARCH_TARGET_CFLAGS="-mabi=spe -mspe"
- CT_ARCH_CC_CORE_EXTRA_CONFIG="--enable-e500_double"
- CT_ARCH_CC_EXTRA_CONFIG="--enable-e500_double"
+ CT_ARCH_CC_CORE_EXTRA_CONFIG="--enable-e500_double --enable-obsolete"
+ CT_ARCH_CC_EXTRA_CONFIG="--enable-e500_double --enable-obsolete"
fi
}
diff --git a/scripts/build/arch/pru.sh b/scripts/build/arch/pru.sh
new file mode 100644
index 0000000..c4d61ce
--- /dev/null
+++ b/scripts/build/arch/pru.sh
@@ -0,0 +1,5 @@
+# Compute PRU-specific values
+
+CT_DoArchTupleValues() {
+ CT_TARGET_ARCH="${CT_ARCH}"
+}
diff --git a/scripts/build/arch/riscv.sh b/scripts/build/arch/riscv.sh
new file mode 100644
index 0000000..a0a5ba4
--- /dev/null
+++ b/scripts/build/arch/riscv.sh
@@ -0,0 +1,5 @@
+# Compute RISC-V-specific values
+
+CT_DoArchTupleValues() {
+ CT_TARGET_ARCH="riscv${CT_ARCH_BITNESS}"
+}
diff --git a/scripts/build/arch/sh.sh b/scripts/build/arch/sh.sh
index 6761435..8339b94 100644
--- a/scripts/build/arch/sh.sh
+++ b/scripts/build/arch/sh.sh
@@ -1,50 +1,171 @@
# Compute sh-specific values
CT_DoArchTupleValues () {
- # The architecture part of the tuple:
- CT_TARGET_ARCH="${CT_ARCH_SH_VARIANT}${CT_ARCH_SUFFIX:-${target_endian_eb}}"
-
- # gcc ./configure flags
- CT_ARCH_WITH_ARCH=
- CT_ARCH_WITH_ABI=
- CT_ARCH_WITH_CPU=
- CT_ARCH_WITH_TUNE=
- CT_ARCH_WITH_FPU=
- CT_ARCH_WITH_FLOAT=
-
- # Endianness stuff
+ # The architecture part of the tuple. Binutils do not accept specifications
+ # like 'sheb-unknown-elf' even though GCC does. So keep the tuple just sh-*-elf
+ # unless user wants something specific (either CPU or explicit suffix).
+ if [ "${CT_ARCH_SH_VARIANT}" != "sh" -o -n "${CT_ARCH_SUFFIX}" ]; then
+ CT_TARGET_ARCH="${CT_ARCH_SH_VARIANT}${CT_ARCH_SUFFIX:-${target_endian_eb}}"
+ fi
+
+ # Endianness stuff (uses non-standard CFLAGS). If both are compiled, let the
+ # compiler's default or multilib iterator be used.
case "${CT_ARCH_ENDIAN}" in
big) CT_ARCH_ENDIAN_CFLAG=-mb;;
little) CT_ARCH_ENDIAN_CFLAG=-ml;;
esac
- # CFLAGS
+ # Instead of -m{soft,hard}-float, uses CPU type
+ CT_ARCH_FLOAT_CFLAG=
case "${CT_ARCH_SH_VARIANT}" in
sh3) CT_ARCH_ARCH_CFLAG=-m3;;
- sh4*)
+ sh4*|sh2*)
# softfp is not possible for SuperH, no need to test for it.
case "${CT_ARCH_FLOAT}" in
hard)
- CT_ARCH_ARCH_CFLAG="-m4${CT_ARCH_SH_VARIANT##sh?}"
+ CT_ARCH_ARCH_CFLAG="-m${CT_ARCH_SH_VARIANT##sh}"
;;
soft)
- CT_ARCH_ARCH_CFLAG="-m4${CT_ARCH_SH_VARIANT##sh?}-nofpu"
+ CT_ARCH_ARCH_CFLAG="-m${CT_ARCH_SH_VARIANT##sh}-nofpu"
;;
esac
;;
esac
- CT_ARCH_FLOAT_CFLAG=
+}
+
+CT_DoArchMultilibList() {
+ local save_ifs="${IFS}"
+ local new
+ local x
+
+ # In a configuration for SuperH, GCC list of multilibs shall not include
+ # the default CPU. E.g. if configuring for sh4-*-*, we need to remove
+ # "sh4" or "m4" from the multilib list. Otherwise, the resulting compiler
+ # will fail when that CPU is selected explicitly "sh4-multilib-linux-gnu-gcc -m4 ..."
+ # as it will fail to find the sysroot with that suffix. This applies to both
+ # the CPU type inferred from the target tuple (CT_ARCH_SH_VARIANT) as well as
+ # the default CPU configured with --with-cpu (CT_ARCH_CPU).
+ IFS=,
+ for x in ${CT_CC_GCC_MULTILIB_LIST}; do
+ if [ "${x}" = "${CT_ARCH_SH_VARIANT}" -o "sh${x#m}" = "${CT_ARCH_SH_VARIANT}" ]; then
+ CT_DoLog WARN "Ignoring '${x}' in multilib list: it is the default multilib"
+ continue
+ fi
+ if [ "${x}" = "${CT_ARCH_CPU}" -o "sh${x#m}" = "${CT_ARCH_CPU}" ]; then
+ CT_DoLog WARN "Ignoring '${x}' in multilib list: it is the default multilib"
+ continue
+ fi
+ new="${new:+${new},}${x}"
+ done
+ IFS="${save_ifs}"
+ CT_CC_GCC_MULTILIB_LIST="${new}"
+ CT_DoLog DEBUG "Adjusted CT_CC_GCC_MULTILIB_LIST to '${CT_CC_GCC_MULTILIB_LIST}'"
+}
+
+#------------------------------------------------------------------------------
+# Get multilib architecture-specific target
+# Usage: CT_DoArchMultilibTarget "target variable" "multilib flags"
+CT_DoArchMultilibTarget ()
+{
+ local target_var="${1}"; shift
+ local -a multi_flags=( "$@" )
+ local target_
+ local newcpu
+
+ for m in "${multi_flags[@]}"; do
+ case "${m}" in
+ -m4*) newcpu=sh4;;
+ -m3*) newcpu=sh3;;
+ -m2*) newcpu=sh2;;
+ -m1*) newcpu=sh1;;
+ esac
+ done
+
+ eval target_=\"\${${target_var}}\"
+
+ # Strip CPU name and append the new one if an option has been seen.
+ if [ -n "${newcpu}" ]; then
+ target_="${newcpu}-${target_#*-}"
+ fi
+
+ # Set the target variable
+ eval ${target_var}=\"${target_}\"
+}
+
+# Adjust target tuple for GLIBC
+CT_DoArchGlibcAdjustTuple() {
+ local target_var="${1}"
+ local target_
+
+ eval target_=\"\${${target_var}}\"
+
+ case "${target_}" in
+ sh-*)
+ # Glibc does not build unless configured with 'shX-*' tuple.
+ # Since we ended up here, no architecture variant has been
+ # specified, so the only source of default is CT_ARCH_CPU.
+ # GCC defaults to sh1, but this Glibc cannot compile for it.
+ if [ -n "${CT_ARCH_CPU}" ]; then
+ target_=${target_/#sh-/${CT_ARCH_CPU}-}
+ CT_DoLog DEBUG "Adjusted target tuple ${target_}"
+ else
+ CT_Abort "GNU C library cannot build for sh1 (GCC default). " \
+ "Specify architecture variant or the default CPU type."
+ fi
+ ;;
+ esac
+
+ # Set the target variable
+ eval ${target_var}=\"${target_}\"
+}
+
+# Multilib: Adjust configure arguments for GLIBC
+# Usage: CT_DoArchGlibcAdjustConfigure <configure-args-array-name> <cflags>
+CT_DoArchGlibcAdjustConfigure() {
+ local -a add_args
+ local array="${1}"
+ local cflags="${2}"
+ local opt
+
+ for opt in ${cflags}; do
+ case "${opt}" in
+ -m[1-5]*-nofpu)
+ add_args+=( "--without-fp" )
+ ;;
+ -m[1-5]*)
+ add_args+=( "--with-fp" )
+ ;;
+ esac
+ done
+
+ # If architecture variant was specified, we'd have CT_ARCH_ARCH_CFLAG
+ # and it would've been handled above. Our last resort: CT_ARCH_CPU
+ if [ "${#add_args[@]}" = 0 ]; then
+ case "${CT_ARCH_CPU}" in
+ sh[34]*-nofpu)
+ add_args+=( "--without-fp" )
+ ;;
+ sh[34]*)
+ add_args+=( "--with-fp" )
+ ;;
+ esac
+ fi
+
+ eval "${array}+=( \"\${add_args[@]}\" )"
}
CT_DoArchUClibcConfig() {
local cfg="${1}"
- # FIXME: uclibc (!ng) seems to support sh64 (sh5), too
CT_DoArchUClibcSelectArch "${cfg}" "sh"
+ CT_KconfigDisableOption "CONFIG_SH2" "${cfg}"
+ CT_KconfigDisableOption "CONFIG_SH2A" "${cfg}"
CT_KconfigDisableOption "CONFIG_SH3" "${cfg}"
CT_KconfigDisableOption "CONFIG_SH4" "${cfg}"
CT_KconfigDisableOption "CONFIG_SH4A" "${cfg}"
case "${CT_ARCH_SH_VARIANT}" in
+ sh2) CT_KconfigEnableOption "CONFIG_SH2" "${cfg}";;
+ sh2a) CT_KconfigEnableOption "CONFIG_SH2A" "${cfg}";;
sh3) CT_KconfigEnableOption "CONFIG_SH3" "${cfg}";;
sh4) CT_KconfigEnableOption "CONFIG_SH4" "${cfg}";;
sh4a) CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}";;
@@ -58,6 +179,36 @@ CT_DoArchUClibcCflags() {
for f in ${cflags}; do
case "${f}" in
+ -ml)
+ CT_KconfigDisableOption "ARCH_BIG_ENDIAN" "${dst}"
+ CT_KconfigDisableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}"
+ CT_KconfigEnableOption "ARCH_LITTLE_ENDIAN" "${dst}"
+ CT_KconfigEnableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}"
+ ;;
+ -mb)
+ CT_KconfigEnableOption "ARCH_BIG_ENDIAN" "${dst}"
+ CT_KconfigEnableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}"
+ CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${dst}"
+ CT_KconfigDisableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}"
+ ;;
+ -m2|-m2a|-m2a-nofpu|-m3|-m4|-m4-nofpu|-m4a|-m4a-nofpu)
+ CT_KconfigDisableOption "CONFIG_SH2" "${cfg}"
+ CT_KconfigDisableOption "CONFIG_SH2A" "${cfg}"
+ CT_KconfigDisableOption "CONFIG_SH3" "${cfg}"
+ CT_KconfigDisableOption "CONFIG_SH4" "${cfg}"
+ CT_KconfigDisableOption "CONFIG_SH4A" "${cfg}"
+ CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}"
+ case "${f}" in
+ -m2)
+ CT_KconfigEnableOption "CONFIG_SH2" "${cfg}"
+ ;;
+ -m2a)
+ CT_KconfigEnableOption "CONFIG_SH2A" "${cfg}"
+ CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${cfg}"
+ ;;
+ -m2a-nofpu)
+ CT_KconfigEnableOption "CONFIG_SH2A" "${cfg}"
+ ;;
-m3)
CT_KconfigEnableOption "CONFIG_SH3" "${cfg}"
;;
@@ -67,7 +218,6 @@ CT_DoArchUClibcCflags() {
;;
-m4-nofpu)
CT_KconfigEnableOption "CONFIG_SH4" "${cfg}"
- CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}"
;;
-m4a)
CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}"
@@ -75,8 +225,9 @@ CT_DoArchUClibcCflags() {
;;
-m4a-nofpu)
CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}"
- CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}"
;;
+ esac
+ ;;
esac
done
}
diff --git a/scripts/build/arch/sparc.sh b/scripts/build/arch/sparc.sh
index 74f6f78..22d98e4 100644
--- a/scripts/build/arch/sparc.sh
+++ b/scripts/build/arch/sparc.sh
@@ -3,17 +3,32 @@ CT_DoArchTupleValues() {
# That's the only thing to override
CT_TARGET_ARCH="sparc${target_bits_64}${CT_ARCH_SUFFIX}"
- # By default, sparc64-*-linux is configured with -mcpu=v9. However,
- # according to https://sourceware.org/ml/libc-alpha/2005-12/msg00027.html,
- # "There is no Linux sparc64 port that runs on non-UltraSPARC-I+ ISA CPUs."
- # There is a patch that would change the default to -mcpu=ultrasparc for
- # sparc64-*-linux configuration: https://patchwork.ozlabs.org/patch/409424/
- # but that patch has not been integrated (yet). One concern raised about
- # this patch was that -mcpu=ultrasparc can suboptimally schedule instructions
- # for newer SPARC CPUs. So, override to -mcpu=ultrasparc and warn the user.
- if [ "${CT_KERNEL}" = "linux" -a "${CT_ARCH_64}" = "y" -a -z "${CT_ARCH_CPU}" ]; then
- CT_DoLog WARN "Setting CPU to UltraSPARC-I for sparc64-linux. Set CT_ARCH_CPU if a different CPU is desired."
- CT_ARCH_WITH_CPU="--with-cpu=ultrasparc"
+ if [ "${CT_KERNEL}" = "linux" -a -z "${CT_ARCH_CPU}" ]; then
+ if [ "${CT_ARCH_64}" = "y" ]; then
+ # By default, sparc64-*-linux is configured with -mcpu=v9. However,
+ # according to https://sourceware.org/ml/libc-alpha/2005-12/msg00027.html,
+ # "There is no Linux sparc64 port that runs on non-UltraSPARC-I+ ISA CPUs."
+ # There is a patch that would change the default to -mcpu=ultrasparc for
+ # sparc64-*-linux configuration: https://patchwork.ozlabs.org/patch/409424/
+ # but that patch has not been integrated (yet). One concern raised about
+ # this patch was that -mcpu=ultrasparc can suboptimally schedule instructions
+ # for newer SPARC CPUs. So, override to -mcpu=ultrasparc and warn the user.
+ CT_DoLog WARN "Setting CPU to UltraSPARC-I for sparc64-linux. Set CT_ARCH_CPU if a different CPU is desired."
+ CT_ARCH_WITH_CPU="--with-cpu=ultrasparc"
+ if [ -n "${CT_ARCH_SUPPORTS_WITH_32_64}" -a -n "${CT_MULTILIB}" ]; then
+ CT_ARCH_WITH_CPU_32="--with-cpu-32=ultrasparc"
+ CT_ARCH_WITH_CPU_64="--with-cpu-64=ultrasparc"
+ fi
+ else
+ # Similarly, sparc-*-linux defaults to v7. GLIBC 2.31 started to reject
+ # pre-v8 configurations with 2.31, and default v8 fails a subsequent test for
+ # using atomics (which are presumably, only available on some v8 CPUs).
+ # Therefore, default to v9.
+ if [ -z "${CT_GLIBC_SPARC_ALLOW_V7}" ]; then
+ CT_DoLog WARN "Setting CPU to V9 for sparc-linux. Set CT_ARCH_CPU if a different CPU is desired."
+ CT_ARCH_WITH_CPU="--with-cpu=v9"
+ fi
+ fi
fi
}
@@ -60,8 +75,8 @@ CT_DoArchGlibcAdjustTuple() {
# earlier (corresponding pthread barrier code is missing). Until this
# support is reintroduced, configure as sparcv9.
sparc-*)
- if [ "${CT_LIBC_GLIBC_2_23_or_later}" = y ]; then
- CT_DoLog WARN "GLIBC 2.23 only supports SPARCv9"
+ if [ "${CT_GLIBC_NO_SPARC_V8}" = y ]; then
+ CT_DoLog WARN "GLIBC 2.23 and newer only support SPARCv9"
target_=${target_/#sparc-/sparcv9-}
fi
;;
diff --git a/scripts/build/arch/x86.sh b/scripts/build/arch/x86.sh
index 3a7a2ce..0538d66 100644
--- a/scripts/build/arch/x86.sh
+++ b/scripts/build/arch/x86.sh
@@ -10,7 +10,11 @@ CT_DoArchTupleValues() {
arch="${CT_ARCH_ARCH}"
[ -z "${arch}" ] && arch="${CT_ARCH_TUNE}"
case "${arch}" in
- "") CT_TARGET_ARCH=i386;;
+ "")
+ CT_DoLog WARN "Architecture level is not specified for 32-bit x86; defaulting to i386."
+ CT_DoLog WARN "This may not be supported by the C library."
+ CT_TARGET_ARCH=i386
+ ;;
i386|i486|i586|i686) CT_TARGET_ARCH="${arch}";;
winchip*) CT_TARGET_ARCH=i486;;
pentium|pentium-mmx|c3*) CT_TARGET_ARCH=i586;;
@@ -86,7 +90,7 @@ CT_DoArchGlibcAdjustTuple() {
# x86 quirk: architecture name is i386, but glibc expects i[4567]86 - to
# indicate the desired optimization. If it was a multilib variant of x86_64,
# then it targets at least NetBurst a.k.a. i786, but we'll follow the model
- # above # and set the optimization to i686. Otherwise, replace with the most
+ # above and set the optimization to i686. Otherwise, replace with the most
# conservative choice, i486.
i386-*)
if [ "${CT_TARGET_ARCH}" = "x86_64" ]; then
diff --git a/scripts/build/arch/xtensa.sh b/scripts/build/arch/xtensa.sh
index bf94ddf..d0ba6f5 100644
--- a/scripts/build/arch/xtensa.sh
+++ b/scripts/build/arch/xtensa.sh
@@ -1,79 +1,15 @@
# Compute Xtensa-specific values
-CT_DoArchTupleValues() {
+CT_DoArchTupleValues()
+{
# The architecture part of the tuple:
CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX}"
CT_ARCH_ENDIAN_CFLAG=""
CT_ARCH_ENDIAN_LDFLAG=""
- # The system part of the tuple:
- case "${CT_LIBC}" in
- *glibc) CT_TARGET_SYS=gnu;;
- uClibc) CT_TARGET_SYS=uclibc;;
- esac
}
-# This function updates the specified component (binutils, gcc, gdb, etc.)
-# with the processor specific configuration.
-CT_ConfigureXtensa() {
- local component="${1}"
- local version="${2}"
- local custom_overlay="xtensa_${CT_ARCH_XTENSA_CUSTOM_NAME}.tar"
- local custom_location="${CT_ARCH_XTENSA_CUSTOM_OVERLAY_LOCATION}"
-
- if [ -z "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then
- custom_overlay="xtensa-overlay.tar"
- fi
-
- CT_TestAndAbort "${custom_overlay}: CT_ARCH_XTENSA_CUSTOM_OVERLAY_LOCATION must be set." -z "${custom_location}"
-
- local full_file="${custom_location}/${custom_overlay}"
- local basename="${component}-${version}"
- local ext
-
- ext=${full_file/*./.}
-
- if [ -z "${ext}" ] ; then
- CT_DoLog WARN "'${full_file}' not found"
- return 1
- fi
-
- if [ -e "${CT_SRC_DIR}/.${basename}.configuring" ]; then
- CT_DoLog ERROR "The '${basename}' source were partially configured."
- CT_DoLog ERROR "Please remove first:"
- CT_DoLog ERROR " - the source dir for '${basename}', in '${CT_SRC_DIR}'"
- CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.extracted'"
- CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.patch'"
- CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.configuring'"
- CT_Abort
- fi
-
- CT_DoLog EXTRA "Using '${custom_overlay}' from ${custom_location}"
- CT_DoExecLog DEBUG ln -sf "${custom_location}/${custom_overlay}" \
- "${CT_TARBALLS_DIR}/${custom_overlay}"
-
- CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.configuring"
-
- CT_Pushd "${CT_SRC_DIR}/${basename}"
-
- tar_opts=( "--strip-components=1" )
- tar_opts+=( "-xv" )
-
- case "${ext}" in
- .tar) CT_DoExecLog FILE tar "${tar_opts[@]}" -f "${full_file}" "${component}";;
- .gz|.tgz) gzip -dc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f - "${component}";;
- .bz2) bzip2 -dc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f - "${component}";;
- *) CT_DoLog WARN "Don't know how to handle '${basename}${ext}': unknown extension"
- return 1
- ;;
- esac
-
- CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.configured"
- CT_DoExecLog DEBUG rm -f "${CT_SRC_DIR}/.${basename}.configuring"
-
- CT_Popd
-}
-
-CT_DoArchUClibcConfig() {
+CT_DoArchUClibcConfig()
+{
local cfg="${1}"
CT_DoArchUClibcSelectArch "${cfg}" "xtensa"
diff --git a/scripts/build/binutils/binutils-ld.in b/scripts/build/binutils/binutils-ld.in
deleted file mode 100644
index 30f4591..0000000
--- a/scripts/build/binutils/binutils-ld.in
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-call_to=@@DEFAULT_LD@@
-
-case "${CTNG_LD_IS}" in
- bfd) call_to=bfd;;
- gold) call_to=gold;;
-esac
-
-exec "${0}.${call_to}" "$@"
-exit $?
diff --git a/scripts/build/binutils/binutils.sh b/scripts/build/binutils/binutils.sh
index f9c5fe7..b16be90 100644
--- a/scripts/build/binutils/binutils.sh
+++ b/scripts/build/binutils/binutils.sh
@@ -4,44 +4,17 @@
# Download binutils
do_binutils_get() {
- if [ "${CT_BINUTILS_CUSTOM}" = "y" ]; then
- CT_GetCustom "binutils" "${CT_BINUTILS_CUSTOM_VERSION}" \
- "${CT_BINUTILS_CUSTOM_LOCATION}"
- else
- case "${CT_BINUTILS_VERSION}" in
- linaro-*)
- CT_GetLinaro "binutils" "${CT_BINUTILS_VERSION}"
- ;;
- *)
- CT_GetFile "binutils-${CT_BINUTILS_VERSION}" \
- {http,ftp}://{ftp.gnu.org/gnu,ftp.kernel.org/pub/linux/devel}/binutils \
- ftp://{sourceware.org,gcc.gnu.org}/pub/binutils/{releases,snapshots}
- ;;
- esac
- fi
-
+ CT_Fetch BINUTILS
if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
- if [ "${CT_ELF2FLT_CUSTOM}" = "y" ]; then
- CT_GetCustom "elf2flt" "${CT_ELF2FLT_CUSTOM_VERSION}" \
- "${CT_ELF2FLT_CUSTOM_LOCATION}"
- else
- CT_GetGit elf2flt "${CT_ELF2FLT_GIT_CSET}" https://github.com/uclinux-dev/elf2flt.git
- fi
+ CT_Fetch ELF2FLT
fi
}
# Extract binutils
do_binutils_extract() {
- CT_Extract "binutils-${CT_BINUTILS_VERSION}"
- CT_Patch "binutils" "${CT_BINUTILS_VERSION}"
-
+ CT_ExtractPatch BINUTILS
if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
- CT_Extract "elf2flt-${CT_ELF2FLT_GIT_CSET}"
- CT_Patch "elf2flt" "${CT_ELF2FLT_GIT_CSET}"
- fi
-
- if [ -n "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then
- CT_ConfigureXtensa "binutils" "${CT_BINUTILS_VERSION}"
+ CT_ExtractPatch ELF2FLT
fi
}
@@ -67,7 +40,7 @@ do_binutils_for_build() {
if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
# We re-use binutils' options, plus our owns
- binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}" )
+ binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils" )
binutils_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-build-${CT_BUILD}" )
CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-build-${CT_BUILD}"
@@ -82,7 +55,6 @@ do_binutils_for_build() {
# Build binutils for host -> target
do_binutils_for_host() {
- local -a binutils_tools
local -a binutils_opts
CT_DoStep INFO "Installing binutils for host"
@@ -101,7 +73,7 @@ do_binutils_for_host() {
if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
# We re-use binutils' options, plus our owns
- binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}" )
+ binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils" )
binutils_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}" )
CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-host-${CT_HOST}"
@@ -118,26 +90,13 @@ do_binutils_for_host() {
# are not executable on the build machine.
case "${CT_TOOLCHAIN_TYPE}" in
cross|native)
- binutils_tools=( ar as ld ranlib strip )
- if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then
- binutils_tools+=( elf2flt flthdr )
- fi
- case "${CT_BINUTILS_LINKERS_LIST}" in
- ld) binutils_tools+=( ld.bfd ) ;;
- gold) binutils_tools+=( ld.gold ) ;;
- ld,gold) binutils_tools+=( ld.bfd ld.gold ) ;;
- gold,ld) binutils_tools+=( ld.bfd ld.gold ) ;;
- esac
- mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin"
mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin"
- for t in "${binutils_tools[@]}"; do
- CT_DoExecLog ALL ln -sv \
- "${CT_PREFIX_DIR}/${CT_TARGET}/bin/${t}" \
- "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
- CT_DoExecLog ALL ln -sv \
- "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" \
- "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
- done
+ CT_SymlinkTools "${CT_BUILDTOOLS_PREFIX_DIR}/bin" \
+ "${CT_PREFIX_DIR}/bin" \
+ "${CT_TARGET}"
+ CT_DoExecLog ALL mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}"
+ CT_DoExecLog ALL ln -sv "${CT_PREFIX_DIR}/${CT_TARGET}/bin" \
+ "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin"
;;
*) ;;
esac
@@ -172,32 +131,36 @@ do_binutils_backend() {
CT_DoLog EXTRA "Configuring binutils"
- if [ "${CT_BINUTILS_HAS_GOLD}" = "y" ]; then
- case "${CT_BINUTILS_LINKERS_LIST}" in
- ld)
- extra_config+=( --enable-ld=yes --enable-gold=no )
- ;;
- gold)
- extra_config+=( --enable-ld=no --enable-gold=yes )
- ;;
- ld,gold)
- extra_config+=( --enable-ld=default --enable-gold=yes )
- ;;
- gold,ld)
- extra_config+=( --enable-ld=yes --enable-gold=default )
- ;;
- esac
- if [ "${CT_BINUTILS_GOLD_THREADS}" = "y" ]; then
- extra_config+=( --enable-threads )
- fi
+ case "${CT_BINUTILS_LINKERS_LIST}" in
+ ld)
+ extra_config+=( --enable-ld=yes --enable-gold=no )
+ ;;
+ gold)
+ extra_config+=( --enable-ld=no --enable-gold=yes )
+ ;;
+ ld,gold)
+ extra_config+=( --enable-ld=default --enable-gold=yes )
+ ;;
+ gold,ld)
+ extra_config+=( --enable-ld=yes --enable-gold=default )
+ ;;
+ esac
+ if [ "${CT_BINUTILS_GOLD_THREADS}" = "y" ]; then
+ extra_config+=( --enable-threads )
fi
if [ "${CT_BINUTILS_PLUGINS}" = "y" ]; then
extra_config+=( --enable-plugins )
fi
- if [ "${CT_BINUTILS_HAS_PKGVERSION_BUGURL}" = "y" ]; then
- extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
- [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
+ if [ "${CT_BINUTILS_RELRO}" = "y" ]; then
+ extra_config+=( --enable-relro )
+ elif [ "${CT_BINUTILS_RELRO}" != "m" ]; then
+ extra_config+=( --disable-relro )
fi
+ if [ "${CT_BINUTILS_DETERMINISTIC_ARCHIVES}" = "y" ]; then
+ extra_config+=( --enable-deterministic-archives )
+ fi
+ [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
+ [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
if [ "${CT_MULTILIB}" = "y" ]; then
extra_config+=("--enable-multilib")
else
@@ -208,16 +171,27 @@ do_binutils_backend() {
extra_config+=("--disable-sim")
extra_config+=("--disable-gdb")
+ # libdebuginfod in incompatible with static linking
+ [ "${CT_STATIC_TOOLCHAIN}" = "y" ] && extra_config+=("--without-debuginfod")
+
[ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && extra_config+=("--disable-nls")
+ # Disable usage of glob for higher compatibility.
+ # Not strictly needed for anything but GDB anyways.
+ export ac_cv_func_glob=no
+
CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
CT_DoExecLog CFG \
+ CC_FOR_BUILD="${CT_BUILD}-gcc" \
+ CFLAGS_FOR_BUILD="${CT_CFLAGS_FOR_BUILD}" \
+ CXXFLAGS_FOR_BUILD="${CT_CFLAGS_FOR_BUILD} ${CT_CXXFLAGS_FOR_BUILD}" \
+ LDFLAGS_FOR_BUILD="${CT_LDFLAGS_FOR_BUILD}" \
CFLAGS="${cflags}" \
- CXXFLAGS="${cflags}" \
+ CXXFLAGS="${cflags} ${CT_CXXFLAGS_FOR_BUILD}" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure" \
+ "${CT_SRC_DIR}/binutils/configure" \
--build=${CT_BUILD} \
--host=${host} \
--target=${CT_TARGET} \
@@ -225,21 +199,27 @@ do_binutils_backend() {
--disable-werror \
"${extra_config[@]}" \
${CT_ARCH_WITH_FLOAT} \
- ${BINUTILS_SYSROOT_ARG} \
+ ${CT_BINUTILS_SYSROOT_ARG} \
"${CT_BINUTILS_EXTRA_CONFIG_ARRAY[@]}"
if [ "${static_build}" = "y" ]; then
extra_make_flags+=("LDFLAGS=${ldflags} -all-static")
CT_DoLog EXTRA "Prepare binutils for static build"
- CT_DoExecLog ALL make ${JOBSFLAGS} configure-host
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} configure-host
fi
CT_DoLog EXTRA "Building binutils"
- CT_DoExecLog ALL make "${extra_make_flags[@]}" ${JOBSFLAGS}
+ CT_DoExecLog ALL make "${extra_make_flags[@]}" ${CT_JOBSFLAGS}
CT_DoLog EXTRA "Installing binutils"
CT_DoExecLog ALL make install
+ if [ "${CT_BINUTILS_PLUGINS}" = "y" ]; then
+ # Create a directory for plugins such as LTO (to be installed by
+ # their providers later)
+ CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/lib/bfd-plugins"
+ fi
+
if [ "${build_manuals}" = "y" ]; then
CT_DoLog EXTRA "Building and installing the binutils manuals"
manuals_for=( gas binutils ld gprof )
@@ -248,7 +228,7 @@ do_binutils_backend() {
fi
manuals_install=( "${manuals_for[@]/#/install-pdf-}" )
manuals_install+=( "${manuals_for[@]/#/install-html-}" )
- CT_DoExecLog ALL make ${JOBSFLAGS} pdf html
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} pdf html
CT_DoExecLog ALL make "${manuals_install[@]}"
fi
@@ -258,15 +238,16 @@ do_binutils_backend() {
rm -f "${prefix}/bin/${CT_TARGET}-ld"
rm -f "${prefix}/${CT_TARGET}/bin/ld"
sed -r -e "s/@@DEFAULT_LD@@/${CT_BINUTILS_LINKER_DEFAULT}/" \
- "${CT_LIB_DIR}/scripts/build/binutils/binutils-ld.in" \
+ "${CT_LIB_DIR}/packages/binutils/binutils-ld.in" \
>"${prefix}/bin/${CT_TARGET}-ld"
- chmod +x "${prefix}/bin/${CT_TARGET}-ld"
+ chmod a+x "${prefix}/bin/${CT_TARGET}-ld"
cp -a "${prefix}/bin/${CT_TARGET}-ld" \
"${prefix}/${CT_TARGET}/bin/ld"
- # If needed, force using ld.bfd during the toolchain build
- if [ "${CT_BINUTILS_FORCE_LD_BFD}" = "y" ]; then
- export CTNG_LD_IS=bfd
+ # If needed, force using ld.bfd during the toolchain build.
+ # Note that
+ if [ "${CT_BINUTILS_FORCE_LD_BFD_DEFAULT}" = "y" ]; then
+ CT_EnvModify export CTNG_LD_IS bfd
fi
fi
}
@@ -301,7 +282,7 @@ do_elf2flt_backend() {
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/elf2flt-${CT_ELF2FLT_VERSION}/configure" \
+ "${CT_SRC_DIR}/elf2flt/configure" \
--build=${CT_BUILD} \
--host=${host} \
--target=${CT_TARGET} \
@@ -315,7 +296,7 @@ do_elf2flt_backend() {
"${CT_ELF2FLT_EXTRA_CONFIG_ARRAY[@]}"
CT_DoLog EXTRA "Building elf2flt"
- CT_DoExecLog ALL make ${JOBSFLAGS} CPU=${CT_ARCH}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} CPU=${CT_ARCH}
CT_DoLog EXTRA "Installing elf2flt"
CT_DoExecLog ALL make install
@@ -343,10 +324,8 @@ do_binutils_for_target() {
CT_DoLog EXTRA "Configuring binutils for target"
- if [ "${CT_BINUTILS_HAS_PKGVERSION_BUGURL}" = "y" ]; then
- extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
- [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
- fi
+ [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
+ [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
if [ "${CT_MULTILIB}" = "y" ]; then
extra_config+=("--enable-multilib")
else
@@ -361,7 +340,7 @@ do_binutils_for_target() {
CT_DoExecLog CFG \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure" \
+ "${CT_SRC_DIR}/binutils/configure" \
--build=${CT_BUILD} \
--host=${CT_TARGET} \
--target=${CT_TARGET} \
@@ -374,7 +353,7 @@ do_binutils_for_target() {
"${CT_BINUTILS_EXTRA_CONFIG_ARRAY[@]}"
CT_DoLog EXTRA "Building binutils' libraries (${targets[*]}) for target"
- CT_DoExecLog ALL make ${JOBSFLAGS} "${build_targets[@]}"
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} "${build_targets[@]}"
CT_DoLog EXTRA "Installing binutils' libraries (${targets[*]}) for target"
CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" "${install_targets[@]}"
diff --git a/scripts/build/cc.sh b/scripts/build/cc.sh
deleted file mode 100644
index 0db6b9c..0000000
--- a/scripts/build/cc.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-# Wrapper to build the companion tools facilities
-
-# List all companion tools facilities, and parse their scripts
-CT_CC_FACILITY_LIST=
-for f in "${CT_LIB_DIR}/scripts/build/cc/"*.sh; do
- _f="$(basename "${f}" .sh)"
- _f="${_f#???-}"
- __f="CT_CC_${_f}"
- if [ "${!__f}" = "y" ]; then
- CT_DoLog DEBUG "Enabling cc '${_f}'"
- . "${f}"
- CT_CC_FACILITY_LIST="${CT_CC_FACILITY_LIST} ${_f}"
- else
- CT_DoLog DEBUG "Disabling cc '${_f}'"
- fi
-done
-
-# Download the cc facilities
-do_cc_get() {
- for f in ${CT_CC_FACILITY_LIST}; do
- do_${f}_get
- done
-}
-
-# Extract and patch the cc facilities
-do_cc_extract() {
- for f in ${CT_CC_FACILITY_LIST}; do
- do_${f}_extract
- done
-}
-
-# Core pass 1 the cc facilities
-do_cc_core_pass_1() {
- for f in ${CT_CC_FACILITY_LIST}; do
- do_${f}_core_pass_1
- done
-}
-
-# Core pass 2 the cc facilities
-do_cc_core_pass_2() {
- for f in ${CT_CC_FACILITY_LIST}; do
- do_${f}_core_pass_2
- done
-}
-
-# Build for build the cc facilities
-do_cc_for_build() {
- for f in ${CT_CC_FACILITY_LIST}; do
- do_${f}_for_build
- done
-}
-
-# Build for host the cc facilities
-do_cc_for_host() {
- for f in ${CT_CC_FACILITY_LIST}; do
- do_${f}_for_host
- done
-}
diff --git a/scripts/build/cc/100-gcc.sh b/scripts/build/cc/gcc.sh
index 4dc7a69..0f369a4 100644
--- a/scripts/build/cc/100-gcc.sh
+++ b/scripts/build/cc/gcc.sh
@@ -3,53 +3,33 @@
# Licensed under the GPL v2. See COPYING in the root of this package
# Download gcc
-do_gcc_get() {
+do_cc_get() {
local linaro_version=""
local linaro_series=""
- if [ "${CT_CC_GCC_CUSTOM}" = "y" ]; then
- CT_GetCustom "gcc" "${CT_CC_GCC_CUSTOM_VERSION}" \
- "${CT_CC_GCC_CUSTOM_LOCATION}"
- else
- case "${CT_CC_GCC_VERSION}" in
- linaro-*)
- CT_GetLinaro "gcc" "${CT_CC_GCC_VERSION}"
- ;;
- *)
- # The official gcc hosts put gcc under a gcc/release/ directory,
- # whereas the mirrors put it in the gcc/ directory.
- CT_GetFile "gcc-${CT_CC_GCC_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/gcc/gcc-${CT_CC_GCC_VERSION} \
- ftp://{gcc.gnu.org,sourceware.org}/pub/gcc/releases/gcc-${CT_CC_GCC_VERSION}
- ;;
- esac
- fi # ! custom location
+ CT_Fetch GCC
+
# Starting with GCC 4.3, ecj is used for Java, and will only be
# built if the configure script finds ecj.jar at the top of the
# GCC source tree, which will not be there unless we get it and
# put it there ourselves
if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" ]; then
- CT_GetFile ecj-latest .jar http://mirrors.kernel.org/sourceware/java/ \
- http://crosstool-ng.org/pub/java \
- ftp://gcc.gnu.org/pub/java \
- ftp://sourceware.org/pub/java
+ if ! CT_GetFile package=ecj basename=ecj-latest extensions=.jar dir_name=gcc \
+ mirrors="$(CT_Mirrors sourceware java)"; then
+ # Should be a package, too - but with Java retirement in GCC,
+ # it may not make sense.
+ CT_Abort "Failed to download ecj-latest.jar"
+ fi
fi
}
# Extract gcc
-do_gcc_extract() {
- CT_Extract "gcc-${CT_CC_GCC_VERSION}"
- CT_Patch "gcc" "${CT_CC_GCC_VERSION}"
+do_cc_extract() {
+ CT_ExtractPatch GCC
# Copy ecj-latest.jar to ecj.jar at the top of the GCC source tree
- if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" \
- -a ! -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/ecj.jar" \
- ]; then
- CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/ecj.jar"
- fi
-
- if [ -n "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then
- CT_ConfigureXtensa "gcc" "${CT_CC_GCC_VERSION}"
+ if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" -a ! -f "${CT_SRC_DIR}/gcc/ecj.jar" ]; then
+ CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc/ecj.jar"
fi
}
@@ -73,23 +53,6 @@ cc_gcc_lang_list() {
}
#------------------------------------------------------------------------------
-# Return a value of a requested GCC spec
-cc_gcc_get_spec() {
- local spec=$1
- local cc_and_cflags=$2
-
- # GCC does not provide a facility to request a value of a spec string.
- # The only way to do that I found was to augment the spec file with
- # some dummy suffix handler that does nothing except printing it.
- touch temp-input.spec_eval
- {
- echo ".spec_eval:"
- echo "echo %(${spec})"
- } > "tmp-specs-${spec}"
- ${cc_and_cflags} -specs="tmp-specs-${spec}" -E temp-input.spec_eval
-}
-
-#------------------------------------------------------------------------------
# Report the type of a GCC option
cc_gcc_classify_opt() {
# Options present in multiple architectures
@@ -129,33 +92,55 @@ cc_gcc_classify_opt() {
echo "unknown"
}
+evaluate_multilib_cflags()
+{
+ local multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_flags multi_index multi_count
+ local mdir mdir_os dirtop
+ local f
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ mdir="lib/${multi_dir}"
+ mdir_os="lib/${multi_os_dir_gcc}"
+ CT_SanitizeVarDir mdir mdir_os
+ CT_DoLog EXTRA " '${multi_flags}' --> ${mdir} (gcc) ${mdir_os} (os)"
+ for f in ${multi_flags}; do
+ eval ml_`cc_gcc_classify_opt ${f}`=seen
+ done
+ if [ "${CT_DEMULTILIB}" = "y" -a "${CT_USE_SYSROOT}" = "y" ]; then
+ case "${mdir_os}" in
+ lib/*)
+ ;;
+ *)
+ dirtop="${mdir_os%%/*}"
+ if [ ! -e "${multi_root}/${mdir_os}" ]; then
+ CT_DoExecLog ALL ln -sfv lib "${multi_root}/${mdir_os}"
+ fi
+ if [ ! -e "${multi_root}/usr/${mdir_os}" ]; then
+ CT_DoExecLog ALL ln -sfv lib "${multi_root}/usr/${mdir_os}"
+ fi
+ ;;
+ esac
+ fi
+}
+
#------------------------------------------------------------------------------
# This function lists the multilibs configured in the compiler (even if multilib
# is disabled - so that it lists the default GCC/OS directory, which may differ
# from the default 'lib'). It then performs a few multilib checks/quirks:
#
-# 1. On SuperH target, configuring with default CPU (e.g. by supplying the target
-# name as 'sh4', which is what CT-NG does) results in the compiler being unable to
-# run if that same switch is passed to the resulting gcc (e.g. 'gcc -m4'). The reason
-# for this behavior is that the script that determines the sysroot suffix is not
-# aware of the default multilib selection, so it generates <sysroot>/m4 as the
-# suffixed sysroot. But the main driver, knowing that -m4 is the default, does not
-# even attempt to fall back to the non-suffixed sysroot (as it does with non-default
-# multilibs) - as a result, gcc fails to find any library if invoked with -m4.
-# The right solution would be to drop the default CPU from the multilib list
-# completely, or make the print-sysroot-suffix.sh script aware of the defaults
-# (which is not easy, as the defaults are not in tmake_file, but rather in tm_file...)
-#
-# 2. On MIPS target, gcc (or rather, ld, which it invokes under the hood) chokes
+# 1. On MIPS target, gcc (or rather, ld, which it invokes under the hood) chokes
# if supplied with two -mabi=* options. I.e., 'gcc -mabi=n32' and 'gcc -mabi=32' both
# work, but 'gcc -mabi=32 -mabi=n32' produces an internal error in ld. Thus we do
-# not supply target's CFLAGS in multilib builds - and after compiling pass-1 gcc,
+# not supply target's CFLAGS in multilib builds - and after compiling core gcc,
# attempt to determine which CFLAGS need to be filtered out.
+#
+# 2. If "demultilibing" is in effect, create top-level directories for any
+# multilibs not in lib/ as symlinks to lib.
cc_gcc_multilib_housekeeping() {
local cc host
- local flags osdir dir multilibs i f
- local multilib_defaults
- local suffix sysroot base lnk
local ml_arch ml_abi ml_cpu ml_tune ml_fpu ml_float ml_endian ml_mode ml_unknown ml
local new_cflags
@@ -171,76 +156,40 @@ cc_gcc_multilib_housekeeping() {
cc="${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${CT_CC}"
fi
- # sed: prepend dashes or do nothing if default is empty string
- multilib_defaults=( $( cc_gcc_get_spec multilib_defaults "${cc}" | \
- sed 's/\(^\|[[:space:]]\+\)\([^[:space:]]\)/ -\2/g' ) )
- CT_DoLog EXTRA "gcc default flags: '${multilib_defaults}'"
-
- multilibs=( $( "${cc}" -print-multi-lib ) )
- if [ ${#multilibs[@]} -ne 0 ]; then
- CT_DoLog EXTRA "gcc configured with these multilibs (including the default):"
- for i in "${multilibs[@]}"; do
- dir="lib/${i%%;*}"
- flags="${i#*;}"
- flags=${flags//@/ -}
- flags=$( echo ${flags} )
- osdir="lib/"$( "${cc}" -print-multi-os-directory ${flags} )
- CT_SanitizeVarDir dir osdir
- CT_DoLog EXTRA " '${flags}' --> ${dir} (gcc) ${osdir} (os)"
- for f in ${flags}; do
- eval ml_`cc_gcc_classify_opt ${f}`=seen
- done
+ CT_IterateMultilibs evaluate_multilib_cflags evaluate_cflags
+
+ if [ -n "${CT_MULTILIB}" ]; then
+ # Filtering out some of the options provided in CT-NG config. Then *prepend*
+ # them to CT_TARGET_CFLAGS, like scripts/crosstool-NG.sh does. Zero out
+ # the stashed MULTILIB flags so that we don't process them again in the passes
+ # that follow.
+ CT_DoLog DEBUG "Configured target CFLAGS: '${CT_ARCH_TARGET_CFLAGS_MULTILIB}'"
+ ml_unknown= # Pass through anything we don't know about
+ for f in ${CT_ARCH_TARGET_CFLAGS_MULTILIB}; do
+ eval ml=\$ml_`cc_gcc_classify_opt ${f}`
+ if [ "${ml}" != "seen" ]; then
+ new_cflags="${new_cflags} ${f}"
+ fi
done
- else
- CT_DoLog WARN "no multilib configuration: GCC unusable?"
- fi
-
- # Filtering out some of the options provided in CT-NG config. Then *prepend*
- # them to CT_TARGET_CFLAGS, like scripts/crosstool-NG.sh does. Zero out
- # the stashed MULTILIB flags so that we don't process them again in the passes
- # that follow.
- CT_DoLog DEBUG "Configured target CFLAGS: '${CT_ARCH_TARGET_CFLAGS_MULTILIB}'"
- ml_unknown= # Pass through anything we don't know about
- for f in ${CT_ARCH_TARGET_CFLAGS_MULTILIB}; do
- eval ml=\$ml_`cc_gcc_classify_opt ${f}`
- if [ "${ml}" != "seen" ]; then
- new_cflags="${new_cflags} ${f}"
- fi
- done
- CT_DoLog DEBUG "Filtered target CFLAGS: '${new_cflags}'"
- CT_EnvModify CT_TARGET_CFLAGS "${new_cflags} ${CT_TARGET_CFLAGS}"
- CT_EnvModify CT_ARCH_TARGET_CFLAGS_MULTILIB ""
-
- # Currently, the only LDFLAGS are endianness-related
- CT_DoLog DEBUG "Configured target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'"
- if [ "${ml_endian}" != "seen" ]; then
- CT_EnvModify CT_TARGET_LDFLAGS "${CT_ARCH_TARGET_LDFLAGS_MULTILIB} ${CT_TARGET_LDFLAGS}"
- CT_EnvModify CT_ARCH_TARGET_LDFLAGS_MULTILIB ""
- fi
- CT_DoLog DEBUG "Filtered target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'"
-
- # Sysroot suffix fixup for the multilib default.
- suffix=$( cc_gcc_get_spec sysroot_suffix_spec "${cc} ${multilib_defaults}" )
- if [ -n "${suffix}" ]; then
- base=${suffix%/*}
- sysroot=$( "${cc}" -print-sysroot )
- if [ -n "${base}" ]; then
- CT_DoExecLog ALL mkdir -p "${sysroot}${base}"
- lnk=$( echo "${base#/}" | sed -e 's,[^/]*,..,g' )
- else
- lnk=.
+ CT_DoLog DEBUG "Filtered target CFLAGS: '${new_cflags}'"
+ CT_EnvModify CT_ALL_TARGET_CFLAGS "${new_cflags} ${CT_TARGET_CFLAGS}"
+ CT_EnvModify CT_ARCH_TARGET_CFLAGS_MULTILIB ""
+
+ # Currently, the only LDFLAGS are endianness-related
+ CT_DoLog DEBUG "Configured target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'"
+ if [ "${ml_endian}" != "seen" ]; then
+ CT_EnvModify CT_ALL_TARGET_LDFLAGS "${CT_ARCH_TARGET_LDFLAGS_MULTILIB} ${CT_TARGET_LDFLAGS}"
+ CT_EnvModify CT_ARCH_TARGET_LDFLAGS_MULTILIB ""
fi
- CT_DoExecLog ALL rm -f "${sysroot}${suffix}"
- CT_DoExecLog ALL ln -sfv "${lnk}" "${sysroot}${suffix}"
+ CT_DoLog DEBUG "Filtered target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'"
fi
}
#------------------------------------------------------------------------------
-# Core gcc pass 1
-do_gcc_core_pass_1() {
+do_cc_core() {
local -a core_opts
- if [ "${CT_CC_CORE_PASS_1_NEEDED}" != "y" ]; then
+ if [ "${CT_CC_CORE_NEEDED}" != "y" ]; then
return 0
fi
@@ -251,56 +200,12 @@ do_gcc_core_pass_1() {
core_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
core_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
core_opts+=( "lang_list=c" )
- core_opts+=( "build_step=core1" )
-
- CT_DoStep INFO "Installing pass-1 core C gcc compiler"
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-1"
-
- do_gcc_core_backend "${core_opts[@]}"
-
- CT_Popd
- CT_EndStep
-}
-
-# Core gcc pass 2
-do_gcc_core_pass_2() {
- local -a core_opts
-
- if [ "${CT_CC_CORE_PASS_2_NEEDED}" != "y" ]; then
- return 0
- fi
-
- # Common options:
- core_opts+=( "host=${CT_BUILD}" )
- core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
- core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" )
- core_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
- core_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
- core_opts+=( "lang_list=c" )
- core_opts+=( "build_step=core2" )
-
- # Different conditions are at stake here:
- # - In case the threading model is NPTL, we need a shared-capable core
- # gcc; in all other cases, we need a static-only core gcc.
- # - In case the threading model is NPTL or win32, or gcc is 4.3 or
- # later, we need to build libgcc
- case "${CT_THREADS}" in
- nptl)
- core_opts+=( "mode=shared" )
- core_opts+=( "build_libgcc=yes" )
- ;;
- win32)
- core_opts+=( "mode=static" )
- core_opts+=( "build_libgcc=yes" )
- ;;
- *)
- core_opts+=( "mode=static" )
- core_opts+=( "build_libgcc=yes" )
- ;;
- esac
+ core_opts+=( "build_step=core" )
+ core_opts+=( "mode=static" )
+ core_opts+=( "build_libgcc=yes" )
- CT_DoStep INFO "Installing pass-2 core C gcc compiler"
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-2"
+ CT_DoStep INFO "Installing core C gcc compiler"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core"
do_gcc_core_backend "${core_opts[@]}"
@@ -325,8 +230,8 @@ do_gcc_core_pass_2() {
# build_manuals : whether to build manuals or not : bool : no
# cflags : cflags to use : string : (empty)
# ldflags : ldflags to use : string : (empty)
-# build_step : build step 'core1', 'core2', 'gcc_build'
-# or 'gcc_host' : string : (none)
+# build_step : build step 'core', 'gcc_build',
+# 'libstdcxx' or 'gcc_host' : string : (none)
# Usage: do_gcc_core_backend mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no]
do_gcc_core_backend() {
local mode
@@ -337,13 +242,18 @@ do_gcc_core_backend() {
local build_manuals=no
local host
local prefix
+ local enable_optspace
local complibs
local lang_list
- local cflags
+ local cflags cflags_for_build cxxflags_for_build cflags_for_target cxxflags_for_target
+ local extra_cxxflags_for_target
local ldflags
local build_step
local log_txt
local tmp
+ local exec_prefix
+ local header_dir
+ local libstdcxx_name
local -a host_libstdcxx_flags
local -a extra_config
local -a core_LDFLAGS
@@ -359,25 +269,44 @@ do_gcc_core_backend() {
# This function gets called in case of a bare metal compiler for the final gcc, too.
case "${build_step}" in
- core1|core2)
+ core)
CT_DoLog EXTRA "Configuring core C gcc compiler"
log_txt="gcc"
+ extra_config+=( "${CT_CC_CORE_SYSROOT_ARG[@]}" )
extra_user_config=( "${CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY[@]}" )
;;
gcc_build|gcc_host)
CT_DoLog EXTRA "Configuring final gcc compiler"
+ extra_config+=( "${CT_CC_SYSROOT_ARG[@]}" )
extra_user_config=( "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" )
log_txt="final gcc compiler"
- if [ "${CT_CC_GCC_TARGET_FINAL}" = "y" ]; then
- # to inhibit the libiberty and libgcc tricks later on
- build_libgcc=no
+ # to inhibit the libiberty and libgcc tricks later on
+ build_libgcc=no
+ ;;
+ libstdcxx)
+ CT_DoLog EXTRA "Configuring libstdc++ for ${libstdcxx_name}"
+ if [ "${header_dir}" = "" ]; then
+ header_dir="${CT_PREFIX_DIR}/${libstdcxx_name}/include"
fi
+ if [ "${exec_prefix}" = "" ]; then
+ exec_prefix="${CT_PREFIX_DIR}/${libstdcxx_name}"
+ fi
+ extra_config+=( "${CT_CC_SYSROOT_ARG[@]}" )
+ extra_config+=( "--with-headers=${header_dir}" )
+ extra_user_config=( "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" )
+ log_txt="libstdc++ ${libstdcxx_name} library"
+ # to inhibit the libiberty and libgcc tricks later on
+ build_libgcc=no
;;
*)
- CT_Abort "Internal Error: 'build_step' must be one of: 'core1', 'core2', 'gcc_build' or 'gcc_host', not '${build_step:-(empty)}'"
+ CT_Abort "Internal Error: 'build_step' must be one of: 'core', 'gcc_build', 'gcc_host' or 'libstdcxx', not '${build_step:-(empty)}'"
;;
esac
+ if [ "${exec_prefix}" = "" ]; then
+ exec_prefix="${prefix}"
+ fi
+
case "${mode}" in
static)
extra_config+=("--with-newlib")
@@ -397,29 +326,33 @@ do_gcc_core_backend() {
;;
esac
- # This is only needed when building libstdc++ in a canadian environment with
- # this function being used for final step (i.e., when building for bare metal).
- if [ "${build_step}" = "gcc_build" ]; then
- CT_DoLog DEBUG "Copying headers to install area of core C compiler"
- CT_DoExecLog ALL cp -a "${CT_HEADERS_DIR}" "${prefix}/${CT_TARGET}/include"
- fi
-
- for tmp in ARCH ABI CPU TUNE FPU FLOAT; do
+ for tmp in ARCH ABI CPU CPU_32 CPU_64 TUNE FPU FLOAT ENDIAN; do
eval tmp="\${CT_ARCH_WITH_${tmp}}"
if [ -n "${tmp}" ]; then
extra_config+=("${tmp}")
fi
done
- extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
+ [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
+ # Hint GCC we'll use a bit special version of Newlib
+ if [ "${CT_LIBC_NEWLIB_NANO_FORMATTED_IO}" = "y" ]; then
+ extra_config+=("--enable-newlib-nano-formatted-io")
+ fi
+
if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
extra_config+=("--enable-__cxa_atexit")
else
extra_config+=("--disable-__cxa_atexit")
fi
+ case "${CT_CC_GCC_TM_CLONE_REGISTRY}" in
+ y) extra_config+=("--enable-tm-clone-registry");;
+ m) ;;
+ "") extra_config+=("--disable-tm-clone-registry");;
+ esac
+
if [ -n "${CT_CC_GCC_ENABLE_CXX_FLAGS}" \
-a "${mode}" = "baremetal" ]; then
extra_config+=("--enable-cxx-flags=${CT_CC_GCC_ENABLE_CXX_FLAGS}")
@@ -429,11 +362,11 @@ do_gcc_core_backend() {
extra_config+=(--disable-libmudflap)
extra_config+=(--disable-libmpx)
- if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then
- extra_config+=(--enable-libssp)
- else
- extra_config+=(--disable-libssp)
- fi
+ case "${CT_CC_GCC_LIBSSP}" in
+ y) extra_config+=(--enable-libssp);;
+ m) ;;
+ "") extra_config+=(--disable-libssp);;
+ esac
if [ "${CT_CC_GCC_LIBQUADMATH}" = "y" ]; then
extra_config+=(--enable-libquadmath)
extra_config+=(--enable-libquadmath-support)
@@ -442,6 +375,15 @@ do_gcc_core_backend() {
extra_config+=(--disable-libquadmath-support)
fi
+ case "${CT_CC_GCC_LIBSTDCXX_VERBOSE}" in
+ y) extra_config+=("--enable-libstdcxx-verbose");;
+ "") extra_config+=("--disable-libstdcxx-verbose");;
+ esac
+
+ if [ "${build_libstdcxx}" = "no" ]; then
+ extra_config+=(--disable-libstdcxx)
+ fi
+
core_LDFLAGS+=("${ldflags}")
# *** WARNING ! ***
@@ -449,9 +391,11 @@ do_gcc_core_backend() {
# with the same block in do_gcc_backend, below.
if [ "${build_staticlinked}" = "yes" ]; then
core_LDFLAGS+=("-static")
- host_libstdcxx_flags+=("-static-libgcc")
- host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++")
- host_libstdcxx_flags+=("-lm")
+ if [ "${CT_GCC_older_than_6}" = "y" ]; then
+ host_libstdcxx_flags+=("-static-libgcc")
+ host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++")
+ host_libstdcxx_flags+=("-lm")
+ fi
# Companion libraries are build static (eg !shared), so
# the libstdc++ is not pulled automatically, although it
# is needed. Shoe-horn it in our LDFLAGS
@@ -459,7 +403,7 @@ do_gcc_core_backend() {
core_LDFLAGS+=("-lstdc++")
core_LDFLAGS+=("-lm")
else
- if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then
+ if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" -a "${CT_GCC_older_than_6}" = "y" ]; then
# this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
# build script
# INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
@@ -500,13 +444,28 @@ do_gcc_core_backend() {
extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}")
fi
- if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then
+ if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ] || \
+ [ "${enable_optspace}" = "yes" ]; then
extra_config+=("--enable-target-optspace")
fi
if [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ]; then
extra_config+=("--disable-libstdcxx-pch")
fi
+ if [ "${CT_LIBC_GLIBC}" = "y" ]; then
+ # Report GLIBC's version to GCC, it affects the defaults on other options.
+ # GCC expects just two numbers separated by a dot.
+ local glibc_version
+
+ CT_GetPkgVersion GLIBC glibc_version
+ case "${glibc_version}" in
+ new) glibc_version=99.99;;
+ old) glibc_version=1.0;;
+ *) glibc_version=`echo "${glibc_version}" | sed 's/\([1-9][0-9]*\.[1-9][0-9]*\).*/\1/'`;;
+ esac
+ extra_config+=("--with-glibc-version=${glibc_version}")
+ fi
+
case "${CT_CC_GCC_LDBL_128}" in
y) extra_config+=("--with-long-double-128");;
m) ;;
@@ -563,11 +522,10 @@ do_gcc_core_backend() {
# Some versions of gcc have a defective --enable-multilib.
# Since that's the default, only pass --disable-multilib. For multilib,
- # also enable multiarch. Without explicit --enable-multiarch, pass-1
- # compiler is configured as multilib/no-multiarch and pass-2/final
- # are multilib/multiarch (because gcc autodetects multiarch based on
- # multiple instances of crt*.o in the install directory - which do
- # not exist in pass-1).
+ # also enable multiarch. Without explicit --enable-multiarch, core
+ # compiler is configured as multilib/no-multiarch (because gcc autodetects
+ # multiarch based on multiple instances of crt*.o in the install directory
+ # which do not exist in the core pass).
if [ "${CT_MULTILIB}" != "y" ]; then
extra_config+=("--disable-multilib")
else
@@ -579,29 +537,75 @@ do_gcc_core_backend() {
CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
+ # We may need to modify host/build/target CFLAGS separately below. Note
+ # that ${cflags} may refer either to build or host CFLAGS; they are provided
+ # by the caller.
+ cflags_for_build="${CT_CFLAGS_FOR_BUILD}"
+ cxxflags_for_build="${CT_CXXFLAGS_FOR_BUILD}"
+ cflags_for_target="${CT_TARGET_CFLAGS}"
+
# Clang's default bracket-depth is 256, and building GCC
# requires somewhere between 257 and 512.
- if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then
- cflags="$cflags "-fbracket-depth=512
+ if [ "${host}" = "${CT_BUILD}" ]; then
+ if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then
+ cflags="$cflags -fbracket-depth=512"
+ cflags_for_build="$cflags_for_build -fbracket-depth=512"
+ fi
+ else
+ # FIXME we currently don't support clang as host compiler, only as build
+ if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then
+ cflags_for_build="$cflags_for_build -fbracket-depth=512"
+ fi
+ fi
+
+ # For non-sysrooted toolchain, GCC doesn't search except at the installation
+ # prefix; in core stage we use a temporary installation prefix - but
+ # we may have installed something into the final prefix. This is less than ideal:
+ # in the installation prefix GCC also handles subdirectories for multilibs
+ # (e.g. first trying ${prefix}/include/${arch-triplet}) but
+ # we can only pass the top level directory, so non-sysrooted build with libc
+ # selection that doesn't merge the headers (i.e. musl, uClibc-ng) may not
+ # work. Better suggestions welcome.
+ if [ "${CT_USE_SYSROOT}" != "y" ]; then
+ cflags_for_target="${cflags_for_target} -idirafter ${CT_HEADERS_DIR}"
fi
- # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
+ # Assume '-O2' by default for building target libraries.
+ cflags_for_target="-g -O2 ${cflags_for_target}"
+
+ # Set target CXXFLAGS to CFLAGS if none is provided.
+ if [ -z "${cxxflags_for_target}" ]; then
+ cxxflags_for_target="${cflags_for_target}"
+ fi
+
+ # Append extra CXXFLAGS if provided.
+ if [ -n "${extra_cxxflags_for_target}" ]; then
+ cxxflags_for_target="${cxxflags_for_target} ${extra_cxxflags_for_target}"
+ fi
+
+ # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532).
+ # Pass only user-specified CFLAGS/LDFLAGS in CFLAGS_FOR_TARGET/LDFLAGS_FOR_TARGET: during
+ # the build of, for example, libatomic, GCC tried to compile multiple variants for runtime
+ # selection and passing architecture/CPU selectors, as detemined by crosstool-NG, may
+ # miscompile or outright fail.
CT_DoExecLog CFG \
CC_FOR_BUILD="${CT_BUILD}-gcc" \
CFLAGS="${cflags}" \
- CXXFLAGS="${cflags}" \
+ CFLAGS_FOR_BUILD="${cflags_for_build}" \
+ CXXFLAGS="${cflags} ${cxxflags_for_build}" \
+ CXXFLAGS_FOR_BUILD="${cflags_for_build} ${cxxflags_for_build}" \
LDFLAGS="${core_LDFLAGS[*]}" \
- CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
- CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
+ CFLAGS_FOR_TARGET="${cflags_for_target}" \
+ CXXFLAGS_FOR_TARGET="${cxxflags_for_target}" \
LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure" \
+ "${CT_SRC_DIR}/gcc/configure" \
--build=${CT_BUILD} \
--host=${host} \
--target=${CT_TARGET} \
--prefix="${prefix}" \
+ --exec_prefix="${exec_prefix}" \
--with-local-prefix="${CT_SYSROOT_DIR}" \
- ${CC_CORE_SYSROOT_ARG} \
"${extra_config[@]}" \
--enable-languages="${lang_list}" \
"${extra_user_config[@]}"
@@ -623,43 +627,31 @@ do_gcc_core_backend() {
# so we configure then build it.
# Next we have to configure gcc, create libgcc.mk then edit it...
# So much easier if we just edit the source tree, but hey...
- if [ ! -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then
- CT_DoExecLog CFG make ${JOBSFLAGS} configure-libiberty
- CT_DoExecLog ALL make ${JOBSFLAGS} -C libiberty libiberty.a
- CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp
- CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp
+ if [ ! -f "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ]; then
+ CT_DoExecLog CFG make ${CT_JOBSFLAGS} configure-libiberty
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} -C libiberty libiberty.a
+ CT_DoExecLog CFG make ${CT_JOBSFLAGS} configure-gcc configure-libcpp
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} all-libcpp
else
- CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp configure-build-libiberty
- CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp all-build-libiberty
+ CT_DoExecLog CFG make ${CT_JOBSFLAGS} configure-gcc configure-libcpp configure-build-libiberty
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} all-libcpp all-build-libiberty
fi
# HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
- if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/libdecnumber" ]; then
- CT_DoExecLog CFG make ${JOBSFLAGS} configure-libdecnumber
- CT_DoExecLog ALL make ${JOBSFLAGS} -C libdecnumber libdecnumber.a
+ if [ -d "${CT_SRC_DIR}/gcc/libdecnumber" ]; then
+ CT_DoExecLog CFG make ${CT_JOBSFLAGS} configure-libdecnumber
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} -C libdecnumber libdecnumber.a
fi
# HACK: gcc-4.8 uses libbacktrace to make libgcc.mvars, so make it here.
- if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/libbacktrace" ]; then
- CT_DoExecLog CFG make ${JOBSFLAGS} configure-libbacktrace
- CT_DoExecLog ALL make ${JOBSFLAGS} -C libbacktrace
+ if [ -d "${CT_SRC_DIR}/gcc/libbacktrace" ]; then
+ CT_DoExecLog CFG make ${CT_JOBSFLAGS} configure-libbacktrace
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} -C libbacktrace
fi
libgcc_rule="libgcc.mvars"
core_targets=( gcc target-libgcc )
- # On bare metal and canadian build the host-compiler is used when
- # actually the build-system compiler is required. Choose the correct
- # compilers for canadian build and use the defaults on other
- # configurations.
- if [ "${CT_BARE_METAL},${CT_CANADIAN}" = "y,y" ]; then
- repair_cc="CC_FOR_BUILD=${CT_BUILD}-gcc \
- CXX_FOR_BUILD=${CT_BUILD}-g++ \
- GCC_FOR_TARGET=${CT_TARGET}-${CT_CC}"
- else
- repair_cc=""
- fi
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} -C gcc ${libgcc_rule}
- CT_DoExecLog ALL make ${JOBSFLAGS} -C gcc ${libgcc_rule} \
- ${repair_cc}
sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule}
else # build_libgcc
core_targets=( gcc )
@@ -681,17 +673,20 @@ do_gcc_core_backend() {
case "${build_step}" in
gcc_build|gcc_host)
- if [ "${CT_CC_GCC_TARGET_FINAL}" = "y" ]; then
- core_targets_all=all
- core_targets_install=install
- fi
+ core_targets_all=all
+ core_targets_install=install
+ ;;
+ libstdcxx)
+ core_targets=( target-libstdc++-v3 )
+ core_targets_all="${core_targets[@]/#/all-}"
+ core_targets_install="${core_targets[@]/#/install-}"
;;
esac
CT_DoLog EXTRA "Building ${log_txt}"
- CT_DoExecLog ALL make ${JOBSFLAGS} ${core_targets_all}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} ${core_targets_all}
- # Do not pass ${JOBSFLAGS} here: recent GCC builds have been failing
+ # Do not pass ${CT_JOBSFLAGS} here: recent GCC builds have been failing
# in parallel 'make install' at random locations: libitm, libcilk,
# always for the files that are installed more than once to the same
# location (such as libitm.info).
@@ -729,11 +724,18 @@ do_gcc_core_backend() {
cc_gcc_multilib_housekeeping cc="${prefix}/bin/${CT_TARGET}-${CT_CC}" \
host="${host}"
+
+ # If binutils want the LTO plugin, point them to it
+ if [ -d "${CT_PREFIX_DIR}/lib/bfd-plugins" -a "${build_step}" = "gcc_host" ]; then
+ local gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER" )
+ CT_DoExecLog ALL ln -sfv "../../libexec/gcc/${CT_TARGET}/${gcc_version}/liblto_plugin.so" \
+ "${CT_PREFIX_DIR}/lib/bfd-plugins/liblto_plugin.so"
+ fi
}
#------------------------------------------------------------------------------
# Build complete gcc to run on build
-do_gcc_for_build() {
+do_cc_for_build() {
local -a build_final_opts
local build_final_backend
@@ -755,7 +757,9 @@ do_gcc_for_build() {
# lack of such a compiler, but better safe than sorry...
build_final_opts+=( "mode=baremetal" )
build_final_opts+=( "build_libgcc=yes" )
- build_final_opts+=( "build_libstdcxx=yes" )
+ if [ "${CT_LIBC_NONE}" != "y" ]; then
+ build_final_opts+=( "build_libstdcxx=yes" )
+ fi
build_final_opts+=( "build_libgfortran=yes" )
if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
build_final_opts+=( "build_staticlinked=yes" )
@@ -774,14 +778,24 @@ do_gcc_for_build() {
CT_EndStep
}
-gcc_movelibs() {
- local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count
- local gcc_dir
+gcc_movelibs()
+{
+ local multi_flags multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_index multi_count
+ local gcc_dir dst_dir canon_root canon_prefix
+ local rel
for arg in "$@"; do
eval "${arg// /\\ }"
done
+ # GCC prints the sysroot in canonicalized form, which may be different if there
+ # is a symlink in the path. Since we need textual match to obtain a relative
+ # subdirectory path, canonicalize the prefix directory. Since GCC's behavior
+ # is not documented and hence may change at any time, canonicalize it too just
+ # for the good measure.
+ canon_root=$( cd "${multi_root}" && pwd -P )
+ canon_prefix=$( cd "${CT_PREFIX_DIR}" && pwd -P )
+
# Move only files, directories are for other multilibs. We're looking inside
# GCC's directory structure, thus use unmangled multi_os_dir that GCC reports.
gcc_dir="${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_os_dir_gcc}"
@@ -789,6 +803,16 @@ gcc_movelibs() {
# GCC didn't install anything outside of sysroot
return
fi
+ # Depending on the selected libc, we may or may not have the ${multi_os_dir_gcc}
+ # created by libc installation. If we do, use it. If we don't, use ${multi_os_dir}
+ # to avoid creating an otherwise empty directory.
+ dst_dir="${canon_root}/lib/${multi_os_dir_gcc}"
+ if [ ! -d "${dst_dir}" ]; then
+ dst_dir="${canon_root}/lib/${multi_os_dir}"
+ fi
+ CT_SanitizeVarDir dst_dir gcc_dir
+ rel=$( echo "${gcc_dir#${CT_PREFIX_DIR}/}" | sed 's#[^/]\{1,\}#..#g' )
+
ls "${gcc_dir}" | while read f; do
case "${f}" in
*.ld)
@@ -798,15 +822,16 @@ gcc_movelibs() {
;;
esac
if [ -f "${gcc_dir}/${f}" ]; then
- CT_DoExecLog ALL mkdir -p "${multi_root}/lib/${multi_os_dir}"
- CT_DoExecLog ALL mv "${gcc_dir}/${f}" "${multi_root}/lib/${multi_os_dir}/${f}"
+ CT_DoExecLog ALL mkdir -p "${dst_dir}"
+ CT_DoExecLog ALL mv "${gcc_dir}/${f}" "${dst_dir}/${f}"
+ CT_DoExecLog ALL ln -sf "${rel}/${dst_dir#${canon_prefix}/}/${f}" "${gcc_dir}/${f}"
fi
done
}
#------------------------------------------------------------------------------
# Build final gcc to run on host
-do_gcc_for_host() {
+do_cc_for_host() {
local -a final_opts
local final_backend
@@ -823,7 +848,9 @@ do_gcc_for_host() {
if [ "${CT_BARE_METAL}" = "y" ]; then
final_opts+=( "mode=baremetal" )
final_opts+=( "build_libgcc=yes" )
- final_opts+=( "build_libstdcxx=yes" )
+ if [ "${CT_LIBC_NONE}" != "y" ]; then
+ final_opts+=( "build_libstdcxx=yes" )
+ fi
final_opts+=( "build_libgfortran=yes" )
if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
final_opts+=( "build_staticlinked=yes" )
@@ -856,19 +883,31 @@ do_gcc_for_host() {
# Parameter : Definition : Type : Default
# host : the host we run onto : tuple : (none)
# prefix : the runtime prefix : dir : (none)
+# exec_prefix : prefix for executables : dir : (none)
# complibs : the companion libraries prefix : dir : (none)
# cflags : cflags to use : string : (empty)
# ldflags : ldflags to use : string : (empty)
# lang_list : the list of languages to build : string : (empty)
# build_manuals : whether to build manuals or not : bool : no
+# build_step : build step 'gcc_build', 'gcc_host'
+# or 'libstdcxx' : string : (none)
do_gcc_backend() {
local host
local prefix
+ local exec_prefix
local complibs
local lang_list
local cflags
+ local cflags_for_build
+ local cxxflags_for_build
+ local cflags_for_target
+ local cxxflags_for_target
+ local extra_cxxflags_for_target
local ldflags
local build_manuals
+ local exec_prefix
+ local header_dir
+ local libstdcxx_name
local -a host_libstdcxx_flags
local -a extra_config
local -a final_LDFLAGS
@@ -879,22 +918,42 @@ do_gcc_backend() {
eval "${arg// /\\ }"
done
- CT_DoLog EXTRA "Configuring final gcc compiler"
+ if [ "${exec_prefix}" = "" ]; then
+ exec_prefix="${prefix}"
+ fi
+
+ # This function gets called for final gcc and libstdcxx.
+ case "${build_step}" in
+ gcc_build|gcc_host)
+ log_txt="final gcc compiler"
+ ;;
+ libstdcxx)
+ log_txt="libstdc++ library for ${libstdcxx_name}"
+ ;;
+ *)
+ CT_Abort "Internal Error: 'build_step' must be one of: 'gcc_build', 'gcc_host' or 'libstdcxx', not '${build_step:-(empty)}'"
+ ;;
+ esac
+
+ CT_DoLog EXTRA "Configuring ${log_txt}"
# Enable selected languages
extra_config+=("--enable-languages=${lang_list}")
- for tmp in ARCH ABI CPU TUNE FPU FLOAT; do
+ for tmp in ARCH ARCH_32 ARCH_64 ABI CPU CPU_32 CPU_64 TUNE TUNE_32 TUNE_64 FPU FLOAT; do
eval tmp="\${CT_ARCH_WITH_${tmp}}"
if [ -n "${tmp}" ]; then
extra_config+=("${tmp}")
fi
done
- [ "${CT_SHARED_LIBS}" = "y" ] || extra_config+=("--disable-shared")
- extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
+ [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
+ if [ "${CT_SHARED_LIBS}" != "y" ]; then
+ extra_config+=("--disable-shared")
+ fi
+
case "${CT_CC_GCC_SJLJ_EXCEPTIONS}" in
y) extra_config+=("--enable-sjlj-exceptions");;
m) ;;
@@ -906,6 +965,12 @@ do_gcc_backend() {
extra_config+=("--disable-__cxa_atexit")
fi
+ case "${CT_CC_GCC_TM_CLONE_REGISTRY}" in
+ y) extra_config+=("--enable-tm-clone-registry");;
+ m) ;;
+ "") extra_config+=("--disable-tm-clone-registry");;
+ esac
+
if [ -n "${CT_CC_GCC_ENABLE_CXX_FLAGS}" ]; then
extra_config+=("--enable-cxx-flags=${CT_CC_GCC_ENABLE_CXX_FLAGS}")
fi
@@ -923,11 +988,11 @@ do_gcc_backend() {
else
extra_config+=(--disable-libgomp)
fi
- if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then
- extra_config+=(--enable-libssp)
- else
- extra_config+=(--disable-libssp)
- fi
+ case "${CT_CC_GCC_LIBSSP}" in
+ y) extra_config+=(--enable-libssp);;
+ m) ;;
+ "") extra_config+=(--disable-libssp);;
+ esac
if [ "${CT_CC_GCC_LIBQUADMATH}" = "y" ]; then
extra_config+=(--enable-libquadmath)
extra_config+=(--enable-libquadmath-support)
@@ -950,6 +1015,15 @@ do_gcc_backend() {
fi
fi
+ case "${CT_CC_GCC_LIBSTDCXX_VERBOSE}" in
+ y) extra_config+=("--enable-libstdcxx-verbose");;
+ "") extra_config+=("--disable-libstdcxx-verbose");;
+ esac
+
+ if [ "${build_libstdcxx}" = "no" ]; then
+ extra_config+=(--disable-libstdcxx)
+ fi
+
final_LDFLAGS+=("${ldflags}")
# *** WARNING ! ***
@@ -957,9 +1031,11 @@ do_gcc_backend() {
# with the same block in do_gcc_core_backend, above.
if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
final_LDFLAGS+=("-static")
- host_libstdcxx_flags+=("-static-libgcc")
- host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++")
- host_libstdcxx_flags+=("-lm")
+ if [ "${CT_GCC_older_than_6}" = "y" ]; then
+ host_libstdcxx_flags+=("-static-libgcc")
+ host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++")
+ host_libstdcxx_flags+=("-lm")
+ fi
# Companion libraries are build static (eg !shared), so
# the libstdc++ is not pulled automatically, although it
# is needed. Shoe-horn it in our LDFLAGS
@@ -967,7 +1043,7 @@ do_gcc_backend() {
final_LDFLAGS+=("-lstdc++")
final_LDFLAGS+=("-lm")
else
- if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then
+ if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" -a "${CT_GCC_older_than_6}" = "y" ]; then
# this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
# build script
# INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
@@ -1003,6 +1079,11 @@ do_gcc_backend() {
else
extra_config+=("--disable-lto")
fi
+ case "${CT_CC_GCC_LTO_ZSTD}" in
+ y) extra_config+=("--with-zstd");;
+ m) ;;
+ *) extra_config+=("--without-zstd");;
+ esac
if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then
extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}")
@@ -1019,9 +1100,11 @@ do_gcc_backend() {
fi
fi
- if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then
+ if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ] || \
+ [ "${enable_optspace}" = "yes" ]; then
extra_config+=("--enable-target-optspace")
fi
+
if [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ]; then
extra_config+=("--disable-libstdcxx-pch")
fi
@@ -1102,27 +1185,58 @@ do_gcc_backend() {
CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
+ # We may need to modify host/build/target CFLAGS separately below
+ cflags_for_build="${cflags}"
+ cxxflags_for_build="${CT_CXXFLAGS_FOR_BUILD}"
+ cflags_for_target="${CT_TARGET_CFLAGS}"
+
# Clang's default bracket-depth is 256, and building GCC
# requires somewhere between 257 and 512.
- if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then
- cflags="$cflags "-fbracket-depth=512
+ if [ "${host}" = "${CT_BUILD}" ]; then
+ if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then
+ cflags="$cflags "-fbracket-depth=512
+ cflags_for_build="$cflags_for_build "-fbracket-depth=512
+ fi
+ else
+ # FIXME we currently don't support clang as host compiler, only as build
+ if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then
+ cflags_for_build="$cflags_for_build "-fbracket-depth=512
+ fi
+ fi
+
+ # Assume '-O2' by default for building target libraries.
+ cflags_for_target="-g -O2 ${cflags_for_target}"
+
+ # Set target CXXFLAGS to CFLAGS if none is provided.
+ if [ -z "${cxxflags_for_target}" ]; then
+ cxxflags_for_target="${cflags_for_target}"
fi
+ # Append extra CXXFLAGS if provided.
+ if [ -n "${extra_cxxflags_for_target}" ]; then
+ cxxflags_for_target="${cxxflags_for_target} ${extra_cxxflags_for_target}"
+ fi
+
+ # NB: not using CT_ALL_TARGET_CFLAGS/CT_ALL_TARGET_LDFLAGS here!
+ # See do_gcc_core_backend for explanation.
CT_DoExecLog CFG \
CC_FOR_BUILD="${CT_BUILD}-gcc" \
CFLAGS="${cflags}" \
- CXXFLAGS="${cflags}" \
+ CFLAGS_FOR_BUILD="${cflags_for_build}" \
+ CXXFLAGS="${cflags} ${cxxflags_for_build}" \
+ CXXFLAGS_FOR_BUILD="${cflags_for_build} ${cxxflags_for_build}" \
LDFLAGS="${final_LDFLAGS[*]}" \
- CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
- CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
+ CFLAGS_FOR_TARGET="${cflags_for_target}" \
+ CXXFLAGS_FOR_TARGET="${cxxflags_for_target}" \
LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure" \
+ "${CT_SRC_DIR}/gcc/configure" \
--build=${CT_BUILD} \
--host=${host} \
--target=${CT_TARGET} \
--prefix="${prefix}" \
- ${CC_SYSROOT_ARG} \
+ --exec_prefix="${exec_prefix}" \
+ ${CT_CC_SYSROOT_ARG} \
"${extra_config[@]}" \
--with-local-prefix="${CT_SYSROOT_DIR}" \
--enable-long-long \
@@ -1130,11 +1244,11 @@ do_gcc_backend() {
if [ "${CT_CANADIAN}" = "y" ]; then
CT_DoLog EXTRA "Building libiberty"
- CT_DoExecLog ALL make ${JOBSFLAGS} all-build-libiberty
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} all-build-libiberty
fi
CT_DoLog EXTRA "Building final gcc compiler"
- CT_DoExecLog ALL make ${JOBSFLAGS} all
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} all
# See the note on issues with parallel 'make install' in GCC above.
CT_DoLog EXTRA "Installing final gcc compiler"
@@ -1171,4 +1285,11 @@ do_gcc_backend() {
cc_gcc_multilib_housekeeping cc="${prefix}/bin/${CT_TARGET}-${CT_CC}" \
host="${host}"
+
+ # If binutils want the LTO plugin, point them to it
+ if [ -d "${CT_PREFIX_DIR}/lib/bfd-plugins" -a "${build_step}" = "gcc_host" ]; then
+ local gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER" )
+ CT_DoExecLog ALL ln -sfv "../../libexec/gcc/${CT_TARGET}/${gcc_version}/liblto_plugin.so" \
+ "${CT_PREFIX_DIR}/lib/bfd-plugins/liblto_plugin.so"
+ fi
}
diff --git a/scripts/build/companion_libs/050-zlib.sh b/scripts/build/companion_libs/050-zlib.sh
index 6e17819..8c6a0f6 100644
--- a/scripts/build/companion_libs/050-zlib.sh
+++ b/scripts/build/companion_libs/050-zlib.sh
@@ -13,14 +13,12 @@ if [ "${CT_ZLIB}" = "y" ]; then
# Download zlib
do_zlib_get() {
- CT_GetFile "zlib-${CT_ZLIB_VERSION}" \
- "http://downloads.sourceforge.net/project/libpng/zlib/${CT_ZLIB_VERSION}"
+ CT_Fetch ZLIB
}
# Extract zlib
do_zlib_extract() {
- CT_Extract "zlib-${CT_ZLIB_VERSION}"
- CT_Patch "zlib" "${CT_ZLIB_VERSION}"
+ CT_ExtractPatch ZLIB
}
# Build zlib for running on build
@@ -76,30 +74,51 @@ do_zlib_backend() {
local ldflags
local arg
local -a extra_config
+ local -a extra_make
for arg in "$@"; do
eval "${arg// /\\ }"
done
- CT_DoLog EXTRA "Configuring zlib"
-
- CT_DoExecLog CFG \
- CFLAGS="${cflags}" \
- LDFLAGS="${ldflags}" \
- CROSS_PREFIX="${host}-" \
- ${CONFIG_SHELL} \
- "${CT_SRC_DIR}/zlib-${CT_ZLIB_VERSION}/configure" \
- --prefix="${prefix}" \
- --static \
- "${extra_config[@]}"
+ case "${host}" in
+ *-mingw32)
+ # zlib treats mingw host differently and requires using a different
+ # makefile rather than configure+make. It also does not support
+ # out-of-tree building.
+ cp -av "${CT_SRC_DIR}/zlib/." .
+ extra_make=( -f win32/Makefile.gcc \
+ PREFIX="${host}-" \
+ SHAREDLIB= \
+ IMPLIB= \
+ LIBRARY_PATH="${prefix}/lib" \
+ INCLUDE_PATH="${prefix}/include" \
+ BINARY_PATH="${prefix}/bin" \
+ prefix="${prefix}" \
+ )
+ ;;
+
+ *)
+ CT_DoLog EXTRA "Configuring zlib"
+
+ CT_DoExecLog CFG \
+ CFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
+ CHOST="${host}" \
+ ${CONFIG_SHELL} \
+ "${CT_SRC_DIR}/zlib/configure" \
+ --prefix="${prefix}" \
+ --static \
+ "${extra_config[@]}"
+ ;;
+ esac
CT_DoLog EXTRA "Building zlib"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make "${extra_make[@]}" ${CT_JOBSFLAGS}
if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
if [ "${host}" = "${CT_BUILD}" ]; then
CT_DoLog EXTRA "Checking zlib"
- CT_DoExecLog ALL make ${JOBSFLAGS} -s check
+ CT_DoExecLog ALL make "${extra_make[@]}" -s test
else
# Cannot run host binaries on build in a canadian cross
CT_DoLog EXTRA "Skipping check for zlib on the host"
@@ -107,7 +126,7 @@ do_zlib_backend() {
fi
CT_DoLog EXTRA "Installing zlib"
- CT_DoExecLog ALL make install
+ CT_DoExecLog ALL make "${extra_make[@]}" install
}
fi # CT_ZLIB
diff --git a/scripts/build/companion_libs/100-gmp.sh b/scripts/build/companion_libs/100-gmp.sh
index c81874a..a17eda9 100644
--- a/scripts/build/companion_libs/100-gmp.sh
+++ b/scripts/build/companion_libs/100-gmp.sh
@@ -9,19 +9,16 @@ do_gmp_for_host() { :; }
do_gmp_for_target() { :; }
# Overide functions depending on configuration
-if [ "${CT_GMP}" = "y" ]; then
+if [ "${CT_GMP_TARGET}" = "y" -o "${CT_GMP}" = "y" ]; then
# Download GMP
do_gmp_get() {
- CT_GetFile "gmp-${CT_GMP_VERSION}" \
- https://gmplib.org/download/gmp \
- {http,ftp,https}://ftp.gnu.org/gnu/gmp
+ CT_Fetch GMP
}
# Extract GMP
do_gmp_extract() {
- CT_Extract "gmp-${CT_GMP_VERSION}"
- CT_Patch "gmp" "${CT_GMP_VERSION}"
+ CT_ExtractPatch GMP
}
# Build GMP for running on build
@@ -64,12 +61,40 @@ do_gmp_for_host() {
CT_EndStep
}
+if [ "${CT_GMP_TARGET}" = "y" ]; then
+do_gmp_for_target() {
+ local -a gmp_opts
+
+ CT_DoStep INFO "Installing GMP for target"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-target-${CT_HOST}"
+
+ gmp_opts+=( "host=${CT_TARGET}" )
+ case "${CT_TARGET}" in
+ *-*-mingw*)
+ prefix="/mingw"
+ ;;
+ *)
+ prefix="/usr"
+ ;;
+ esac
+ gmp_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" )
+ gmp_opts+=( "prefix=${prefix}" )
+ gmp_opts+=( "destdir=${CT_SYSROOT_DIR}" )
+ gmp_opts+=( "shared=${CT_SHARED_LIBS}" )
+ do_gmp_backend "${gmp_opts[@]}"
+
+ CT_Popd
+ CT_EndStep
+}
+fi
+
# Build GMP
# Parameter : description : type : default
# host : machine to run on : tuple : (none)
# prefix : prefix to install into : dir : (none)
# cflags : cflags to use : string : (empty)
# ldflags : ldflags to use : string : (empty)
+# destdir : install destination : dir : (none)
do_gmp_backend() {
local host
local prefix
@@ -84,15 +109,23 @@ do_gmp_backend() {
CT_DoLog EXTRA "Configuring GMP"
- if [ ! "${CT_GMP_5_0_2_or_later}" = "y" ]; then
- extra_config+=("--enable-mpbsd")
- fi
+ # To avoind “illegal text-relocation” linking error against
+ # the static library, see:
+ # https://github.com/Homebrew/homebrew-core/pull/25470
+ case "${host}" in
+ *darwin*)
+ extra_config+=("--with-pic")
+ ;;
+ esac
+ # FIXME: GMP's configure script doesn't respect the host parameter
+ # when not cross-compiling, ie when build == host.
CT_DoExecLog CFG \
+ CC="${host}-gcc" \
CFLAGS="${cflags} -fexceptions" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/gmp-${CT_GMP_VERSION}/configure" \
+ "${CT_SRC_DIR}/gmp/configure" \
--build=${CT_BUILD} \
--host=${host} \
--prefix="${prefix}" \
@@ -103,12 +136,12 @@ do_gmp_backend() {
"${extra_config[@]}"
CT_DoLog EXTRA "Building GMP"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
if [ "${host}" = "${CT_BUILD}" ]; then
CT_DoLog EXTRA "Checking GMP"
- CT_DoExecLog ALL make ${JOBSFLAGS} -s check
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check
else
# Cannot run host binaries on build in a canadian cross
CT_DoLog EXTRA "Skipping check for GMP on the host"
@@ -116,7 +149,7 @@ do_gmp_backend() {
fi
CT_DoLog EXTRA "Installing GMP"
- CT_DoExecLog ALL make install
+ CT_DoExecLog ALL make install DESTDIR="${destdir}"
}
fi # CT_GMP
diff --git a/scripts/build/companion_libs/110-mpfr.sh b/scripts/build/companion_libs/110-mpfr.sh
index 5a89077..d2cb9f6 100644
--- a/scripts/build/companion_libs/110-mpfr.sh
+++ b/scripts/build/companion_libs/110-mpfr.sh
@@ -13,16 +13,14 @@ if [ "${CT_MPFR}" = "y" ]; then
# Download MPFR
do_mpfr_get() {
- CT_GetFile "mpfr-${CT_MPFR_VERSION}" \
- {https,http,ftp}://ftp.gnu.org/gnu/mpfr \
- http://www.mpfr.org/mpfr-${CT_MPFR_VERSION}
+ CT_Fetch MPFR
}
# Extract MPFR
do_mpfr_extract() {
- CT_Extract "mpfr-${CT_MPFR_VERSION}"
- CT_Patch "mpfr" "${CT_MPFR_VERSION}"
+ CT_ExtractPatch MPFR
+ # TBD is it a problem with 2.4.x? The comment says it is not, yet the code is run
# OK, Gentoo have a sanity check that libtool.m4 and ltmain.sh have the
# same version number. Unfortunately, some tarballs of MPFR are not
# built sanely, and thus ./configure fails on Gentoo.
@@ -115,7 +113,7 @@ do_mpfr_backend() {
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure" \
+ "${CT_SRC_DIR}/mpfr/configure" \
--build=${CT_BUILD} \
--host=${host} \
--prefix="${prefix}" \
@@ -124,12 +122,12 @@ do_mpfr_backend() {
--enable-static
CT_DoLog EXTRA "Building MPFR"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
if [ "${host}" = "${CT_BUILD}" ]; then
CT_DoLog EXTRA "Checking MPFR"
- CT_DoExecLog ALL make ${JOBSFLAGS} -s check
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check
else
# Cannot run host binaries on build in a canadian cross
CT_DoLog EXTRA "Skipping check for MPFR on the host"
diff --git a/scripts/build/companion_libs/121-isl.sh b/scripts/build/companion_libs/121-isl.sh
index ef93bbd..3577b75 100644
--- a/scripts/build/companion_libs/121-isl.sh
+++ b/scripts/build/companion_libs/121-isl.sh
@@ -13,14 +13,12 @@ if [ "${CT_ISL}" = "y" ]; then
# Download ISL
do_isl_get() {
- CT_GetFile "isl-${CT_ISL_VERSION}" \
- http://isl.gforge.inria.fr
+ CT_Fetch ISL
}
# Extract ISL
do_isl_extract() {
- CT_Extract "isl-${CT_ISL_VERSION}"
- CT_Patch "isl" "${CT_ISL_VERSION}"
+ CT_ExtractPatch ISL
}
# Build ISL for running on build
@@ -86,21 +84,12 @@ do_isl_backend() {
CT_DoLog EXTRA "Configuring ISL"
- if [ "${CT_ISL_V_0_12_or_later}" != "y" ]; then
- extra_config+=("--with-libgmp-prefix=${prefix}")
- extra_config+=("--with-libgmpxx-prefix=${prefix}")
- fi
-
- if [ "${CT_ISL_V_0_14_or_later}" != "y" ]; then
- extra_config+=("--with-piplib=no")
- fi
-
CT_DoExecLog CFG \
CFLAGS="${cflags}" \
CXXFLAGS="${cxxflags}" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/isl-${CT_ISL_VERSION}/configure" \
+ "${CT_SRC_DIR}/isl/configure" \
--build=${CT_BUILD} \
--host=${host} \
--prefix="${prefix}" \
@@ -112,12 +101,12 @@ do_isl_backend() {
--with-clang=no
CT_DoLog EXTRA "Building ISL"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
if [ "${host}" = "${CT_BUILD}" ]; then
CT_DoLog EXTRA "Checking ISL"
- CT_DoExecLog ALL make ${JOBSFLAGS} -s check
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check
else
# Cannot run host binaries on build in a canadian cross
CT_DoLog EXTRA "Skipping check for ISL on the host"
diff --git a/scripts/build/companion_libs/130-cloog.sh b/scripts/build/companion_libs/130-cloog.sh
index b21b028..9ee897a 100644
--- a/scripts/build/companion_libs/130-cloog.sh
+++ b/scripts/build/companion_libs/130-cloog.sh
@@ -13,18 +13,12 @@ if [ "${CT_CLOOG}" = "y" ]; then
# Download CLooG
do_cloog_get() {
- CT_GetFile "cloog-${CT_CLOOG_VERSION}" \
- http://www.bastoul.net/cloog/pages/download \
- ftp://gcc.gnu.org/pub/gcc/infrastructure
+ CT_Fetch CLOOG
}
# Extract CLooG
do_cloog_extract() {
- CT_Extract "cloog-${CT_CLOOG_VERSION}"
- CT_Patch "cloog" "${CT_CLOOG_VERSION}"
-
- # Help the autostuff in case it thinks there are things to regenerate...
- CT_DoExecLog DEBUG mkdir -p "${CT_SRC_DIR}/cloog-${CT_CLOOG_VERSION}/m4"
+ CT_ExtractPatch CLOOG
}
# Build CLooG for running on build
@@ -85,11 +79,9 @@ do_cloog_backend() {
eval "${arg// /\\ }"
done
- if [ "${CT_CLOOG_0_18_or_later}" = y ]; then
- cloog_opts+=( --with-gmp=system --with-gmp-prefix="${prefix}" )
- cloog_opts+=( --with-isl=system --with-isl-prefix="${prefix}" )
- cloog_opts+=( --without-osl )
- fi
+ cloog_opts+=( --with-gmp=system --with-gmp-prefix="${prefix}" )
+ cloog_opts+=( --with-isl=system --with-isl-prefix="${prefix}" )
+ cloog_opts+=( --without-osl )
CT_DoLog EXTRA "Configuring CLooG"
@@ -98,7 +90,7 @@ do_cloog_backend() {
LDFLAGS="${ldflags}" \
LIBS="-lm" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/cloog-${CT_CLOOG_VERSION}/configure" \
+ "${CT_SRC_DIR}/cloog/configure" \
--build=${CT_BUILD} \
--host=${host} \
--prefix="${prefix}" \
@@ -109,12 +101,12 @@ do_cloog_backend() {
"${cloog_opts[@]}"
CT_DoLog EXTRA "Building CLooG"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
if [ "${host}" = "${CT_BUILD}" ]; then
CT_DoLog EXTRA "Checking CLooG"
- CT_DoExecLog ALL make ${JOBSFLAGS} -s check
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check
else
# Cannot run host binaries on build in a canadian cross
CT_DoLog EXTRA "Skipping check for CLooG on the host"
diff --git a/scripts/build/companion_libs/140-mpc.sh b/scripts/build/companion_libs/140-mpc.sh
index e6efb4f..2166ef1 100644
--- a/scripts/build/companion_libs/140-mpc.sh
+++ b/scripts/build/companion_libs/140-mpc.sh
@@ -13,15 +13,12 @@ if [ "${CT_MPC}" = "y" ]; then
# Download MPC
do_mpc_get() {
- CT_GetFile "mpc-${CT_MPC_VERSION}" .tar.gz \
- {http,ftp,https}://ftp.gnu.org/gnu/mpc \
- http://www.multiprecision.org/mpc/download
+ CT_Fetch MPC
}
# Extract MPC
do_mpc_extract() {
- CT_Extract "mpc-${CT_MPC_VERSION}"
- CT_Patch "mpc" "${CT_MPC_VERSION}"
+ CT_ExtractPatch MPC
}
# Build MPC for running on build
@@ -87,7 +84,7 @@ do_mpc_backend() {
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/mpc-${CT_MPC_VERSION}/configure" \
+ "${CT_SRC_DIR}/mpc/configure" \
--build=${CT_BUILD} \
--host=${host} \
--prefix="${prefix}" \
@@ -97,12 +94,12 @@ do_mpc_backend() {
--enable-static
CT_DoLog EXTRA "Building MPC"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
if [ "${host}" = "${CT_BUILD}" ]; then
CT_DoLog EXTRA "Checking MPC"
- CT_DoExecLog ALL make ${JOBSFLAGS} -s check
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check
else
# Cannot run host binaries on build in a canadian cross
CT_DoLog EXTRA "Skipping check for MPC on the host"
diff --git a/scripts/build/companion_libs/200-libelf.sh b/scripts/build/companion_libs/200-libelf.sh
index 807ce7e..f0d8be4 100644
--- a/scripts/build/companion_libs/200-libelf.sh
+++ b/scripts/build/companion_libs/200-libelf.sh
@@ -9,15 +9,11 @@ do_libelf_for_target() { :; }
if [ "${CT_LIBELF}" = "y" -o "${CT_LIBELF_TARGET}" = "y" ]; then
do_libelf_get() {
- # The server hosting libelf will return an "HTTP 300 : Multiple Choices"
- # error code if we try to download a file that does not exists there.
- # So we have to request the file with an explicit extension.
- CT_GetFile "libelf-${CT_LIBELF_VERSION}" .tar.gz http://www.mr511.de/software/
+ CT_Fetch LIBELF
}
do_libelf_extract() {
- CT_Extract "libelf-${CT_LIBELF_VERSION}"
- CT_Patch "libelf" "${CT_LIBELF_VERSION}"
+ CT_ExtractPatch LIBELF
}
if [ "${CT_LIBELF}" = "y" ]; then
@@ -85,6 +81,7 @@ do_libelf_for_target() {
libelf_opts+=( "destdir=${CT_SYSROOT_DIR}" )
libelf_opts+=( "host=${CT_TARGET}" )
+ libelf_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" )
libelf_opts+=( "prefix=${prefix}" )
libelf_opts+=( "shared=${CT_SHARED_LIBS}" )
do_libelf_backend "${libelf_opts[@]}"
@@ -131,7 +128,7 @@ do_libelf_backend() {
CFLAGS="${cflags} -fPIC" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure" \
+ "${CT_SRC_DIR}/libelf/configure" \
--build=${CT_BUILD} \
--host=${host} \
--target=${CT_TARGET} \
diff --git a/scripts/build/companion_libs/210-expat.sh b/scripts/build/companion_libs/210-expat.sh
index 5aa8e31..68667f6 100755..100644
--- a/scripts/build/companion_libs/210-expat.sh
+++ b/scripts/build/companion_libs/210-expat.sh
@@ -9,13 +9,11 @@ do_expat_for_target() { :; }
if [ "${CT_EXPAT_TARGET}" = "y" -o "${CT_EXPAT}" = "y" ]; then
do_expat_get() {
- CT_GetFile "expat-${CT_EXPAT_VERSION}" .tar.gz \
- http://downloads.sourceforge.net/project/expat/expat/${CT_EXPAT_VERSION}
+ CT_Fetch EXPAT
}
do_expat_extract() {
- CT_Extract "expat-${CT_EXPAT_VERSION}"
- CT_Patch "expat" "${CT_EXPAT_VERSION}"
+ CT_ExtractPatch EXPAT
}
if [ "${CT_EXPAT}" = "y" ]; then
@@ -56,6 +54,7 @@ do_expat_for_target() {
prefix="/usr"
;;
esac
+ expat_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" )
expat_opts+=( "prefix=${prefix}" )
expat_opts+=( "destdir=${CT_SYSROOT_DIR}" )
expat_opts+=( "shared=${CT_SHARED_LIBS}" )
@@ -95,17 +94,18 @@ do_expat_backend() {
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/expat-${CT_EXPAT_VERSION}/configure" \
+ "${CT_SRC_DIR}/expat/configure" \
--build=${CT_BUILD} \
--host=${host} \
--prefix="${prefix}" \
--enable-static \
+ --without-docbook \
"${extra_config[@]}"
CT_DoLog EXTRA "Building expat"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
CT_DoLog EXTRA "Installing expat"
- CT_DoExecLog ALL make install INSTALL_ROOT="${destdir}"
+ CT_DoExecLog ALL make install DESTDIR="${destdir}"
}
fi
diff --git a/scripts/build/companion_libs/220-ncurses.sh b/scripts/build/companion_libs/220-ncurses.sh
index 573523b..f1fcd1a 100644
--- a/scripts/build/companion_libs/220-ncurses.sh
+++ b/scripts/build/companion_libs/220-ncurses.sh
@@ -9,15 +9,11 @@ do_ncurses_for_target() { :; }
if [ "${CT_NCURSES_TARGET}" = "y" -o "${CT_NCURSES}" = "y" ]; then
do_ncurses_get() {
- CT_GetFile "ncurses-${CT_NCURSES_VERSION}" .tar.gz \
- {http,ftp,https}://ftp.gnu.org/pub/gnu/ncurses \
- ftp://invisible-island.net/ncurses
+ CT_Fetch NCURSES
}
do_ncurses_extract() {
- CT_Extract "ncurses-${CT_NCURSES_VERSION}"
- CT_DoExecLog ALL chmod -R u+w "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}"
- CT_Patch "ncurses" "${CT_NCURSES_VERSION}"
+ CT_ExtractPatch NCURSES
}
# We need tic that runs on the build when building ncurses for host/target
@@ -31,26 +27,13 @@ do_ncurses_for_build() {
"--without-tests" \
"--without-cxx" \
"--without-cxx-binding" \
- "--without-ada")
- # If we are not canadian, this is also our host curses
- # Unlike other companion libs, we skip host build if build==host
- # (i.e. in simple cross or native): ncurses may not be needed for
- # host, but we still need them on build to produce 'tic'.
- case "${CT_TOOLCHAIN_TYPE}" in
- native|cross)
- if [ "${CT_NCURSES_HOST_DISABLE_DB}" = "y" ]; then
- opts+=( "--disable-database" )
- fi
- if [ -n "${CT_NCURSES_HOST_FALLBACKS}" ]; then
- opts+=( "--with-fallbacks=${CT_NCURSES_HOST_FALLBACKS}" )
- fi
- opts+=( "${CT_NCURSES_HOST_CONFIG_ARGS[@]}" )
- ;;
- esac
+ "--without-ada" \
+ "--without-fallbacks" )
do_ncurses_backend host="${CT_BUILD}" \
destdir="${CT_BUILDTOOLS_PREFIX_DIR}" \
cflags="${CT_CFLAGS_FOR_BUILD}" \
ldflags="${CT_LDFLAGS_FOR_BUILD}" \
+ install_target=install.progs \
"${opts[@]}"
CT_Popd
CT_EndStep
@@ -60,13 +43,6 @@ if [ "${CT_NCURSES}" = "y" ]; then
do_ncurses_for_host() {
local -a opts
- # Unlike other companion libs, we skip host build if build==host
- # (i.e. in simple cross or native): ncurses may not be needed for
- # host, but we still need them on build to produce 'tic'.
- case "${CT_TOOLCHAIN_TYPE}" in
- native|cross) return 0;;
- esac
-
CT_DoStep INFO "Installing ncurses for host"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-ncurses-host-${CT_HOST}"
opts=("--enable-symlinks" \
@@ -76,7 +52,8 @@ do_ncurses_for_host() {
"--without-cxx-binding" \
"--without-ada" )
if [ "${CT_NCURSES_HOST_DISABLE_DB}" = "y" ]; then
- opts+=( "--disable-database" )
+ opts+=( "--disable-database" \
+ "--disable-db-install" )
fi
if [ -n "${CT_NCURSES_HOST_FALLBACKS}" ]; then
opts+=( "--with-fallbacks=${CT_NCURSES_HOST_FALLBACKS}" )
@@ -120,6 +97,7 @@ do_ncurses_for_target() {
prefix="${prefix}" \
destdir="${CT_SYSROOT_DIR}" \
shared="${CT_SHARED_LIBS}" \
+ cflags="${CT_ALL_TARGET_CFLAGS}" \
"${opts[@]}"
CT_Popd
CT_EndStep
@@ -142,12 +120,12 @@ do_ncurses_backend() {
local ldflags
local shared
local arg
- local for_target
+ local install_target=install
for arg in "$@"; do
case "$arg" in
--*)
- ncurses_opts+=("$arg")
+ ncurses_opts+=("${arg}")
;;
*)
eval "${arg// /\\ }"
@@ -177,7 +155,7 @@ do_ncurses_backend() {
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
+ "${CT_SRC_DIR}/ncurses/configure" \
--build=${CT_BUILD} \
--host=${host} \
--prefix="${prefix}" \
@@ -196,9 +174,13 @@ do_ncurses_backend() {
# it also builds ncurses anyway, and dedicated targets (install.includes and
# install.progs) do not do well with parallel make (-jX).
CT_DoLog EXTRA "Building ncurses"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
+
+ # STRIPPROG is handled by our wrapper around install.
CT_DoLog EXTRA "Installing ncurses"
- CT_DoExecLog ALL make install
+ CT_DoExecLog ALL \
+ STRIPPROG="${host}-strip" \
+ make "${install_target}"
}
fi
diff --git a/scripts/build/companion_libs/320-libiconv.sh b/scripts/build/companion_libs/320-libiconv.sh
index f2f0bef..9748ba2 100644
--- a/scripts/build/companion_libs/320-libiconv.sh
+++ b/scripts/build/companion_libs/320-libiconv.sh
@@ -9,13 +9,11 @@ do_libiconv_for_target() { :; }
if [ "${CT_LIBICONV}" = "y" ]; then
do_libiconv_get() {
- CT_GetFile "libiconv-${CT_LIBICONV_VERSION}" \
- http://ftp.gnu.org/pub/gnu/libiconv/
+ CT_Fetch LIBICONV
}
do_libiconv_extract() {
- CT_Extract "libiconv-${CT_LIBICONV_VERSION}"
- CT_Patch "libiconv" "${CT_LIBICONV_VERSION}"
+ CT_ExtractPatch LIBICONV
}
# Build libiconv for running on build
@@ -93,7 +91,7 @@ do_libiconv_backend() {
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/libiconv-${CT_LIBICONV_VERSION}/configure" \
+ "${CT_SRC_DIR}/libiconv/configure" \
--build=${CT_BUILD} \
--host="${host}" \
--prefix="${prefix}" \
@@ -102,7 +100,7 @@ do_libiconv_backend() {
"${extra_config[@]}" \
CT_DoLog EXTRA "Building libiconv"
- CT_DoExecLog ALL make CC="${host}-gcc ${cflags}" ${JOBSFLAGS}
+ CT_DoExecLog ALL make CC="${host}-gcc ${cflags}" ${CT_JOBSFLAGS}
CT_DoLog EXTRA "Installing libiconv"
CT_DoExecLog ALL make install CC="${host}-gcc ${cflags}"
diff --git a/scripts/build/companion_libs/330-gettext.sh b/scripts/build/companion_libs/330-gettext.sh
index 8828e5d..9fa3bdc 100644
--- a/scripts/build/companion_libs/330-gettext.sh
+++ b/scripts/build/companion_libs/330-gettext.sh
@@ -9,13 +9,11 @@ do_gettext_for_target() { :; }
if [ "${CT_GETTEXT}" = "y" ]; then
do_gettext_get() {
- CT_GetFile "gettext-${CT_GETTEXT_VERSION}" \
- http://ftp.gnu.org/pub/gnu/gettext/
+ CT_Fetch GETTEXT
}
do_gettext_extract() {
- CT_Extract "gettext-${CT_GETTEXT_VERSION}"
- CT_Patch "gettext" "${CT_GETTEXT_VERSION}"
+ CT_ExtractPatch GETTEXT
}
# Build gettext for running on build
@@ -82,6 +80,28 @@ do_gettext_backend() {
return
;;
+ # Starting with 0.21, gettext cannot build against uClibc-NG: gettext
+ # checks if it needs to use fopen wrapper (using gnulib) and newer versions
+ # of gnulib also check if fopen provided by the system supports 'e' and 'x'
+ # modes. In cross-compile environment, gnulib falls back to assuming fopen
+ # does not support these modes unless the target tuple is glibc or musl
+ # (rightly so, since these fopen modes are optional in uClibc-NG).
+ # Unfortunately, the fopen() wrapper does not compile against uClibc-NG's
+ # stdio.h then because it includes <stdio.h> after defining __need_FILE macro.
+ # It looks like two bugs, one in each of uClibc-ng and gnulib:
+ # - uClibc-ng does not include its internal headers with the definitions for the
+ # __BEGIN_NAMESPACE_STD/__END_NAMESPACE_STD macros, which therefore escape
+ # unsubstituted into the including code.
+ # - gnulib shouldn't expect the fopen() prototype if it only asked for FILE
+ # structure definition by defining the __need_FILE macro.
+ # Until the maintainers sort this out, disallow newer gettext versions if
+ # linking against uClibc-NG.
+ *-uclibc*)
+ if [ "${CT_GETTEXT_INCOMPATIBLE_WITH_UCLIBC_NG}" = "y" ]; then
+ CT_Abort "This version of gettext is incompatible with uClibc-NG"
+ fi
+ ;;
+
# A bit ugly. D__USE_MINGW_ANSI_STDIO=1 has its own {v}asprintf functions
# but gettext configure doesn't see this flag when it checks for that. An
# alternative may be to use CC="${host}-gcc ${cflags}" but that didn't
@@ -112,7 +132,7 @@ do_gettext_backend() {
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/gettext-${CT_GETTEXT_VERSION}/configure" \
+ "${CT_SRC_DIR}/gettext/configure" \
--build=${CT_BUILD} \
--host="${host}" \
--prefix="${prefix}" \
@@ -133,7 +153,7 @@ do_gettext_backend() {
"${extra_config[@]}"
CT_DoLog EXTRA "Building gettext"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
CT_DoLog EXTRA "Installing gettext"
CT_DoExecLog ALL make install
diff --git a/scripts/build/companion_libs/340-picolibc.sh b/scripts/build/companion_libs/340-picolibc.sh
new file mode 100644
index 0000000..e879005
--- /dev/null
+++ b/scripts/build/companion_libs/340-picolibc.sh
@@ -0,0 +1,171 @@
+# This file adds functions to build the Picolibc library
+# Copyright © 2020 Keith Packard
+# Licensed under the GPL v2 or later. See COPYING in the root of this package
+#
+# Edited by Keith Packard <keithp@keithp.com>
+#
+
+do_picolibc_get() { :; }
+do_picolibc_extract() { :; }
+do_picolibc_for_build() { :; }
+do_picolibc_for_host() { :; }
+do_picolibc_for_target() { :; }
+
+if [ "${CT_COMP_LIBS_PICOLIBC}" = "y" ]; then
+
+# Download picolibc
+do_picolibc_get() {
+ CT_Fetch PICOLIBC
+}
+
+do_picolibc_extract() {
+ CT_ExtractPatch PICOLIBC
+}
+
+#------------------------------------------------------------------------------
+# Build an additional target libstdc++ with "-Os" (optimise for speed) option
+# flag for libstdc++ "picolibc" variant.
+do_cc_libstdcxx_picolibc()
+{
+ local -a final_opts
+ local final_backend
+
+ if [ "${CT_LIBC_PICOLIBC_GCC_LIBSTDCXX}" = "y" ]; then
+ final_opts+=( "host=${CT_HOST}" )
+ final_opts+=( "libstdcxx_name=picolibc" )
+ final_opts+=( "prefix=${CT_PREFIX_DIR}" )
+ final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" )
+ final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
+ final_opts+=( "lang_list=c,c++" )
+ final_opts+=( "build_step=libstdcxx" )
+ final_opts+=( "extra_config+=('--enable-stdio=stdio_pure')" )
+ final_opts+=( "extra_config+=('--disable-wchar_t')" )
+ if [ "${CT_LIBC_PICOLIBC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then
+ final_opts+=( "enable_optspace=yes" )
+ fi
+
+ if [ "${CT_BARE_METAL}" = "y" ]; then
+ final_opts+=( "mode=baremetal" )
+ final_opts+=( "build_libgcc=yes" )
+ final_opts+=( "build_libstdcxx=yes" )
+ final_opts+=( "build_libgfortran=yes" )
+ if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
+ final_opts+=( "build_staticlinked=yes" )
+ fi
+ final_backend=do_gcc_core_backend
+ else
+ final_backend=do_gcc_backend
+ fi
+
+ CT_DoStep INFO "Installing libstdc++ picolibc"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-libstdcxx-picolibc"
+ "${final_backend}" "${final_opts[@]}"
+ CT_Popd
+
+ CT_EndStep
+ fi
+}
+
+do_picolibc_for_target() {
+ local -a picolibc_opts
+ local cflags_for_target
+
+ CT_DoStep INFO "Installing Picolibc library"
+
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-picolibc-build-${CT_BUILD}"
+
+ CT_DoLog EXTRA "Configuring Picolibc library"
+
+ # Multilib is the default, so if it is not enabled, disable it.
+ if [ "${CT_MULTILIB}" != "y" ]; then
+ picolibc_opts+=("-Dmultilib=false")
+ fi
+
+ yn_args="IO_C99FMT:io-c99-formats
+IO_LL:io-long-long
+REGISTER_FINI:newlib-register-fini
+NANO_MALLOC:newlib-nano-malloc
+ATEXIT_DYNAMIC_ALLOC:newlib-atexit-dynamic-alloc
+GLOBAL_ATEXIT:newlib-global-atexit
+LITE_EXIT:lite-exit
+MULTITHREAD:newlib-multithread
+RETARGETABLE_LOCKING:newlib-retargetable-locking
+ "
+
+ for ynarg in $yn_args; do
+ var="CT_LIBC_PICOLIBC_${ynarg%:*}"
+ eval var=\$${var}
+ argument=${ynarg#*:}
+
+
+ if [ "${var}" = "y" ]; then
+ picolibc_opts+=( "-D$argument=true" )
+ else
+ picolibc_opts+=( "-D$argument=false" )
+ fi
+ done
+
+ [ "${CT_USE_SYSROOT}" = "y" ] && \
+ picolibc_opts+=( "-Dsysroot-install=true" )
+
+ [ "${CT_LIBC_PICOLIBC_EXTRA_SECTIONS}" = "y" ] && \
+ CT_LIBC_PICOLIBC_TARGET_CFLAGS="${CT_LIBC_PICOLIBC_TARGET_CFLAGS} -ffunction-sections -fdata-sections"
+
+ [ "${CT_LIBC_PICOLIBC_LTO}" = "y" ] && \
+ CT_LIBC_PICOLIBC_TARGET_CFLAGS="${CT_LIBC_PICOLIBC_TARGET_CFLAGS} -flto"
+
+ cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_PICOLIBC_TARGET_CFLAGS}"
+
+ # Note: picolibc handles the build/host/target a little bit differently
+ # than one would expect:
+ # build : not used
+ # host : the machine building picolibc
+ # target : the machine picolibc runs on
+ meson_cflags=""
+ for cflag in ${cflags_for_target}; do
+ meson_cflags="${meson_cflags} '${cflag}',"
+ done
+ cat << EOF > picolibc-cross.txt
+[binaries]
+c = '${CT_TARGET}-gcc'
+ar = '${CT_TARGET}-ar'
+as = '${CT_TARGET}-as'
+strip = '${CT_TARGET}-strip'
+
+[host_machine]
+system = '${CT_TARGET_VENDOR}'
+cpu_family = '${CT_TARGET_ARCH}'
+cpu = '${CT_TARGET_ARCH}'
+endian = '${CT_ARCH_ENDIAN}'
+
+[properties]
+c_args = [ ${meson_cflags} '-nostdlib', '-fno-common', '-ftls-model=local-exec' ]
+needs_exe_wrapper = true
+skip_sanity_check = true
+EOF
+
+ CT_DoExecLog CFG \
+ meson \
+ --cross-file picolibc-cross.txt \
+ --prefix="${CT_PREFIX_DIR}" \
+ -Dincludedir=picolibc/include \
+ -Dlibdir=picolibc/${CT_TARGET}/lib \
+ -Dspecsdir="${CT_SYSROOT_DIR}"/lib \
+ "${CT_SRC_DIR}/picolibc" \
+ "${picolibc_opts[@]}" \
+ "${CT_LIBC_PICOLIBC_EXTRA_CONFIG_ARRAY[@]}"
+
+ CT_DoLog EXTRA "Building C library"
+ CT_DoExecLog ALL ninja
+
+ CT_DoLog EXTRA "Installing C library"
+ CT_DoExecLog ALL ninja install
+
+ CT_Popd
+ CT_EndStep
+
+ do_cc_libstdcxx_picolibc
+}
+
+fi
diff --git a/scripts/build/companion_libs/350-newlib_nano.sh b/scripts/build/companion_libs/350-newlib_nano.sh
new file mode 100644
index 0000000..ad6ea9a
--- /dev/null
+++ b/scripts/build/companion_libs/350-newlib_nano.sh
@@ -0,0 +1,276 @@
+# This file adds functions to build the Newlib library using the 'nano' configuration
+# Copyright © 2021 Keith Packard
+# Licensed under the GPL v2 or later. See COPYING in the root of this package
+#
+# Edited by Keith Packard <keithp@keithp.com>
+#
+
+do_newlib_nano_get() { :; }
+do_newlib_nano_extract() { :; }
+do_newlib_nano_for_build() { :; }
+do_newlib_nano_for_host() { :; }
+do_newlib_nano_for_target() { :; }
+
+if [ "${CT_COMP_LIBS_NEWLIB_NANO}" = "y" ]; then
+
+# Download newlib_nano
+do_newlib_nano_get() {
+ CT_Fetch NEWLIB_NANO
+}
+
+do_newlib_nano_extract() {
+ CT_ExtractPatch NEWLIB_NANO
+}
+
+# Some architectures assume "nano" libs co-exist with normal ones
+# in the same folder, though being suffixed with "_nano".
+do_nano_libc_symlinks() {
+ CT_Pushd "${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/lib/${multi_dir}"
+
+ CT_DoLog DEBUG "Installing nano libc symlinks in $PWD"
+
+ ln -s libc.a libc_nano.a
+ ln -s libm.a libm_nano.a
+ ln -s libg.a libg_nano.a
+
+ CT_Popd
+}
+
+do_nano_libstdcxx_symlinks() {
+ CT_Pushd "${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/lib/${multi_dir}"
+
+ CT_DoLog DEBUG "Installing nano libstdc++ symlinks in $PWD"
+
+ ln -s libstdc++.a libstdc++_nano.a
+ ln -s libsupc++.a libsupc++_nano.a
+
+ CT_Popd
+}
+
+#------------------------------------------------------------------------------
+# Build an additional target libstdc++ with "-Os" (optimise for speed) option
+# flag for libstdc++ "newlib_nano" variant.
+do_cc_libstdcxx_newlib_nano()
+{
+ local -a final_opts
+ local final_backend
+
+ if [ "${CT_NEWLIB_NANO_GCC_LIBSTDCXX}" = "y" ]; then
+ final_opts+=( "host=${CT_HOST}" )
+ final_opts+=( "libstdcxx_name=newlib-nano" )
+ final_opts+=( "prefix=${CT_PREFIX_DIR}" )
+ final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" )
+ final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
+ final_opts+=( "lang_list=c,c++" )
+ final_opts+=( "build_step=libstdcxx" )
+ if [ "${CT_LIBC_NEWLIB_NANO_ENABLE_TARGET_OPTSPACE}" = "y" ]; then
+ final_opts+=( "enable_optspace=yes" )
+ fi
+ if [ -n "${CT_NEWLIB_NANO_GCC_LIBSTDCXX_TARGET_CXXFLAGS}" ]; then
+ final_opts+=( "extra_cxxflags_for_target=${CT_NEWLIB_NANO_GCC_LIBSTDCXX_TARGET_CXXFLAGS}" )
+ fi
+
+ if [ "${CT_BARE_METAL}" = "y" ]; then
+ final_opts+=( "mode=baremetal" )
+ final_opts+=( "build_libgcc=yes" )
+ final_opts+=( "build_libstdcxx=yes" )
+ final_opts+=( "build_libgfortran=yes" )
+ if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
+ final_opts+=( "build_staticlinked=yes" )
+ fi
+ final_backend=do_gcc_core_backend
+ else
+ final_backend=do_gcc_backend
+ fi
+
+ CT_DoStep INFO "Installing libstdc++ newlib-nano"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-libstdcxx-newlib-nano"
+ "${final_backend}" "${final_opts[@]}"
+
+ # Create "nano" symlinks for libstdc++.a & libsup++.a
+ CT_IterateMultilibs do_nano_libstdcxx_symlinks libstdcxx_symlinks
+
+ CT_Popd
+
+ CT_EndStep
+ fi
+}
+
+do_newlib_nano_for_target() {
+ local -a newlib_nano_opts
+ local cflags_for_target
+
+ CT_DoStep INFO "Installing Newlib Nano library"
+
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-newlib_nano-build-${CT_BUILD}"
+
+ CT_DoLog EXTRA "Configuring Newlib Nano library"
+
+ # Multilib is the default, so if it is not enabled, disable it.
+ if [ "${CT_MULTILIB}" != "y" ]; then
+ newlib_nano_opts+=("-Dmultilib=false")
+ fi
+
+ if [ "${CT_LIBC_NEWLIB_NANO_IO_FLOAT}" = "y" ]; then
+ newlib_opts+=( "--enable-newlib-io-float" )
+ if [ "${CT_LIBC_NEWLIB_NANO_IO_LDBL}" = "y" ]; then
+ newlib_opts+=( "--enable-newlib-io-long-double" )
+ else
+ newlib_opts+=( "--disable-newlib-io-long-double" )
+ fi
+ else
+ newlib_opts+=( "--disable-newlib-io-float" )
+ newlib_opts+=( "--disable-newlib-io-long-double" )
+ fi
+
+ if [ "${CT_LIBC_NEWLIB_NANO_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then
+ newlib_opts+=( "--disable-newlib-supplied-syscalls" )
+ else
+ newlib_opts+=( "--enable-newlib-supplied-syscalls" )
+ fi
+
+ yn_args="IO_POS_ARGS:newlib-io-pos-args
+IO_C99FMT:newlib-io-c99-formats
+IO_LL:newlib-io-long-long
+REGISTER_FINI:newlib-register-fini
+NANO_MALLOC:newlib-nano-malloc
+NANO_FORMATTED_IO:newlib-nano-formatted-io
+ATEXIT_DYNAMIC_ALLOC:newlib-atexit-dynamic-alloc
+GLOBAL_ATEXIT:newlib-global-atexit
+LITE_EXIT:lite-exit
+REENT_SMALL:newlib-reent-small
+MULTITHREAD:newlib-multithread
+RETARGETABLE_LOCKING:newlib-retargetable-locking
+WIDE_ORIENT:newlib-wide-orient
+FSEEK_OPTIMIZATION:newlib-fseek-optimization
+FVWRITE_IN_STREAMIO:newlib-fvwrite-in-streamio
+UNBUF_STREAM_OPT:newlib-unbuf-stream-opt
+ENABLE_TARGET_OPTSPACE:target-optspace
+ "
+
+ for ynarg in $yn_args; do
+ var="CT_LIBC_NEWLIB_NANO_${ynarg%:*}"
+ eval var=\$${var}
+ argument=${ynarg#*:}
+
+
+ if [ "${var}" = "y" ]; then
+ newlib_opts+=( "--enable-$argument" )
+ else
+ newlib_opts+=( "--disable-$argument" )
+ fi
+ done
+
+ [ "${CT_LIBC_NEWLIB_NANO_EXTRA_SECTIONS}" = "y" ] && \
+ CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS="${CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS} -ffunction-sections -fdata-sections"
+
+ [ "${CT_LIBC_NEWLIB_NANO_LTO}" = "y" ] && \
+ CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS="${CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS} -flto"
+
+ cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS}"
+
+ # Note: newlib handles the build/host/target a little bit differently
+ # than one would expect:
+ # build : not used
+ # host : the machine building newlib
+ # target : the machine newlib runs on
+ CT_DoExecLog CFG \
+ CC_FOR_BUILD="${CT_BUILD}-gcc" \
+ CFLAGS_FOR_TARGET="${cflags_for_target}" \
+ AR_FOR_TARGET="`which ${CT_TARGET}-gcc-ar`" \
+ RANLIB_FOR_TARGET="`which ${CT_TARGET}-gcc-ranlib`" \
+ ${CONFIG_SHELL} \
+ "${CT_SRC_DIR}/newlib-nano/configure" \
+ --host=${CT_BUILD} \
+ --target=${CT_TARGET} \
+ --prefix=${CT_PREFIX_DIR} \
+ --exec-prefix=${CT_PREFIX_DIR}/newlib-nano \
+ --libdir=${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/lib \
+ "${newlib_opts[@]}" \
+ "${CT_LIBC_NEWLIB_NANO_EXTRA_CONFIG_ARRAY[@]}"
+
+ CT_DoLog EXTRA "Building Newlib Nano C library"
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
+
+ CT_DoLog EXTRA "Installing Newlib Nano C library"
+ CT_DoExecLog ALL make install
+
+ if [ "${CT_NEWLIB_NANO_INSTALL_IN_TARGET}" = "y" ]; then
+ cat > "${CT_SYSROOT_DIR}/lib/nano.specs" <<EOF
+%rename link nano_link
+%rename link_gcc_c_sequence nano_link_gcc_c_sequence
+%rename cpp_unique_options nano_cpp_unique_options
+
+*cpp_unique_options:
+-isystem =/include/newlib-nano %(nano_cpp_unique_options)
+
+*nano_libc:
+-lc_nano
+
+*nano_libgloss:
+%{specs=rdimon.specs:-lrdimon_nano} %{specs=nosys.specs:-lnosys}
+
+*link_gcc_c_sequence:
+%(nano_link_gcc_c_sequence) --start-group %G %(nano_libc) %(nano_libgloss) --end-group
+
+*link:
+%(nano_link) %:replace-outfile(-lc -lc_nano) %:replace-outfile(-lg -lg_nano) %:replace-outfile(-lm -lm_nano) %:replace-outfile(-lstdc++ -lstdc++_nano) %:replace-outfile(-lsupc++ -lsupc++_nano) %:replace-outfile(-lrdimon -lrdimon_nano)
+
+*lib:
+%{!shared:%{g*:-lg_nano} %{!p:%{!pg:-lc_nano}}%{p:-lc_p}%{pg:-lc_p}}
+
+EOF
+ else
+ cat > "${CT_SYSROOT_DIR}/lib/nano.specs" <<EOF
+%rename link newlib_nano_link
+%rename cpp newlib_nano_cpp
+%rename cc1plus newlib_nano_cc1plus
+
+*cpp:
+-isystem %:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/include) %(newlib_nano_cpp)
+
+*cc1plus:
+-idirafter %:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/include) %(newlib_nano_cc1plus)
+
+*link:
+-L%:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/lib/%M) -L%:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/lib)
+
+EOF
+ fi
+
+ # Create "nano" symlinks for libc.a, libg.a & libm.a
+ CT_IterateMultilibs do_nano_libc_symlinks libc_symlinks
+
+ CT_Popd
+ CT_EndStep
+
+ do_cc_libstdcxx_newlib_nano
+
+ if [ "${CT_NEWLIB_NANO_INSTALL_IN_TARGET}" = "y" ]; then
+ CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/${CT_TARGET}/include/newlib-nano"
+ CT_DoExecLog ALL cp -f "${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/include/newlib.h" \
+ "${CT_PREFIX_DIR}/${CT_TARGET}/include/newlib-nano/newlib.h"
+ CT_IterateMultilibs newlib_nano_copy_multilibs copylibs
+ fi
+}
+
+newlib_nano_copy_multilibs()
+{
+ local nano_lib_dir="${CT_PREFIX_DIR}/newlib-nano"
+ local multi_flags multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_index multi_count
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ for lib_a in "${nano_lib_dir}/${CT_TARGET}/lib/${multi_dir}/"*.a; do
+ if [ -f ${lib_a} ] && [ ! -L ${lib_a} ]; then
+ _f=$(basename "${lib_a}")
+ CT_DoExecLog ALL cp -f "${lib_a}" \
+ "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/${_f%.*}_nano.a"
+ fi
+ done
+}
+
+fi
diff --git a/scripts/build/companion_libs/400-gnuprumcu.sh b/scripts/build/companion_libs/400-gnuprumcu.sh
new file mode 100644
index 0000000..bba8574
--- /dev/null
+++ b/scripts/build/companion_libs/400-gnuprumcu.sh
@@ -0,0 +1,88 @@
+# Build script for gnuprumcu
+
+do_gnuprumcu_get() { :; }
+do_gnuprumcu_extract() { :; }
+do_gnuprumcu_for_build() { :; }
+do_gnuprumcu_for_host() { :; }
+do_gnuprumcu_for_target() { :; }
+
+if [ "${CT_COMP_LIBS_GNUPRUMCU}" = "y" ]; then
+
+do_gnuprumcu_get() {
+ CT_Fetch GNUPRUMCU
+}
+
+do_gnuprumcu_extract() {
+ CT_ExtractPatch GNUPRUMCU
+}
+
+
+do_gnuprumcu_for_target() {
+ local -a gnuprumcu_opts
+
+ CT_DoStep INFO "Installing gnuprumcu for the target"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-gnuprumcu-target-${CT_TARGET}"
+
+ gnuprumcu_opts+=( "destdir=${CT_SYSROOT_DIR}" )
+ gnuprumcu_opts+=( "host=${CT_TARGET}" )
+
+ gnuprumcu_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" )
+ gnuprumcu_opts+=( "prefix=${CT_PREFIX_DIR}" )
+ do_gnuprumcu_backend "${gnuprumcu_opts[@]}"
+
+ CT_Popd
+ CT_EndStep
+}
+
+
+# Build gnuprumcu
+# Parameter : description : type : default
+# destdir : out-of-tree install dir : string : /
+# host : machine to run on : tuple : (none)
+# prefix : prefix to install into : dir : (none)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
+# shared : also buils shared lib : bool : n
+do_gnuprumcu_backend() {
+ local destdir="/"
+ local host
+ local prefix
+ local cflags
+ local ldflags
+ local shared
+ local -a extra_config
+ local arg
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoLog EXTRA "Configuring gnuprumcu"
+
+ CT_DoExecLog CFG \
+ CC="${CT_TARGET}-${CT_CC}" \
+ RANLIB="${CT_TARGET}-ranlib" \
+ CFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
+ ${CONFIG_SHELL} \
+ "${CT_SRC_DIR}/gnuprumcu/configure" \
+ --build=${CT_BUILD} \
+ --host=${CT_TARGET} \
+ --prefix="${prefix}" \
+ "${extra_config[@]}"
+
+ CT_DoLog EXTRA "Building gnuprumcu"
+ CT_DoExecLog ALL make
+
+ CT_DoLog EXTRA "Installing gnuprumcu"
+
+ # Guard against $destdir$prefix == //
+ # which is a UNC path on Cygwin/MSYS2
+ if [[ ${destdir} == / ]] && [[ ${prefix} == /* ]]; then
+ destdir=
+ fi
+
+ CT_DoExecLog ALL make instroot="${destdir}" install
+}
+
+fi # CT_COMP_LIBS_GNUPRUMCU
diff --git a/scripts/build/companion_tools.sh b/scripts/build/companion_tools.sh
index b190ed7..7776f64 100644
--- a/scripts/build/companion_tools.sh
+++ b/scripts/build/companion_tools.sh
@@ -5,7 +5,7 @@ CT_COMP_TOOLS_FACILITY_LIST=
for f in "${CT_LIB_DIR}/scripts/build/companion_tools/"*.sh; do
_f="$(basename "${f}" .sh)"
_f="${_f#???-}"
- __f="CT_COMP_TOOLS_${_f}"
+ __f="CT_COMP_TOOLS_${_f^^}"
if [ "${!__f}" = "y" ]; then
CT_DoLog DEBUG "Enabling companion tool '${_f}'"
. "${f}"
diff --git a/scripts/build/companion_tools/050-make.sh b/scripts/build/companion_tools/050-make.sh
index 44487c1..df77d5b 100644
--- a/scripts/build/companion_tools/050-make.sh
+++ b/scripts/build/companion_tools/050-make.sh
@@ -1,17 +1,17 @@
# Build script for make
-do_companion_tools_make_get() {
- CT_GetFile "make-${CT_MAKE_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/make
+do_companion_tools_make_get()
+{
+ CT_Fetch MAKE
}
-do_companion_tools_make_extract() {
- CT_Extract "make-${CT_MAKE_VERSION}"
- CT_DoExecLog ALL chmod -R u+w "${CT_SRC_DIR}/make-${CT_MAKE_VERSION}"
- CT_Patch "make" "${CT_MAKE_VERSION}"
+do_companion_tools_make_extract()
+{
+ CT_ExtractPatch MAKE
}
-do_companion_tools_make_for_build() {
+do_companion_tools_make_for_build()
+{
CT_DoStep INFO "Installing make for build"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-make-build"
do_make_backend \
@@ -23,10 +23,14 @@ do_companion_tools_make_for_build() {
if [ "${CT_MAKE_GMAKE_SYMLINK}" = "y" ]; then
CT_DoExecLog ALL ln -sv make "${CT_BUILD_COMPTOOLS_DIR}/bin/gmake"
fi
+ if [ "${CT_MAKE_GNUMAKE_SYMLINK}" = "y" ]; then
+ CT_DoExecLog ALL ln -sv make "${CT_BUILD_COMPTOOLS_DIR}/bin/gnumake"
+ fi
CT_EndStep
}
-do_companion_tools_make_for_host() {
+do_companion_tools_make_for_host()
+{
CT_DoStep INFO "Installing make for host"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-make-host"
do_make_backend \
@@ -38,27 +42,37 @@ do_companion_tools_make_for_host() {
if [ "${CT_MAKE_GMAKE_SYMLINK}" = "y" ]; then
CT_DoExecLog ALL ln -sv make "${CT_PREFIX_DIR}/bin/gmake"
fi
+ if [ "${CT_MAKE_GNUMAKE_SYMLINK}" = "y" ]; then
+ CT_DoExecLog ALL ln -sv make "${CT_PREFIX_DIR}/bin/gnumake"
+ fi
CT_EndStep
}
-do_make_backend() {
+do_make_backend()
+{
local host
local prefix
local cflags
local ldflags
+ local -a extra_config
for arg in "$@"; do
eval "${arg// /\\ }"
done
+ if [ "${host}" != "${CT_BUILD}" ]; then
+ extra_config+=( --without-guile )
+ fi
+
CT_DoLog EXTRA "Configuring make"
CT_DoExecLog CFG \
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/make-${CT_MAKE_VERSION}/configure" \
+ "${CT_SRC_DIR}/make/configure" \
--host="${host}" \
- --prefix="${prefix}"
+ --prefix="${prefix}" \
+ "${extra_config[@]}"
CT_DoLog EXTRA "Building make"
CT_DoExecLog ALL make
diff --git a/scripts/build/companion_tools/100-m4.sh b/scripts/build/companion_tools/100-m4.sh
index e0fccd7..7d9044f 100644
--- a/scripts/build/companion_tools/100-m4.sh
+++ b/scripts/build/companion_tools/100-m4.sh
@@ -1,16 +1,17 @@
# Build script for m4
-do_companion_tools_m4_get() {
- CT_GetFile "m4-${CT_M4_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/m4
+do_companion_tools_m4_get()
+{
+ CT_Fetch M4
}
-do_companion_tools_m4_extract() {
- CT_Extract "m4-${CT_M4_VERSION}"
- CT_Patch "m4" "${CT_M4_VERSION}"
+do_companion_tools_m4_extract()
+{
+ CT_ExtractPatch M4
}
-do_companion_tools_m4_for_build() {
+do_companion_tools_m4_for_build()
+{
CT_DoStep INFO "Installing m4 for build"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-m4-build"
do_m4_backend \
@@ -22,7 +23,8 @@ do_companion_tools_m4_for_build() {
CT_EndStep
}
-do_companion_tools_m4_for_host() {
+do_companion_tools_m4_for_host()
+{
CT_DoStep INFO "Installing m4 for host"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-m4-host"
do_m4_backend \
@@ -34,11 +36,13 @@ do_companion_tools_m4_for_host() {
CT_EndStep
}
-do_m4_backend() {
+do_m4_backend()
+{
local host
local prefix
local cflags
local ldflags
+ local libs
for arg in "$@"; do
eval "${arg// /\\ }"
@@ -51,14 +55,21 @@ do_m4_backend() {
# it includes system <spawn.h> but expects a locally-built
# posix_spawn().
ldflags="${ldflags} -lrt"
+ ;;
+ *-mingw32)
+ # m4 is built with stack smashing protection enabled which
+ # is not part of mingw-w64 c library in v7.0.0 and later.
+ libs="${libs} -lssp"
+ ;;
esac
CT_DoLog EXTRA "Configuring m4"
CT_DoExecLog CFG \
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
+ LIBS="${libs}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/m4-${CT_M4_VERSION}/configure" \
+ "${CT_SRC_DIR}/m4/configure" \
--host="${host}" \
--prefix="${prefix}"
diff --git a/scripts/build/companion_tools/200-autoconf.sh b/scripts/build/companion_tools/200-autoconf.sh
index bccef75..28ff651 100644
--- a/scripts/build/companion_tools/200-autoconf.sh
+++ b/scripts/build/companion_tools/200-autoconf.sh
@@ -1,17 +1,17 @@
# Build script for autoconf
-do_companion_tools_autoconf_get() {
- CT_GetFile "autoconf-${CT_AUTOCONF_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/autoconf
+do_companion_tools_autoconf_get()
+{
+ CT_Fetch AUTOCONF
}
-do_companion_tools_autoconf_extract() {
- CT_Extract "autoconf-${CT_AUTOCONF_VERSION}"
- CT_DoExecLog ALL chmod -R u+w "${CT_SRC_DIR}/autoconf-${CT_AUTOCONF_VERSION}"
- CT_Patch "autoconf" "${CT_AUTOCONF_VERSION}"
+do_companion_tools_autoconf_extract()
+{
+ CT_ExtractPatch AUTOCONF
}
-do_companion_tools_autoconf_for_build() {
+do_companion_tools_autoconf_for_build()
+{
CT_DoStep INFO "Installing autoconf for build"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-autoconf-build"
do_autoconf_backend host=${CT_BUILD} prefix="${CT_BUILD_COMPTOOLS_DIR}"
@@ -19,7 +19,8 @@ do_companion_tools_autoconf_for_build() {
CT_EndStep
}
-do_companion_tools_autoconf_for_host() {
+do_companion_tools_autoconf_for_host()
+{
CT_DoStep INFO "Installing autoconf for host"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-autoconf-host"
do_autoconf_backend host=${CT_HOST} prefix="${CT_PREFIX_DIR}"
@@ -27,7 +28,8 @@ do_companion_tools_autoconf_for_host() {
CT_EndStep
}
-do_autoconf_backend() {
+do_autoconf_backend()
+{
local host
local prefix
@@ -42,7 +44,7 @@ do_autoconf_backend() {
CT_DoLog EXTRA "Configuring autoconf"
CT_DoExecLog CFG \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/autoconf-${CT_AUTOCONF_VERSION}/configure" \
+ "${CT_SRC_DIR}/autoconf/configure" \
--host="${host}" \
--prefix="${prefix}"
diff --git a/scripts/build/companion_tools/300-automake.sh b/scripts/build/companion_tools/300-automake.sh
index ee76463..9f7dd49 100644
--- a/scripts/build/companion_tools/300-automake.sh
+++ b/scripts/build/companion_tools/300-automake.sh
@@ -1,17 +1,17 @@
# Build script for automake
-do_companion_tools_automake_get() {
- CT_GetFile "automake-${CT_AUTOMAKE_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/automake
+do_companion_tools_automake_get()
+{
+ CT_Fetch AUTOMAKE
}
-do_companion_tools_automake_extract() {
- CT_Extract "automake-${CT_AUTOMAKE_VERSION}"
- CT_DoExecLog ALL chmod -R u+w "${CT_SRC_DIR}/automake-${CT_AUTOMAKE_VERSION}"
- CT_Patch "automake" "${CT_AUTOMAKE_VERSION}"
+do_companion_tools_automake_extract()
+{
+ CT_ExtractPatch AUTOMAKE
}
-do_companion_tools_automake_for_build() {
+do_companion_tools_automake_for_build()
+{
CT_DoStep INFO "Installing automake for build"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-automake-build"
do_automake_backend host=${CT_BUILD} prefix="${CT_BUILD_COMPTOOLS_DIR}"
@@ -19,7 +19,8 @@ do_companion_tools_automake_for_build() {
CT_EndStep
}
-do_companion_tools_automake_for_host() {
+do_companion_tools_automake_for_host()
+{
CT_DoStep INFO "Installing automake for host"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-automake-host"
do_automake_backend host=${CT_HOST} prefix="${CT_PREFIX_DIR}"
@@ -27,7 +28,8 @@ do_companion_tools_automake_for_host() {
CT_EndStep
}
-do_automake_backend() {
+do_automake_backend()
+{
local host
local prefix
@@ -38,7 +40,7 @@ do_automake_backend() {
CT_DoLog EXTRA "Configuring automake"
CT_DoExecLog CFG \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/automake-${CT_AUTOMAKE_VERSION}/configure" \
+ "${CT_SRC_DIR}/automake/configure" \
--host="${host}" \
--prefix="${prefix}"
diff --git a/scripts/build/companion_tools/400-libtool.sh b/scripts/build/companion_tools/400-libtool.sh
index 4461207..f7aeb6c 100644
--- a/scripts/build/companion_tools/400-libtool.sh
+++ b/scripts/build/companion_tools/400-libtool.sh
@@ -1,17 +1,17 @@
# Build script for libtool
-do_companion_tools_libtool_get() {
- CT_GetFile "libtool-${CT_LIBTOOL_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/libtool
+do_companion_tools_libtool_get()
+{
+ CT_Fetch LIBTOOL
}
-do_companion_tools_libtool_extract() {
- CT_Extract "libtool-${CT_LIBTOOL_VERSION}"
- CT_DoExecLog ALL chmod -R u+w "${CT_SRC_DIR}/libtool-${CT_LIBTOOL_VERSION}"
- CT_Patch "libtool" "${CT_LIBTOOL_VERSION}"
+do_companion_tools_libtool_extract()
+{
+ CT_ExtractPatch LIBTOOL
}
-do_companion_tools_libtool_for_build() {
+do_companion_tools_libtool_for_build()
+{
CT_DoStep INFO "Installing libtool for build"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libtool-build"
do_libtool_backend host=${CT_BUILD} prefix="${CT_BUILD_COMPTOOLS_DIR}"
@@ -19,7 +19,8 @@ do_companion_tools_libtool_for_build() {
CT_EndStep
}
-do_companion_tools_libtool_for_host() {
+do_companion_tools_libtool_for_host()
+{
CT_DoStep INFO "Installing libtool for host"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libtool-host"
do_libtool_backend host=${CT_HOST} prefix="${CT_PREFIX_DIR}"
@@ -27,7 +28,8 @@ do_companion_tools_libtool_for_host() {
CT_EndStep
}
-do_libtool_backend() {
+do_libtool_backend()
+{
local host
local prefix
@@ -38,7 +40,7 @@ do_libtool_backend() {
CT_DoLog EXTRA "Configuring libtool"
CT_DoExecLog CFG \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/libtool-${CT_LIBTOOL_VERSION}/configure" \
+ "${CT_SRC_DIR}/libtool/configure" \
--host="${host}" \
--prefix="${prefix}"
diff --git a/scripts/build/companion_tools/500-dtc.sh b/scripts/build/companion_tools/500-dtc.sh
new file mode 100644
index 0000000..a16ff62
--- /dev/null
+++ b/scripts/build/companion_tools/500-dtc.sh
@@ -0,0 +1,87 @@
+# Build script for DTC (device tree compiler)
+
+do_companion_tools_dtc_get()
+{
+ CT_Fetch DTC
+}
+
+do_companion_tools_dtc_extract()
+{
+ CT_ExtractPatch DTC
+}
+
+do_companion_tools_dtc_for_build()
+{
+ CT_DoStep INFO "Installing dtc for build"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-dtc-build"
+ do_dtc_backend \
+ host=${CT_BUILD} \
+ prefix="${CT_BUILD_COMPTOOLS_DIR}" \
+ cflags="${CT_CFLAGS_FOR_BUILD}" \
+ ldflags="${CT_LDFLAGS_FOR_BUILD}"
+ CT_Popd
+ CT_EndStep
+}
+
+do_companion_tools_dtc_for_host()
+{
+ CT_DoStep INFO "Installing dtc for host"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-dtc-host"
+ do_dtc_backend \
+ host=${CT_HOST} \
+ prefix="${CT_PREFIX_DIR}" \
+ cflags="${CT_CFLAGS_FOR_HOST}" \
+ ldflags="${CT_LDFLAGS_FOR_HOST}"
+ CT_Popd
+ CT_EndStep
+}
+
+do_dtc_backend()
+{
+ local host
+ local prefix
+ local cflags
+ local ldflags
+ local -a extra_opts
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ # Override PKG_CONFIG: if pkg-config is not installed, DTC's makefile
+ # misinterprets the error code and tries to enable YAML support while
+ # not linking against libyaml. NO_YAML=1 is sufficient to make the build
+ # pass; PKG_CONFIG=/bin/true just suppresses some scary error messages.
+ extra_opts=( \
+ CC="${host}-gcc" \
+ AR="${host}-ar" \
+ PREFIX="${prefix}" \
+ PKG_CONFIG=/bin/true \
+ NO_PYTHON=1 \
+ NO_YAML=1 \
+ BIN=dtc \
+ )
+ if [ -n "${CT_DTC_VERBOSE}" ]; then
+ extra_opts+=( V=1 )
+ fi
+ case "${host}" in
+ *-mingw32)
+ # Turn off warnings: mingw32 hosts complain about %zd formats even though
+ # they seem to be supported by mingw32. Only build 'dtc', again, because
+ # other binaries use syscalls not available under mingw32, but we also
+ # do not need them. Hijack WARNINGS to override lstat with stat (Windows
+ # does not have symlinks).
+ extra_opts+=( BIN=dtc WARNINGS=-Dlstat=stat )
+ ;;
+ esac
+
+ CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/dtc/." .
+
+ CT_DoLog EXTRA "Building dtc"
+ CT_DoExecLog ALL make all "${extra_opts[@]}"
+
+ # Only install binaries, we don't support shared libraries in installation
+ # directory yet.
+ CT_DoLog EXTRA "Installing dtc"
+ CT_DoExecLog ALL make install-bin "${extra_opts[@]}"
+}
diff --git a/scripts/build/companion_tools/510-bison.sh b/scripts/build/companion_tools/510-bison.sh
new file mode 100644
index 0000000..90bf9ec
--- /dev/null
+++ b/scripts/build/companion_tools/510-bison.sh
@@ -0,0 +1,66 @@
+# Build script for bison
+
+do_companion_tools_bison_get()
+{
+ CT_Fetch BISON
+}
+
+do_companion_tools_bison_extract()
+{
+ CT_ExtractPatch BISON
+}
+
+do_companion_tools_bison_for_build()
+{
+ CT_DoStep INFO "Installing bison for build"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-bison-build"
+ do_bison_backend \
+ host=${CT_BUILD} \
+ prefix="${CT_BUILD_COMPTOOLS_DIR}" \
+ cflags="${CT_CFLAGS_FOR_BUILD}" \
+ ldflags="${CT_LDFLAGS_FOR_BUILD}"
+ CT_Popd
+ CT_EndStep
+}
+
+do_companion_tools_bison_for_host()
+{
+ CT_DoStep INFO "Installing bison for host"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-bison-host"
+ do_bison_backend \
+ host=${CT_HOST} \
+ prefix="${CT_PREFIX_DIR}" \
+ cflags="${CT_CFLAGS_FOR_HOST}" \
+ ldflags="${CT_LDFLAGS_FOR_HOST}"
+ CT_Popd
+ CT_EndStep
+}
+
+do_bison_backend()
+{
+ local host
+ local prefix
+ local cflags
+ local ldflags
+ local -a extra_config
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoLog EXTRA "Configuring bison"
+ CT_DoExecLog CFG \
+ CFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
+ ${CONFIG_SHELL} \
+ "${CT_SRC_DIR}/bison/configure" \
+ --host="${host}" \
+ --prefix="${prefix}" \
+ "${extra_config[@]}"
+
+ CT_DoLog EXTRA "Building bison"
+ CT_DoExecLog ALL make
+
+ CT_DoLog EXTRA "Installing bison"
+ CT_DoExecLog ALL make install
+}
diff --git a/scripts/build/debug.sh b/scripts/build/debug.sh
index f07b295..f8178dd 100644
--- a/scripts/build/debug.sh
+++ b/scripts/build/debug.sh
@@ -5,7 +5,7 @@ CT_DEBUG_FACILITY_LIST=
for f in "${CT_LIB_DIR}/scripts/build/debug/"*.sh; do
_f="$(basename "${f}" .sh)"
_f="${_f#???-}"
- __f="CT_DEBUG_${_f}"
+ __f="CT_DEBUG_${_f^^}"
if [ "${!__f}" = "y" ]; then
CT_DoLog DEBUG "Enabling debug '${_f}'"
. "${f}"
diff --git a/scripts/build/debug/000-template.sh b/scripts/build/debug/000-template.sh
deleted file mode 100644
index 47d2cae..0000000
--- a/scripts/build/debug/000-template.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-# Template file for a debug utility
-
-# Put your download code here
-do_debug_foobar_get() {
- # For example:
- # CT_GetFile "foobar-${CT_FOOBAR_VERSION}" http://foobar.com/releases/
- :
-}
-
-# Put your extract code here
-do_debug_foobar_extract() {
- # For example:
- # CT_Extract "foobar-${CT_FOOBAR_VERSION}"
- # CT_Patch "foobar" "${CT_FOOBAR_VERSION}"
- :
-}
-
-# Put your build code here
-do_debug_foobar_build() {
- # For example:
- # mkdir -p "${CT_BUILD_DIR}/build-foobar"
- # CT_Pushd "${CT_BUILD_DIR}/build-foobar"
- # CT_DoExecLog CFG \
- # "${CT_SRC_DIR}/foobar-${CT_FOOBAR_VERSION}/configure" \
- # --build=${CT_BUILD} \
- # --host=${CT_TARGET} \
- # --prefix=/usr \
- # --foobar-options
- # CT_DoExecLog ALL make
- # CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
- # CT_Popd
- :
-}
-
diff --git a/scripts/build/debug/200-duma.sh b/scripts/build/debug/200-duma.sh
index 2a9b01f..9e2379e 100644
--- a/scripts/build/debug/200-duma.sh
+++ b/scripts/build/debug/200-duma.sh
@@ -1,24 +1,11 @@
# Build script for D.U.M.A.
do_debug_duma_get() {
- local dl_base
-
- dl_base="http://downloads.sourceforge.net/project/duma/duma"
- dl_base+="/${CT_DUMA_VERSION//_/.}"
-
- # Downloading an non-existing file from sourceforge will give you an
- # HTML file containing an error message, instead of returning a 404.
- # Sigh...
- CT_GetFile "duma_${CT_DUMA_VERSION}" .tar.gz "${dl_base}"
- # Downloading from sourceforge may leave garbage, cleanup
- CT_DoExecLog ALL rm -f "${CT_TARBALLS_DIR}/showfiles.php"*
+ CT_Fetch DUMA
}
do_debug_duma_extract() {
- CT_Extract "duma_${CT_DUMA_VERSION}"
- CT_Pushd "${CT_SRC_DIR}/duma_${CT_DUMA_VERSION}"
- CT_Patch nochdir "duma" "${CT_DUMA_VERSION}"
- CT_Popd
+ CT_ExtractPatch DUMA
}
do_debug_duma_build() {
@@ -26,14 +13,14 @@ do_debug_duma_build() {
CT_DoStep INFO "Installing D.U.M.A."
CT_DoLog EXTRA "Copying sources"
- cp -a "${CT_SRC_DIR}/duma_${CT_DUMA_VERSION}/." "${CT_BUILD_DIR}/build-duma"
+ cp -a "${CT_SRC_DIR}/duma/." "${CT_BUILD_DIR}/build-duma"
CT_Pushd "${CT_BUILD_DIR}/build-duma"
make_args=(
prefix="${CT_DEBUGROOT_DIR}/usr"
HOSTCC="${CT_BUILD}-gcc"
- CC="${CT_TARGET}-${CT_CC}"
- CXX="${CT_TARGET}-g++"
+ CC="${CT_TARGET}-${CT_CC} ${CT_ALL_TARGET_CFLAGS}"
+ CXX="${CT_TARGET}-g++ ${CT_ALL_TARGET_CFLAGS}"
RANLIB="${CT_TARGET}-ranlib"
OS="${CT_KERNEL}"
)
diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh
index a5ac7f9..4afaba4 100644
--- a/scripts/build/debug/300-gdb.sh
+++ b/scripts/build/debug/300-gdb.sh
@@ -1,190 +1,150 @@
# Build script for the gdb debug facility
-do_debug_gdb_get() {
- local linaro_version=""
- local linaro_series=""
-
- if [ "${CT_GDB_CUSTOM}" = "y" ]; then
- CT_GetCustom "gdb" "${CT_GDB_CUSTOM_VERSION}" \
- "${CT_GDB_CUSTOM_LOCATION}"
- else
- case "${CT_GDB_VERSION}" in
- linaro-*)
- CT_GetLinaro "gdb" "${CT_GDB_VERSION}"
- ;;
- *)
- CT_GetFile "gdb-${CT_GDB_VERSION}" \
- http://mirrors.kernel.org/sourceware/gdb \
- {http,ftp,https}://ftp.gnu.org/pub/gnu/gdb \
- ftp://{sourceware.org,gcc.gnu.org}/pub/gdb/releases
- ;;
- esac
- fi
+do_debug_gdb_get()
+{
+ CT_Fetch GDB
}
-do_debug_gdb_extract() {
- CT_Extract "gdb-${CT_GDB_VERSION}"
- CT_Patch "gdb" "${CT_GDB_VERSION}"
-
- if [ -n "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then
- CT_ConfigureXtensa "gdb" "${CT_GDB_VERSION}"
- fi
+do_debug_gdb_extract()
+{
+ CT_ExtractPatch GDB
}
-do_debug_gdb_build() {
- local -a extra_config
-
- gdb_src_dir="${CT_SRC_DIR}/gdb-${CT_GDB_VERSION}"
-
- # Version 6.3 and below behave badly with gdbmi
- case "${CT_GDB_VERSION}" in
- 6.2*|6.3) extra_config+=("--disable-gdbmi");;
- esac
-
- if [ "${CT_GDB_HAS_PKGVERSION_BUGURL}" = "y" ]; then
- extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
- [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
- fi
-
+do_debug_gdb_build()
+{
if [ "${CT_GDB_CROSS}" = "y" ]; then
+ local gcc_version p _p
local -a cross_extra_config
- local gcc_version
CT_DoStep INFO "Installing cross-gdb"
- CT_DoLog EXTRA "Configuring cross-gdb"
-
- mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
- cd "${CT_BUILD_DIR}/build-gdb-cross"
-
- cross_extra_config=("${extra_config[@]}")
-
- # For gdb-cross this combination of flags forces
- # gdb configure to fall back to default '-lexpat' flag
- # which is acceptable.
- #
- # NOTE: DO NOT USE --with-libexpat-prefix (until GDB configure is smarter)!!!
- # It conflicts with a static build: GDB's configure script will find the shared
- # version of expat and will attempt to link that, despite the -static flag.
- # The link will fail, and configure will abort with "expat missing or unusable"
- # message.
- cross_extra_config+=("--with-expat")
- cross_extra_config+=("--without-libexpat-prefix")
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-gdb-cross"
- case "${CT_THREADS}" in
- none) cross_extra_config+=("--disable-threads");;
- *) cross_extra_config+=("--enable-threads");;
- esac
+ cross_extra_config=( "${CT_GDB_CROSS_EXTRA_CONFIG_ARRAY[@]}" )
if [ "${CT_GDB_CROSS_PYTHON}" = "y" ]; then
- cross_extra_config+=( "--with-python=yes" )
+ if [ -z "${CT_GDB_CROSS_PYTHON_BINARY}" ]; then
+ if [ "${CT_CANADIAN}" = "y" -o "${CT_CROSS_NATIVE}" = "y" ]; then
+ CT_Abort "For canadian build, Python wrapper runnable on the build machine must be provided. Set CT_GDB_CROSS_PYTHON_BINARY."
+ elif [ "${CT_CONFIGURE_has_python}" = "y" ]; then
+ cross_extra_config+=("--with-python=${python}")
+ else
+ CT_Abort "Python support requested in GDB, but Python not found. Set CT_GDB_CROSS_PYTHON_BINARY."
+ fi
+ else
+ cross_extra_config+=("--with-python=${CT_GDB_CROSS_PYTHON_BINARY}")
+ fi
else
- cross_extra_config+=( "--with-python=no" )
+ cross_extra_config+=("--with-python=no")
fi
+
if [ "${CT_GDB_CROSS_SIM}" = "y" ]; then
- cross_extra_config+=( "--enable-sim" )
+ cross_extra_config+=("--enable-sim")
else
- cross_extra_config+=( "--disable-sim" )
- fi
- if [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ]; then
- cross_extra_config+=("--disable-nls")
+ cross_extra_config+=("--disable-sim")
fi
- CPP_for_gdb="${CT_HOST}-cpp ${CT_CFLAGS_FOR_HOST}"
- CC_for_gdb="${CT_HOST}-gcc ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST}"
- CXX_for_gdb="${CT_HOST}-g++ ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST}"
- LD_for_gdb="${CT_HOST}-ld ${CT_LDFLAGS_FOR_HOST}"
- if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
- CC_for_gdb+=" -static"
- CXX_for_gdb+=" -static"
- LD_for_gdb+=" -static"
+ if ${CT_HOST}-gcc --version 2>&1 | grep clang; then
+ # clang detects the line from gettext's _ macro as format string
+ # not being a string literal and produces a lot of warnings - which
+ # ct-ng's logger faithfully relays to user if this happens in the
+ # error() function. Suppress them.
+ cross_extra_config+=("--enable-build-warnings=,-Wno-format-nonliteral,-Wno-format-security")
fi
- case "${CT_HOST}" in
- *darwin*)
- # FIXME: Really, we should be testing for host compiler being clang.
- CC_for_gdb+=" -Qunused-arguments"
- CXX_for_gdb+=" -Qunused-arguments"
- ;;
- esac
- # Fix up whitespace. Some older GDB releases (e.g. 6.8a) get confused if there
- # are multiple consecutive spaces: sub-configure scripts replace them with a
- # single space and then complain that $CC value changed from that in
- # the master directory.
- CPP_for_gdb=`echo $CPP_for_gdb`
- CC_for_gdb=`echo $CC_for_gdb`
- CXX_for_gdb=`echo $CXX_for_gdb`
- LD_for_gdb=`echo $LD_for_gdb`
-
- # Disable binutils options when building from the binutils-gdb repo.
- cross_extra_config+=("--disable-binutils")
- cross_extra_config+=("--disable-ld")
- cross_extra_config+=("--disable-gas")
-
- CT_DoLog DEBUG "Extra config passed: '${cross_extra_config[*]}'"
-
- CT_DoExecLog CFG \
- CPP="${CPP_for_gdb}" \
- CC="${CC_for_gdb}" \
- CXX="${CXX_for_gdb}" \
- LD="${LD_for_gdb}" \
- ${CONFIG_SHELL} \
- "${gdb_src_dir}/configure" \
- --build=${CT_BUILD} \
- --host=${CT_HOST} \
- --target=${CT_TARGET} \
- --prefix="${CT_PREFIX_DIR}" \
- --with-build-sysroot="${CT_SYSROOT_DIR}" \
+ # Target libexpat resides in sysroot and does not have
+ # any dependencies, so just passing '-lexpat' to gcc is enough.
+ #
+ # By default gdb configure looks for expat in '$prefix/lib'
+ # directory. In our case '$prefix/lib' resolves to '/usr/lib'
+ # where libexpat for build platform lives, which is
+ # unacceptable for cross-compiling.
+ #
+ # To prevent this '--without-libexpat-prefix' flag must be passed.
+ # Thus configure falls back to '-lexpat', which is exactly what we want.
+ #
+ # NOTE: DO NOT USE --with-libexpat-prefix (until GDB configure is smarter)!!!
+ # It conflicts with a static build: GDB's configure script will find the shared
+ # version of expat and will attempt to link that, despite the -static flag.
+ # The link will fail, and configure will abort with "expat missing or unusable"
+ # message.
+ extra_config+=("--with-expat")
+ extra_config+=("--without-libexpat-prefix")
+
+ do_gdb_backend \
+ buildtype=cross \
+ host="${CT_HOST}" \
+ cflags="${CT_CFLAGS_FOR_HOST}" \
+ ldflags="${CT_LDFLAGS_FOR_HOST}" \
+ prefix="${CT_PREFIX_DIR}" \
+ static="${CT_GDB_CROSS_STATIC}" \
--with-sysroot="${CT_SYSROOT_DIR}" \
- --disable-werror \
- "${cross_extra_config[@]}" \
- "${CT_GDB_CROSS_EXTRA_CONFIG_ARRAY[@]}"
-
- CT_DoLog EXTRA "Building cross-gdb"
- CT_DoExecLog ALL make ${JOBSFLAGS}
-
- CT_DoLog EXTRA "Installing cross-gdb"
- CT_DoExecLog ALL make install
+ "${cross_extra_config[@]}"
if [ "${CT_BUILD_MANUALS}" = "y" ]; then
CT_DoLog EXTRA "Building and installing the cross-GDB manuals"
- CT_DoExecLog ALL make ${JOBSFLAGS} pdf html
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} pdf html
CT_DoExecLog ALL make install-{pdf,html}-gdb
fi
- if [ "${CT_GDB_INSTALL_GDBINIT}" = "y" ]; then
- CT_DoLog EXTRA "Installing '.gdbinit' template"
- # See in scripts/build/internals.sh for why we do this
- if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then
- gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" )
- else
- gcc_version=$(sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \
- "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/version.c" \
- )
- fi
- sed -r \
- -e "s:@@PREFIX@@:${CT_PREFIX_DIR}:;" \
- -e "s:@@VERSION@@:${gcc_version}:;" \
- "${CT_LIB_DIR}/scripts/build/debug/gdbinit.in" \
- >"${CT_PREFIX_DIR}/share/gdb/gdbinit"
- fi # Install gdbinit sample
+ CT_DoLog EXTRA "Installing '.gdbinit' template"
+ # See in scripts/build/internals.sh for why we do this
+ # TBD GCC 3.x and older not supported
+ if [ -f "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ]; then
+ gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER")
+ else
+ gcc_version=$(sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \
+ "${CT_SRC_DIR}/gcc/gcc/version.c" \
+ )
+ fi
+ sed -r \
+ -e "s:@@PREFIX@@:${CT_PREFIX_DIR}:;" \
+ -e "s:@@VERSION@@:${gcc_version}:;" \
+ "${CT_LIB_DIR}/scripts/build/debug/gdbinit.in" \
+ >"${CT_PREFIX_DIR}/share/gdb/gdbinit"
+ CT_Popd
CT_EndStep
fi
if [ "${CT_GDB_NATIVE}" = "y" ]; then
local -a native_extra_config
+ local subdir
CT_DoStep INFO "Installing native gdb"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-gdb-native"
- native_extra_config=("${extra_config[@]}")
+ native_extra_config+=("--program-prefix=")
- # We may not have C++ language configured for target
- native_extra_config+=("--disable-build-with-cxx")
+ # gdbserver gets enabled by default with gdb
+ # since gdbserver was promoted to top-level
+ if [ "${CT_GDB_GDBSERVER_TOPLEVEL}" = "y" ]; then
+ native_extra_config+=("--disable-gdbserver")
+ fi
# GDB on Mingw depends on PDcurses, not ncurses
if [ "${CT_MINGW32}" != "y" ]; then
native_extra_config+=("--with-curses")
fi
+ if [ "${CT_GDB_NATIVE_BUILD_IPA_LIB}" = "y" ]; then
+ native_extra_config+=("--enable-inprocess-agent")
+ else
+ native_extra_config+=("--disable-inprocess-agent")
+ fi
+
+ export ac_cv_func_strncmp_works=yes
+
+ # TBD do we need all these?
+ native_extra_config+=(
+ --without-uiout
+ --disable-gdbtk
+ --without-x
+ --disable-sim
+ --without-included-gettext
+ --without-develop
+ --sysconfdir=/etc
+ --localstatedir=/var
+ )
+
# Target libexpat resides in sysroot and does not have
# any dependencies, so just passing '-lexpat' to gcc is enough.
#
@@ -201,146 +161,194 @@ do_debug_gdb_build() {
# version of expat and will attempt to link that, despite the -static flag.
# The link will fail, and configure will abort with "expat missing or unusable"
# message.
- native_extra_config+=("--with-expat")
- native_extra_config+=("--without-libexpat-prefix")
+ extra_config+=("--with-expat")
+ extra_config+=("--without-libexpat-prefix")
+
+ do_gdb_backend \
+ buildtype=native \
+ subdir=${subdir} \
+ host="${CT_TARGET}" \
+ cflags="${CT_ALL_TARGET_CFLAGS}" \
+ ldflags="${CT_ALL_TARGET_LDFLAGS}" \
+ static="${CT_GDB_NATIVE_STATIC}" \
+ static_libstdc="${CT_GDB_NATIVE_STATIC_LIBSTDC}" \
+ prefix=/usr \
+ destdir="${CT_DEBUGROOT_DIR}" \
+ "${native_extra_config[@]}"
- CT_DoLog EXTRA "Configuring native gdb"
+ unset ac_cv_func_strncmp_works
- mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
- cd "${CT_BUILD_DIR}/build-gdb-native"
+ CT_Popd
+ CT_EndStep # native gdb build
+ fi
- case "${CT_THREADS}" in
- none) native_extra_config+=("--disable-threads");;
- *) native_extra_config+=("--enable-threads");;
- esac
+ if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
+ local -a native_extra_config
+ local subdir
- [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && \
- native_extra_config+=("--disable-nls")
-
- CPP_for_gdb="${CT_TARGET}-cpp"
- CC_for_gdb="${CT_TARGET}-${CT_CC}"
- CXX_for_gdb="${CT_TARGET}-g++"
- LD_for_gdb="${CT_TARGET}-ld"
- if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
- CC_for_gdb+=" -static"
- CXX_for_gdb+=" -static"
- LD_for_gdb+=" -static"
+ if [ "${CT_GDB_GDBSERVER_TOPLEVEL}" != "y" ]; then
+ subdir=gdb/gdbserver/
+ else
+ native_extra_config+=("--disable-gdb")
fi
- export ac_cv_func_strncmp_works=yes
+ CT_DoStep INFO "Installing gdb server"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-gdb-server"
- # Disable binutils options when building from the binutils-gdb repo.
- native_extra_config+=("--disable-binutils")
- native_extra_config+=("--disable-ld")
- native_extra_config+=("--disable-gas")
-
- CT_DoLog DEBUG "Extra config passed: '${native_extra_config[*]}'"
-
- CT_DoExecLog CFG \
- CPP="${CPP_for_gdb}" \
- CC="${CC_for_gdb}" \
- CXX="${CXX_for_gdb}" \
- LD="${LD_for_gdb}" \
- ${CONFIG_SHELL} \
- "${gdb_src_dir}/configure" \
- --build=${CT_BUILD} \
- --host=${CT_TARGET} \
- --target=${CT_TARGET} \
- --prefix=/usr \
- --with-build-sysroot="${CT_SYSROOT_DIR}" \
- --without-uiout \
- --disable-tui \
- --disable-gdbtk \
- --without-x \
- --disable-sim \
- --disable-werror \
- --without-included-gettext \
- --without-develop \
- "${native_extra_config[@]}"
+ native_extra_config+=("--program-prefix=")
+ native_extra_config+=("--enable-gdbserver")
- CT_DoLog EXTRA "Building native gdb"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ if [ "${CT_GDB_NATIVE_BUILD_IPA_LIB}" = "y" ]; then
+ native_extra_config+=("--enable-inprocess-agent")
+ else
+ native_extra_config+=("--disable-inprocess-agent")
+ fi
- CT_DoLog EXTRA "Installing native gdb"
- CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
+ export ac_cv_func_strncmp_works=yes
- # Building a native gdb also builds a gdbserver
- find "${CT_DEBUGROOT_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL
+ # TBD do we need all these?
+ native_extra_config+=(
+ --without-uiout
+ --disable-gdbtk
+ --without-x
+ --disable-sim
+ --without-included-gettext
+ --without-develop
+ --sysconfdir=/etc
+ --localstatedir=/var
+ )
+
+ do_gdb_backend \
+ buildtype=native \
+ subdir=${subdir} \
+ host="${CT_TARGET}" \
+ cflags="${CT_ALL_TARGET_CFLAGS}" \
+ ldflags="${CT_ALL_TARGET_LDFLAGS}" \
+ static="${CT_GDB_NATIVE_STATIC}" \
+ static_libstdcxx="${CT_GDB_NATIVE_STATIC_LIBSTDCXX}" \
+ prefix=/usr \
+ destdir="${CT_DEBUGROOT_DIR}" \
+ "${native_extra_config[@]}"
unset ac_cv_func_strncmp_works
- CT_EndStep # native gdb build
+ CT_Popd
+ CT_EndStep # gdb server build
fi
+}
- if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
- local -a gdbserver_extra_config
- local gdbserver_LDFLAGS
+do_gdb_backend()
+{
+ local host prefix destdir cflags ldflags static buildtype subdir
+ local -a extra_config
- CT_DoStep INFO "Installing gdbserver"
- CT_DoLog EXTRA "Configuring gdbserver"
+ for arg in "$@"; do
+ case "$arg" in
+ --*)
+ extra_config+=("${arg}")
+ ;;
+ *)
+ eval "${arg// /\\ }"
+ ;;
+ esac
+ done
+
+ # Starting with glibc 2.25, it now provides a <proc_service.h> header. The
+ # problem is that GDB releases prior to 7.12 used to implement one of the
+ # interfaces, ps_get_thread_are with a const qualifier on one of the arguments.
+ # Therefore, such older versions cannot be compiled against a newer glibc.
+ # If we detect such a combination, mitigate by creating a local proc_service.h
+ # with a prototype adjusted for GDB requirements.
+ if [ -r "${CT_HEADERS_DIR}/proc_service.h" -a "${CT_GDB_CONST_GET_THREAD_AREA}" = "y" ]; then
+ CT_DoLog DEBUG "Fixing up the prototype in <proc_service.h>"
+ CT_DoExecLog ALL mkdir -p gdb/gdbserver
+ CT_DoExecLog ALL cp "${CT_HEADERS_DIR}/proc_service.h" gdb/proc_service.h
+ CT_DoExecLog ALL sed -i \
+ "s/\(ps_get_thread_area *(\).*\(struct ps_prochandle\)/\1const \2/" \
+ gdb/proc_service.h
+ CT_DoExecLog ALL cp gdb/proc_service.h gdb/gdbserver/proc_service.h
+ fi
- mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
- cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
+ [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
+ [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
- # Workaround for bad versions, where the configure
- # script for gdbserver is not executable...
- # Bah, GNU folks strike again... :-(
- chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
+ # Disable binutils options when building from the binutils-gdb repo.
+ extra_config+=("--disable-binutils")
+ extra_config+=("--disable-ld")
+ extra_config+=("--disable-gas")
- gdbserver_LDFLAGS=
- if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
- gdbserver_LDFLAGS=-static
- fi
+ if [ "${CT_GDB_HAS_DISABLE_CXX_BUILD}" = "y" ]; then
+ extra_config+=("--disable-build-with-cxx")
+ fi
- gdbserver_extra_config=("${extra_config[@]}")
+ case "${CT_THREADS}" in
+ none) extra_config+=("--disable-threads");;
+ *) extra_config+=("--enable-threads");;
+ esac
- # We may not have C++ language configured for target
- gdbserver_extra_config+=("--disable-build-with-cxx")
+ if [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ]; then
+ extra_config+=("--disable-nls")
+ fi
- if [ "${CT_GDB_GDBSERVER_HAS_IPA_LIB}" = "y" ]; then
- if [ "${CT_GDB_GDBSERVER_BUILD_IPA_LIB}" = "y" ]; then
- gdbserver_extra_config+=( --enable-inprocess-agent )
- else
- gdbserver_extra_config+=( --disable-inprocess-agent )
- fi
- fi
+ if [ "${static}" = "y" ]; then
+ cflags+=" -static"
+ ldflags+=" -static"
+ # There is no static libsource-highlight
+ extra_config+=("--disable-source-highlight")
+ fi
+ if [ "${static_libstdcxx}" = "y" ]; then
+ ldflags+=" -static-libgcc"
+ ldflags+=" -static-libstdc++"
+ # libsource-highlight is a dynamic library that uses exception
+ # exceptions are handled by libstdc++
+ # this combination is very buggy, so configure don't use it and abort
+ extra_config+=("--disable-source-highlight")
+ fi
- # Disable binutils options when building from the binutils-gdb repo.
- gdbserver_extra_config+=("--disable-binutils")
- gdbserver_extra_config+=("--disable-ld")
- gdbserver_extra_config+=("--disable-gas")
-
- CT_DoExecLog CFG \
- CC="${CT_TARGET}-${CT_CC}" \
- CPP="${CT_TARGET}-cpp" \
- LD="${CT_TARGET}-ld" \
- LDFLAGS="${gdbserver_LDFLAGS}" \
- ${CONFIG_SHELL} \
- "${gdb_src_dir}/gdb/gdbserver/configure" \
- --build=${CT_BUILD} \
- --host=${CT_TARGET} \
- --target=${CT_TARGET} \
- --prefix=/usr \
- --sysconfdir=/etc \
- --localstatedir=/var \
- --includedir="${CT_HEADERS_DIR}" \
- --with-build-sysroot="${CT_SYSROOT_DIR}" \
- --program-prefix= \
- --without-uiout \
- --disable-tui \
- --disable-gdbtk \
- --without-x \
- --without-included-gettext \
- --without-develop \
- --disable-werror \
- "${gdbserver_extra_config[@]}"
-
- CT_DoLog EXTRA "Building gdbserver"
- CT_DoExecLog ALL make ${JOBSFLAGS} CC=${CT_TARGET}-${CT_CC}
-
- CT_DoLog EXTRA "Installing gdbserver"
- CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
- CT_EndStep
+ # Fix up whitespace. Some older GDB releases (e.g. 6.8a) get confused if there
+ # are multiple consecutive spaces: sub-configure scripts replace them with a
+ # single space and then complain that $CC value changed from that in
+ # the master directory.
+ cflags=`echo ${cflags}`
+ ldflags=`echo ${ldflags}`
+
+ CT_DoLog EXTRA "Configuring ${buildtype} gdb"
+ CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
+
+ # Run configure/make in the matching subdirectory so that any fixups
+ # prepared in a given subdirectory apply.
+ if [ -n "${subdir}" ]; then
+ CT_mkdir_pushd "${subdir}"
+ fi
+
+ # TBD: is passing CPP/CC/CXX/LD needed? GCC should be determining this automatically from the triplets
+ CT_DoExecLog CFG \
+ CPP="${host}-cpp" \
+ CC="${host}-gcc" \
+ CXX="${host}-g++" \
+ LD="${host}-ld" \
+ CFLAGS="${cflags}" \
+ CXXFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
+ ${CONFIG_SHELL} \
+ "${CT_SRC_DIR}/gdb/${subdir}configure" \
+ --build=${CT_BUILD} \
+ --host=${host} \
+ --target=${CT_TARGET} \
+ --prefix="${prefix}" \
+ --with-build-sysroot="${CT_SYSROOT_DIR}" \
+ --includedir="${CT_HEADERS_DIR}" \
+ --disable-werror \
+ "${extra_config[@]}" \
+
+ CT_DoLog EXTRA "Building ${buildtype} gdb"
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
+
+ CT_DoLog EXTRA "Installing ${buildtype} gdb"
+ CT_DoExecLog ALL make install ${destdir:+DESTDIR="${destdir}"}
+
+ if [ -n "${subdir}" ]; then
+ CT_Popd
fi
}
diff --git a/scripts/build/debug/400-ltrace.sh b/scripts/build/debug/400-ltrace.sh
index 6b860e9..9c9052a 100644
--- a/scripts/build/debug/400-ltrace.sh
+++ b/scripts/build/debug/400-ltrace.sh
@@ -1,19 +1,11 @@
# Build script for ltrace
do_debug_ltrace_get() {
- CT_GetFile "ltrace_${CT_LTRACE_VERSION}.orig" .tar.gz \
- {http,ftp}://ftp.debian.org/debian/pool/main/l/ltrace/
- # Create a link so that the following steps are easier to do:
- CT_Pushd "${CT_TARBALLS_DIR}"
- ltrace_ext=$(CT_GetFileExtension "ltrace_${CT_LTRACE_VERSION}.orig")
- ln -sf "ltrace_${CT_LTRACE_VERSION}.orig${ltrace_ext}" \
- "ltrace-${CT_LTRACE_VERSION}${ltrace_ext}"
- CT_Popd
+ CT_Fetch LTRACE
}
do_debug_ltrace_extract() {
- CT_Extract "ltrace-${CT_LTRACE_VERSION}"
- CT_Patch "ltrace" "${CT_LTRACE_VERSION}"
+ CT_ExtractPatch LTRACE
}
do_debug_ltrace_build() {
@@ -22,37 +14,17 @@ do_debug_ltrace_build() {
CT_DoStep INFO "Installing ltrace"
CT_DoLog EXTRA "Copying sources to build dir"
- CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/ltrace-${CT_LTRACE_VERSION}/." \
+ CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/ltrace/." \
"${CT_BUILD_DIR}/build-ltrace"
CT_Pushd "${CT_BUILD_DIR}/build-ltrace"
CT_DoLog EXTRA "Configuring ltrace"
- # ltrace-0.5.3 has a unique hand-crafted configure script. Releases
- # 0.5.2 and earlier as well as 0.6.0 and later use GNU autotools.
- if [ "${LTRACE_0_5_3_CONFIGURE}" = "y" ]; then
- case "${CT_ARCH}:${CT_ARCH_BITNESS}" in
- x86:32) ltrace_host="i386";;
- x86:64) ltrace_host="x86_64";;
- powerpc:*) ltrace_host="ppc";;
- mips:*) ltrace_host="mipsel";;
- *) ltrace_host="${CT_ARCH}";;
- esac
- CT_DoExecLog CFG \
- CC="${CT_TARGET}-${CT_CC}" \
- AR="${CT_TARGET}-ar" \
- HOST="${ltrace_host}" \
- HOST_OS="${CT_TARGET_KERNEL}" \
- CFLAGS="${CT_TARGET_CFLAGS}" \
- ${CONFIG_SHELL} \
- ./configure --prefix=/usr
- else
- CT_DoExecLog CFG \
- ${CONFIG_SHELL} \
- ./configure \
- --build=${CT_BUILD} \
- --host=${CT_TARGET} \
- --prefix=/usr
- fi
+ CT_DoExecLog CFG \
+ ${CONFIG_SHELL} \
+ ./configure \
+ --build=${CT_BUILD} \
+ --host=${CT_TARGET} \
+ --prefix=/usr
CT_DoLog EXTRA "Building ltrace"
CT_DoExecLog ALL make
@@ -63,4 +35,3 @@ do_debug_ltrace_build() {
CT_Popd
CT_EndStep
}
-
diff --git a/scripts/build/debug/500-strace.sh b/scripts/build/debug/500-strace.sh
index 6eb2357..c28af35 100644
--- a/scripts/build/debug/500-strace.sh
+++ b/scripts/build/debug/500-strace.sh
@@ -1,32 +1,44 @@
# Build script for strace
-do_debug_strace_get() {
- local base_url="http://downloads.sourceforge.net/project/strace/strace"
- CT_GetFile "strace-${CT_STRACE_VERSION}" "${base_url}/${CT_STRACE_VERSION}"
- # Downloading from sourceforge leaves garbage, cleanup
- CT_DoExecLog ALL rm -f "${CT_TARBALLS_DIR}/showfiles.php"*
+do_debug_strace_get()
+{
+ CT_Fetch STRACE
}
-do_debug_strace_extract() {
- CT_Extract "strace-${CT_STRACE_VERSION}"
- CT_Patch "strace" "${CT_STRACE_VERSION}"
+do_debug_strace_extract()
+{
+ CT_ExtractPatch STRACE
}
-do_debug_strace_build() {
+do_debug_strace_build()
+{
+ local cflags="${CT_ALL_TARGET_CFLAGS}"
+
CT_DoStep INFO "Installing strace"
+ if [ "${CT_LIBC_MUSL}" = "y" ]; then
+ # Otherwise kernel headers cause errors when included, e.g.
+ # <netinet/in.h> and <linux/in6.h>. Kernel's libc-compat.h
+ # only cares about GLIBC. uClibc-ng does the same
+ # internally, pretending it's GLIBC for kernel headers inclusion.
+ cflags+=" -D__GLIBC__ -D__USE_MISC"
+ fi
+
CT_mkdir_pushd "${CT_BUILD_DIR}/build-strace"
CT_DoLog EXTRA "Configuring strace"
CT_DoExecLog CFG \
CC="${CT_TARGET}-${CT_CC}" \
+ CFLAGS="${cflags}" \
+ LDFLAGS="${CT_ALL_TARGET_LDFLAGS}" \
CPP="${CT_TARGET}-cpp" \
LD="${CT_TARGET}-ld" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/strace-${CT_STRACE_VERSION}/configure" \
+ "${CT_SRC_DIR}/strace/configure" \
--build=${CT_BUILD} \
--host=${CT_TARGET} \
- --prefix=/usr
+ --prefix=/usr \
+ --enable-mpers=check
CT_DoLog EXTRA "Building strace"
CT_DoExecLog ALL make
diff --git a/scripts/build/internals.sh b/scripts/build/internals.sh
index 18ada66..821761c 100644
--- a/scripts/build/internals.sh
+++ b/scripts/build/internals.sh
@@ -1,5 +1,27 @@
# This file contains crosstool-NG internal steps
+create_ldso_conf()
+{
+ local multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_flags multi_index multi_count multi_target
+ local b d
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoExecLog ALL mkdir -p "${multi_root}/etc"
+ for b in /lib /usr/lib "${CT_LDSO_CONF_EXTRA_DIRS_ARRAY[@]}"; do
+ d="${b}/${multi_os_dir}"
+ CT_SanitizeVarDir d
+ echo "${d}" >> "${multi_root}/etc/ld.so.conf"
+ if [ "${multi_os_dir}" != "${multi_os_dir_gcc}" ]; then
+ d="${b}/${multi_os_dir_gcc}"
+ CT_SanitizeVarDir d
+ echo "${d}" >> "${multi_root}/etc/ld.so.conf"
+ fi
+ done
+}
+
# This step is called once all components were built, to remove
# un-wanted files, to add tuple aliases, and to add the final
# crosstool-NG-provided files.
@@ -10,13 +32,23 @@ do_finish() {
local gcc_version
local exe_suffix
- CT_DoStep INFO "Cleaning-up the toolchain's directory"
+ CT_DoStep INFO "Finalizing the toolchain's directory"
+
+ if [ "${CT_CREATE_LDSO_CONF}" = "y" ]; then
+ # Create /etc/ld.so.conf
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-create-ldso"
+ CT_IterateMultilibs create_ldso_conf create-ldso
+ CT_Popd
+ fi
if [ "${CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES}" = "y" ]; then
case "$CT_HOST" in
*darwin*)
strip_args=""
;;
+ *freebsd*)
+ strip_args="--strip-all"
+ ;;
*)
strip_args="--strip-all -v"
;;
@@ -37,20 +69,11 @@ do_finish() {
CT_DoExecLog ALL "${CT_TARGET}-strip" ${strip_args} \
"${CT_TARGET}/debug-root/usr/bin/gdbserver${exe_suffix}"
fi
- if [ "${CT_CC_gcc}" = "y" ]; then
- # We can not use the version in CT_CC_GCC_VERSION because
+ if [ "${CT_CC_GCC}" = "y" ]; then
+ # We can not use the version in CT_GCC_VERSION because
# of the Linaro stuff. So, harvest the version string
# directly from the gcc sources...
- # All gcc 4.x seem to have the version in gcc/BASE-VER
- # while version prior to 4.x have the version in gcc/version.c
- # Of course, here is not the better place to do that...
- if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then
- gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" )
- else
- gcc_version=$(sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \
- "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/version.c" \
- )
- fi
+ gcc_version=$( cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER" )
for _t in "bin/${CT_TARGET}-"* \
"${CT_TARGET}/bin/"* \
"libexec/gcc/${CT_TARGET}/${gcc_version}/"* \
@@ -60,7 +83,7 @@ do_finish() {
case "${_type}" in
*script*executable*)
;;
- *executable*)
+ *executable*|*shared*object*)
CT_DoExecLog ALL ${CT_HOST}-strip ${strip_args} "${_t}"
;;
esac
@@ -100,25 +123,8 @@ do_finish() {
# Create the aliases to the target tools
CT_DoLog EXTRA "Creating toolchain aliases"
- CT_Pushd "${CT_PREFIX_DIR}/bin"
- for t in "${CT_TARGET}-"*; do
- if [ -n "${CT_TARGET_ALIAS}" ]; then
- _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
- CT_DoExecLog ALL ln -sfv "${t}" "${_t}"
- fi
- if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
- _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
- if [ "${_t}" = "${t}" ]; then
- CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
- else
- CT_DoExecLog ALL ln -sfv "${t}" "${_t}"
- fi
- fi
- done
- CT_Popd
-
- CT_DoLog EXTRA "Removing access to the build system tools"
- CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
+ CT_SymlinkTools "${CT_PREFIX_DIR}/bin" "${CT_PREFIX_DIR}/bin" \
+ "${CT_TARGET_ALIAS}" "${CT_TARGET_ALIAS_SED_EXPR}"
# Remove the generated documentation files
if [ "${CT_REMOVE_DOCS}" = "y" ]; then
@@ -128,5 +134,9 @@ do_finish() {
CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{,share/}{man,info}
fi
+ if [ "${CT_INSTALL_LICENSES}" = y ]; then
+ CT_InstallCopyingInformation
+ fi
+
CT_EndStep
}
diff --git a/scripts/build/kernel/bare-metal.sh b/scripts/build/kernel/bare-metal.sh
index 629f63f..79c4345 100644
--- a/scripts/build/kernel/bare-metal.sh
+++ b/scripts/build/kernel/bare-metal.sh
@@ -2,19 +2,23 @@
# Copyright 2008 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package
-CT_DoKernelTupleValues() {
+CT_DoKernelTupleValues()
+{
# For bare-metal, there is no kernel part in the tuple
CT_TARGET_KERNEL=
}
-do_kernel_get() {
+do_kernel_get()
+{
:
}
-do_kernel_extract() {
+do_kernel_extract()
+{
:
}
-do_kernel_headers() {
+do_kernel_headers()
+{
:
}
diff --git a/scripts/build/kernel/linux.sh b/scripts/build/kernel/linux.sh
index 9cfc433..ad3c2ca 100644
--- a/scripts/build/kernel/linux.sh
+++ b/scripts/build/kernel/linux.sh
@@ -2,90 +2,48 @@
# Copyright 2007 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package
-CT_DoKernelTupleValues() {
- if [ "${CT_ARCH_USE_MMU}" = "y" ]; then
- CT_TARGET_KERNEL="linux"
- else
+CT_DoKernelTupleValues()
+{
+ if [ -z "${CT_ARCH_USE_MMU}" ]; then
# Some no-mmu linux targets requires a -uclinux tuple (like m68k/cf),
# while others must have a -linux tuple. Other targets
# should be added here when someone starts to care about them.
case "${CT_ARCH}" in
- arm*) CT_TARGET_KERNEL="linux" ;;
- m68k) CT_TARGET_KERNEL="uclinux" ;;
- *) CT_Abort "Unsupported no-mmu arch '${CT_ARCH}'"
+ arm*|microblaze*) CT_TARGET_KERNEL="linux" ;;
+ c6x|m68k|xtensa*) CT_TARGET_KERNEL="uclinux" ;;
+ *) CT_Abort "Unsupported no-mmu arch '${CT_ARCH}'"
esac
fi
}
# Download the kernel
-do_kernel_get() {
- local k_ver
- local custom_name
- local rel_dir
- local korg_base mirror_base
+do_kernel_get()
+{
+ CT_Fetch LINUX
+}
- if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
- CT_GetCustom "linux" "${CT_KERNEL_LINUX_CUSTOM_VERSION}" \
- "${CT_KERNEL_LINUX_CUSTOM_LOCATION}"
- else # Not a custom tarball
- case "${CT_KERNEL_VERSION}" in
- 2.6.*.*|3.*.*|4.*.*)
- # 4-part versions (for 2.6 stables and long-terms), and
- # 3-part versions (for 3.x.y and 4.x.y stables and long-terms)
- # we need to trash the last digit
- k_ver="${CT_KERNEL_VERSION%.*}"
- ;;
- 2.6.*|3.*|4.*)
- # 3-part version (for 2.6.x initial releases), and 2-part
- # versions (for 3.x and 4.x initial releases), use all of it
- k_ver="${CT_KERNEL_VERSION}"
- ;;
- esac
- case "${CT_KERNEL_VERSION}" in
- 2.6.*) rel_dir=v2.6;;
- 3.*) rel_dir=v3.x;;
- 4.*) rel_dir=v4.x;;
- esac
- korg_base="http://www.kernel.org/pub/linux/kernel/${rel_dir}"
- CT_GetFile "linux-${CT_KERNEL_VERSION}" \
- "${korg_base}" \
- "${korg_base}/longterm/v${k_ver}" \
- "${korg_base}/longterm"
- fi
+# Disable building relocs application - it needs <linux/types.h>
+# on the host, which may not be present on Cygwin or MacOS; it
+# needs <elf.h>, which again is not present on MacOS; and most
+# important, we don't need it to install the headers.
+# This is not done as a patch, since it varies from Linux version
+# to version - patching each particular Linux version would be
+# too cumbersome.
+linux_disable_build_relocs()
+{
+ sed -i -r 's/(\$\(MAKE\) .* relocs)$/:/' arch/*/Makefile
}
# Extract kernel
-do_kernel_extract() {
- # If using a custom directory location, nothing to do
- if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" \
- -a -d "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}" ]; then
- return 0
- fi
-
- # Otherwise, we're using either a mainstream tarball, or a custom
- # tarball; in either case, we need to extract
- CT_Extract "linux-${CT_KERNEL_VERSION}"
-
- # If using a custom tarball, no need to patch
- if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
- return 0
- fi
- CT_Patch "linux" "${CT_KERNEL_VERSION}"
-
- # Disable building relocs application - it needs <linux/types.h>
- # on the host, which may not be present on Cygwin or MacOS; it
- # needs <elf.h>, which again is not present on MacOS; and most
- # important, we don't need it to install the headers.
- # This is not done as a patch, since it varies from Linux version
- # to version - patching each particular Linux version would be
- # too cumbersome.
- CT_Pushd "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"
- sed -i -r 's/(\$\(MAKE\) .* relocs)$/:/' arch/*/Makefile
- CT_Popd
+do_kernel_extract()
+{
+ # TBD verify linux_disable_build_relocs is run
+ CT_ExtractPatch LINUX linux_disable_build_relocs
}
# Install kernel headers using headers_install from kernel sources.
-do_kernel_headers() {
+do_kernel_headers()
+{
local kernel_path
local kernel_arch
@@ -93,7 +51,7 @@ do_kernel_headers() {
mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
- kernel_path="${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}"
+ kernel_path="${CT_SRC_DIR}/linux"
V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}"
kernel_arch="${CT_ARCH}"
@@ -103,24 +61,28 @@ do_kernel_headers() {
esac
CT_DoLog EXTRA "Installing kernel headers"
- CT_DoExecLog ALL \
- make -C "${kernel_path}" \
- CROSS_COMPILE="${CT_TARGET}-" \
- O="${CT_BUILD_DIR}/build-kernel-headers" \
- ARCH=${kernel_arch} \
- INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
- ${V_OPT} \
+ CT_DoExecLog ALL \
+ make -C "${kernel_path}" \
+ BASH="$(which bash)" \
+ HOSTCC="${CT_BUILD}-gcc" \
+ CROSS_COMPILE="${CT_TARGET}-" \
+ O="${CT_BUILD_DIR}/build-kernel-headers" \
+ ARCH=${kernel_arch} \
+ INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
+ ${V_OPT} \
headers_install
if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then
CT_DoLog EXTRA "Checking installed headers"
- CT_DoExecLog ALL \
- make -C "${kernel_path}" \
- CROSS_COMPILE="${CT_TARGET}-" \
- O="${CT_BUILD_DIR}/build-kernel-headers" \
- ARCH=${kernel_arch} \
- INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
- ${V_OPT} \
+ CT_DoExecLog ALL \
+ make -C "${kernel_path}" \
+ BASH="$(which bash)" \
+ HOSTCC="${CT_BUILD}-gcc" \
+ CROSS_COMPILE="${CT_TARGET}-" \
+ O="${CT_BUILD_DIR}/build-kernel-headers" \
+ ARCH=${kernel_arch} \
+ INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
+ ${V_OPT} \
headers_check
fi
diff --git a/scripts/build/kernel/windows.sh b/scripts/build/kernel/windows.sh
index 5e34420..37bc1d7 100644
--- a/scripts/build/kernel/windows.sh
+++ b/scripts/build/kernel/windows.sh
@@ -2,21 +2,24 @@
# Copyright 2012 Yann Diorcet
# Licensed under the GPL v2. See COPYING in the root of this package
-CT_DoKernelTupleValues() {
+CT_DoKernelTupleValues()
+{
# Even we compile for x86_64 target architecture, the target OS have to
# bet mingw32 (require by gcc and mingw-w64)
CT_TARGET_KERNEL="mingw32"
- CT_TARGET_SYS=
}
-do_kernel_get() {
+do_kernel_get()
+{
:
}
-do_kernel_extract() {
+do_kernel_extract()
+{
:
}
-do_kernel_headers() {
+do_kernel_headers()
+{
:
}
diff --git a/scripts/build/libc.sh b/scripts/build/libc.sh
new file mode 100644
index 0000000..5f5aa6f
--- /dev/null
+++ b/scripts/build/libc.sh
@@ -0,0 +1,39 @@
+# C library build routines. We don't invoke the corresponding functions directly
+# because some of them build on top of another. E.g. moxiebox runtime requires
+# newlib as a prerequisite.
+
+# Define default hooks - download/unpack just the main package; no-op build hooks.
+# The actual implementation can override just what it needs then.
+eval "${CT_LIBC//[^A-Za-z0-9]/_}_get() { CT_Fetch \"\${CT_LIBC_${CT_LIBC_CHOICE_KSYM}_PKG_KSYM}\"; }"
+eval "${CT_LIBC//[^A-Za-z0-9]/_}_extract() { CT_ExtractPatch \"\${CT_LIBC_${CT_LIBC_CHOICE_KSYM}_PKG_KSYM}\"; }"
+for _m in headers main post_cc; do
+ eval "${CT_LIBC//[^A-Za-z0-9]/_}_${_m}() { :; }"
+done
+
+# Source the selected libc.
+. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
+
+do_libc_get()
+{
+ eval "${CT_LIBC//[^A-Za-z0-9]/_}_get"
+}
+
+do_libc_extract()
+{
+ eval "${CT_LIBC//[^A-Za-z0-9]/_}_extract"
+}
+
+do_libc_headers()
+{
+ eval "${CT_LIBC//[^A-Za-z0-9]/_}_headers"
+}
+
+do_libc_main()
+{
+ eval "${CT_LIBC//[^A-Za-z0-9]/_}_main"
+}
+
+do_libc_post_cc()
+{
+ eval "${CT_LIBC//[^A-Za-z0-9]/_}_post_cc"
+}
diff --git a/scripts/build/libc/avr-libc.sh b/scripts/build/libc/avr-libc.sh
index f94b601..34eb0f5 100644
--- a/scripts/build/libc/avr-libc.sh
+++ b/scripts/build/libc/avr-libc.sh
@@ -1,24 +1,14 @@
# This file adds functions to build the avr-libc C library
-do_libc_get() {
- local libc_src
-
- libc_src="http://download.savannah.gnu.org/releases/avr-libc"
-
- if [ "${CT_LIBC_AVR_LIBC_CUSTOM}" = "y" ]; then
- CT_GetCustom "avr-libc" "${CT_LIBC_AVR_LIBC_CUSTOM_VERSION}" \
- "${CT_LIBC_AVR_LIBC_CUSTOM_LOCATION}"
- else # ! custom location
- CT_GetFile "avr-libc-${CT_LIBC_VERSION}" "${libc_src}"
- fi # ! custom location
-}
+avr_libc_post_cc()
+{
+ CT_DoStep INFO "Installing C library"
-do_libc_extract() {
- CT_Extract "avr-libc-${CT_LIBC_VERSION}"
- CT_Patch "avr-libc" "${CT_LIBC_VERSION}"
-}
+ CT_DoLog EXTRA "Copying sources to build directory"
+ CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/avr-libc/." \
+ "${CT_BUILD_DIR}/build-libc-post-cc"
+ cd "${CT_BUILD_DIR}/build-libc-post-cc"
-do_libc_configure() {
CT_DoLog EXTRA "Configuring C library"
CT_DoExecLog CFG \
@@ -28,28 +18,9 @@ do_libc_configure() {
--host=${CT_TARGET} \
--prefix=${CT_PREFIX_DIR} \
"${CT_LIBC_AVR_LIBC_EXTRA_CONFIG_ARRAY[@]}"
-}
-
-do_libc_start_files() {
- :
-}
-
-do_libc() {
- :
-}
-
-do_libc_post_cc() {
- CT_DoStep INFO "Installing C library"
-
- CT_DoLog EXTRA "Copying sources to build directory"
- CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/avr-libc-${CT_LIBC_VERSION}/." \
- "${CT_BUILD_DIR}/build-libc-post-cc"
- cd "${CT_BUILD_DIR}/build-libc-post-cc"
-
- do_libc_configure
CT_DoLog EXTRA "Building C library"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
CT_DoLog EXTRA "Installing C library"
CT_DoExecLog ALL make install
diff --git a/scripts/build/libc/bionic.sh b/scripts/build/libc/bionic.sh
new file mode 100644
index 0000000..0ffd4d8
--- /dev/null
+++ b/scripts/build/libc/bionic.sh
@@ -0,0 +1,34 @@
+# This file adds functions to extract the bionic C library from the Android NDK
+# Copyright 2017 Howard Chu
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+# Install Unified headers
+bionic_headers()
+{
+ CT_DoStep INFO "Installing C library headers"
+ CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk/sysroot/usr" "${CT_SYSROOT_DIR}"
+}
+
+bionic_main()
+{
+ local arch="${CT_ARCH}"
+ if [ "${CT_ARCH_64}" = "y" ]; then
+ if [ "${CT_ARCH}" = "x86" ]; then
+ arch="${arch}_"
+ fi
+ arch="${arch}64"
+ fi
+ CT_DoStep INFO "Installing C library binaries"
+ CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk/platforms/android-${CT_ANDROID_API}/arch-${arch}/usr" "${CT_SYSROOT_DIR}"
+
+ # NB: Modifying both CT_TARGET_CFLAGS and CT_ALL_TARGET_CFLAGS: the __ANDROID_API__
+ # definition needs to be passed into GCC build, or the resulting libstdc++ gets
+ # miscompiled (attempt to link against it results in unresolved symbols to stdout/...).
+ # And since __ANDROID_API__ is a user config option, placing it with other user-supplied
+ # options isn't completely out of character.
+ # On the other hand, CT_ALL_TARGET_CFLAGS in non-multilib builds is already set and does
+ # not get recalculated after GCC build, so setting CT_TARGET_CFLAGS is not reflected
+ # on other libraries/apps, such as gdbserver.
+ CT_EnvModify CT_TARGET_CFLAGS "${CT_TARGET_CFLAGS} -D__ANDROID_API__=${CT_ANDROID_API}"
+ CT_EnvModify CT_ALL_TARGET_CFLAGS "${CT_ALL_TARGET_CFLAGS} -D__ANDROID_API__=${CT_ANDROID_API}"
+}
diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh
index 348c35a..c78f069 100644
--- a/scripts/build/libc/glibc.sh
+++ b/scripts/build/libc/glibc.sh
@@ -2,166 +2,58 @@
# Copyright 2007 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package
-do_libc_get() {
+glibc_get()
+{
local date
local version
- local -a addons_list
-
- addons_list=($(do_libc_add_ons_list " "))
-
- # Main source
- if [ "${CT_LIBC_GLIBC_CUSTOM}" = "y" ]; then
- CT_GetCustom "glibc" "${CT_LIBC_GLIBC_CUSTOM_VERSION}" \
- "${CT_LIBC_GLIBC_CUSTOM_LOCATION}"
- else
- case "${CT_LIBC_VERSION}" in
- linaro-*)
- CT_GetLinaro "glibc" "${CT_LIBC_VERSION}"
- ;;
- *)
- CT_GetFile "glibc-${CT_LIBC_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/glibc \
- ftp://{sourceware.org,gcc.gnu.org}/pub/glibc/{releases,snapshots}
- ;;
- esac
- fi
-
- # C library addons
- for addon in "${addons_list[@]}"; do
- # Never ever try to download these add-ons,
- # they've always been internal
- case "${addon}" in
- nptl) continue;;
- esac
-
- case "${addon}:${CT_LIBC_GLIBC_PORTS_EXTERNAL}" in
- ports:y) ;;
- ports:*) continue;;
- esac
-
- if ! CT_GetFile "glibc-${addon}-${CT_LIBC_VERSION}" \
- http://mirrors.kernel.org/sourceware/glibc \
- {http,ftp,https}://ftp.gnu.org/gnu/glibc \
- ftp://{sourceware.org,gcc.gnu.org}/pub/glibc/{releases,snapshots}
- then
- # Some add-ons are bundled with glibc, others are
- # bundled in their own tarball. Eg. NPTL is internal,
- # while LinuxThreads was external. Also, for old
- # versions of glibc, the libidn add-on was external,
- # but with version >=2.10, it is internal.
- CT_DoLog DEBUG "Addon '${addon}' could not be downloaded."
- CT_DoLog DEBUG "We'll see later if we can find it in the source tree"
- fi
- done
+ CT_Fetch GLIBC
+ if [ "${CT_GLIBC_USE_PORTS_EXTERNAL}" = "y" ]; then
+ CT_Fetch GLIBC_PORTS
+ fi
return 0
}
-do_libc_extract() {
- local addon
-
- CT_Extract "${CT_LIBC}-${CT_LIBC_VERSION}"
- CT_Pushd "${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}"
- # Custom glibc won't get patched, because CT_GetCustom
- # marks custom glibc as patched.
- CT_Patch nochdir "${CT_LIBC}" "${CT_LIBC_VERSION}"
-
- for addon in $(do_libc_add_ons_list " "); do
- # If the addon was bundled with the main archive, we do not
- # need to extract it. Worse, if we were to try to extract
- # it, we'd get an error.
- if [ -d "${addon}" ]; then
- CT_DoLog DEBUG "Add-on '${addon}' already present, skipping extraction"
- continue
- fi
-
- CT_Extract nochdir "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
-
- CT_TestAndAbort "Error in add-on '${addon}': both short and long names in tarball" \
- -d "${addon}" -a -d "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
-
- # Some addons have the 'long' name, while others have the
- # 'short' name, but patches are non-uniformly built with
- # either the 'long' or 'short' name, whatever the addons name
- # but we prefer the 'short' name and avoid duplicates.
- if [ -d "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" ]; then
- CT_DoExecLog FILE mv "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" "${addon}"
- fi
-
- CT_DoExecLog FILE ln -s "${addon}" "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
-
- CT_Patch nochdir "${CT_LIBC}" "${addon}-${CT_LIBC_VERSION}"
-
- # Remove the long name since it can confuse configure scripts to run
- # the same source twice.
- rm "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
- done
-
- # The configure files may be older than the configure.in files
- # if using a snapshot (or even some tarballs). Fake them being
- # up to date.
- find . -type f -name configure -exec touch {} \; 2>&1 |CT_DoLog ALL
-
- CT_Popd
-}
-
-# Build and install headers and start files
-do_libc_start_files() {
- # Start files and Headers should be configured the same way as the
- # final libc, but built and installed differently.
- do_libc_backend libc_mode=startfiles
+glibc_extract()
+{
+ CT_ExtractPatch GLIBC
+ if [ "${CT_GLIBC_USE_PORTS_EXTERNAL}" = "y" ]; then
+ CT_ExtractPatch GLIBC_PORTS
+
+ # This may create a bogus symlink if glibc-ports is using custom
+ # sources or has an overlay (and glibc is shared). However,
+ # we do not support concurrent use of the source directory
+ # and next run, if using different glibc-ports source, will override
+ # this symlink anyway.
+ CT_DoExecLog ALL ln -sf "${CT_SRC_DIR}/${CT_GLIBC_PORTS_DIR_NAME}" \
+ "${CT_SRC_DIR}/${CT_GLIBC_DIR_NAME}/ports"
+ fi
}
# This function builds and install the full C library
-do_libc() {
- do_libc_backend libc_mode=final
-}
-
-do_libc_post_cc() {
- :
-}
-
-# This backend builds the C library once for each multilib
-# variant the compiler gives us
-# Usage: do_libc_backend param=value [...]
-# Parameter : Definition : Type : Default
-# libc_mode : 'startfiles' or 'final' : string : (none)
-do_libc_backend() {
- local libc_mode
+glibc_main()
+{
local arg
- for arg in "$@"; do
- eval "${arg// /\\ }"
- done
-
- case "${libc_mode}" in
- startfiles)
- CT_DoStep INFO "Installing C library headers & start files"
- ;;
- final)
- CT_DoStep INFO "Installing C library"
- ;;
- *)
- CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'"
- ;;
- esac
-
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}"
- CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}"
+ CT_DoStep INFO "Installing C library"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc"
+ CT_IterateMultilibs glibc_backend_once multilib
CT_Popd
CT_EndStep
}
# This backend builds the C library once
-# Usage: do_libc_backend_once param=value [...]
+# Usage: glibc_backend_once param=value [...]
# Parameter : Definition : Type
-# libc_mode : 'startfiles' or 'final' : string : (empty)
# multi_* : as defined in CT_IterateMultilibs : (varies) :
-do_libc_backend_once() {
- local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count
+glibc_backend_once()
+{
+ # Glibc seems to be smart enough to know about the cases that can coexist
+ # in the same root and installs them into proper multilib-os directory; all
+ # we need is to point to the right root.
+ local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count multi_target
local build_cflags build_cppflags build_ldflags
- local startfiles_dir
- local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}"
+ local src_dir="${CT_SRC_DIR}/glibc"
local -a extra_config
local -a extra_make_args
local glibc_cflags
@@ -179,93 +71,95 @@ do_libc_backend_once() {
# Adjust target tuple according GLIBC quirks
CT_DoArchGlibcAdjustTuple multi_target
- # Glibc seems to be smart enough to know about the cases that can coexist
- # in the same root and installs them into proper multilib-os directory; all
- # we need is to point to the right root. We do need to handle multilib-os
- # here, though, for the first pass where we install crt*.o and a dummy
- # libc.so; we therefore install it to the most specific location of
- # <sysroot>/<suffix>/usr/lib/<multilib-os> where it is least likely to clash
- # with other multilib variants. We then remove these temporary files at
- # the beginning of the libc-final step and allow glibc to install them
- # where it thinks is proper.
- startfiles_dir="${multi_root}/usr/lib/${multi_os_dir}"
- CT_SanitizeVarDir startfiles_dir
-
- if [ "${libc_mode}" = "final" ]; then
- CT_DoLog EXTRA "Cleaning up start files"
- CT_DoExecLog ALL rm -f "${startfiles_dir}/crt1.o" \
- "${startfiles_dir}/crti.o" \
- "${startfiles_dir}/crtn.o" \
- "${startfiles_dir}/libc.so"
- fi
-
CT_DoLog EXTRA "Configuring C library"
- # Also, if those two are missing, iconv build breaks
+ # If those two are missing, iconv build breaks
extra_config+=( --disable-debug --disable-sanity-checks )
- # always include rpc, the user can still override it with TI-RPC
- extra_config+=( --enable-obsolete-rpc )
+ if [ "${CT_GLIBC_ENABLE_OBSOLETE_RPC}" = "y" ]; then
+ extra_config+=( --enable-obsolete-rpc )
+ fi
# Add some default glibc config options if not given by user.
# We don't need to be conditional on whether the user did set different
- # values, as they CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY is passed after
+ # values, as they CT_GLIBC_EXTRA_CONFIG_ARRAY is passed after
# extra_config
- extra_config+=("$(do_libc_min_kernel_config)")
+ extra_config+=("$(glibc_min_kernel_config)")
case "${CT_THREADS}" in
nptl) extra_config+=("--with-__thread" "--with-tls");;
linuxthreads) extra_config+=("--with-__thread" "--without-tls" "--without-nptl");;
none) extra_config+=("--without-__thread" "--without-nptl")
- case "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in
+ case "${CT_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in
*-tls*) ;;
*) extra_config+=("--without-tls");;
esac
;;
esac
+ # FIXME static version of glibc seems to be broken:
+ # build tries to use libc-modules.h which is generated from
+ # soversions.i, which is only created for builds with shared libs.
case "${CT_SHARED_LIBS}" in
y) extra_config+=("--enable-shared");;
*) extra_config+=("--disable-shared");;
esac
- if [ "${CT_LIBC_DISABLE_VERSIONING}" = "y" ]; then
+ if [ "${CT_GLIBC_DISABLE_VERSIONING}" = "y" ]; then
extra_config+=("--disable-versioning")
fi
- if [ "${CT_LIBC_OLDEST_ABI}" != "" ]; then
- extra_config+=("--enable-oldest-abi=${CT_LIBC_OLDEST_ABI}")
+ if [ "${CT_GLIBC_OLDEST_ABI}" != "" ]; then
+ extra_config+=("--enable-oldest-abi=${CT_GLIBC_OLDEST_ABI}")
fi
- case "$(do_libc_add_ons_list ,)" in
+ case "$(glibc_add_ons_list ,)" in
"") extra_config+=("--enable-add-ons=no");;
- *) extra_config+=("--enable-add-ons=$(do_libc_add_ons_list ,)");;
+ *) extra_config+=("--enable-add-ons=$(glibc_add_ons_list ,)");;
esac
- extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
+ [ "${CT_GLIBC_ENABLE_WERROR}" != "y" ] && extra_config+=("--disable-werror")
+ [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
+ if [ -n "${CT_GLIBC_SSP}" ]; then
+ extra_config+=("--enable-stack-protector=${CT_GLIBC_SSP}")
+ fi
+
touch config.cache
- if [ "${CT_LIBC_GLIBC_FORCE_UNWIND}" = "y" ]; then
+
+ # Until it became explicitly controllable with --enable-stack-protector=...,
+ # configure detected GCC support for -fstack-protector{,-strong} and
+ # tried to enable it in some parts of glibc - which then failed to build.
+ if [ -z "${CT_GLIBC_BUILD_SSP}" ]; then
+ echo "libc_cv_ssp=no" >>config.cache
+ echo "libc_cv_ssp_strong=no" >>config.cache
+ fi
+
+ if [ "${CT_GLIBC_FORCE_UNWIND}" = "y" ]; then
echo "libc_cv_forced_unwind=yes" >>config.cache
echo "libc_cv_c_cleanup=yes" >>config.cache
fi
# Pre-seed the configparms file with values from the config option
- printf "%s\n" "${CT_LIBC_GLIBC_CONFIGPARMS}" > configparms
+ printf "%s\n" "${CT_GLIBC_CONFIGPARMS}" > configparms
# glibc can't be built without -O2 (reference needed!)
- glibc_cflags+=" -O2"
+ glibc_cflags+=" -g -O2"
+
+ if [ "${CT_GLIBC_ENABLE_COMMON_FLAG}" = "y" ]; then
+ glibc_cflags+=" -fcommon"
+ fi
- case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in
+ case "${CT_GLIBC_ENABLE_FORTIFIED_BUILD}" in
y) ;;
*) glibc_cflags+=" -U_FORTIFY_SOURCE";;
esac
# In the order of increasing precedence. Flags common to compiler and linker.
- glibc_cflags+=" ${CT_TARGET_CFLAGS}"
- glibc_cflags+=" ${CT_LIBC_GLIBC_EXTRA_CFLAGS}"
+ glibc_cflags+=" ${CT_ALL_TARGET_CFLAGS}"
+ glibc_cflags+=" ${CT_GLIBC_EXTRA_CFLAGS}"
glibc_cflags+=" ${multi_flags}"
# Analyze the resulting options for any extra configure switches to throw in.
@@ -279,6 +173,7 @@ do_libc_backend_once() {
;;
esac
done
+ CT_DoArchGlibcAdjustConfigure extra_config "${glibc_cflags}"
# ./configure is mislead by our tools override wrapper for bash
# so just tell it where the real bash is _on_the_target_!
@@ -293,6 +188,8 @@ do_libc_backend_once() {
# or even after they get installed...
echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache
+ CT_SymlinkToolsMultilib
+
# Configure with --prefix the way we want it on the target...
# There are a whole lot of settings here. You'll probably want
# to read up on what they all mean, and customize a bit, possibly
@@ -306,17 +203,19 @@ do_libc_backend_once() {
# Run explicitly through CONFIG_SHELL, or the build breaks badly (loop-of-death)
# when the shell is not bash... Sigh... :-(
- CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'"
+ CT_DoLog DEBUG "Configuring with addons : '$(glibc_add_ons_list ,)'"
CT_DoLog DEBUG "Extra config args passed : '${extra_config[*]}'"
CT_DoLog DEBUG "Extra CFLAGS passed : '${glibc_cflags}'"
- CT_DoLog DEBUG "Placing startfiles into : '${startfiles_dir}'"
CT_DoLog DEBUG "Configuring with --host : '${multi_target}'"
# CFLAGS are only applied when compiling .c files. .S files are compiled with ASFLAGS,
# but they are not passed by configure. Thus, pass everything in CC instead.
+ # The CFLAGS variable needs to be cleared, else the default "-g -O2"
+ # would override previous flags.
CT_DoExecLog CFG \
BUILD_CC=${CT_BUILD}-gcc \
CC="${CT_TARGET}-${CT_CC} ${glibc_cflags}" \
+ CFLAGS="" \
AR=${CT_TARGET}-ar \
RANLIB=${CT_TARGET}-ranlib \
"${CONFIG_SHELL}" \
@@ -330,9 +229,13 @@ do_libc_backend_once() {
--without-gd \
--with-headers="${CT_HEADERS_DIR}" \
"${extra_config[@]}" \
- "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[@]}"
+ "${CT_GLIBC_EXTRA_CONFIG_ARRAY[@]}"
# build hacks
+
+ # Mask C++ compiler. Glibc 2.29+ attempts to build some tests using gcc++, but
+ # we haven't built libstdc++ yet. Should really implement #808 after 1.24.0...
+ extra_make_args+=( CXX= )
case "${CT_ARCH},${CT_ARCH_CPU}" in
powerpc,8??)
# http://sourceware.org/ml/crossgcc/2008-10/msg00068.html
@@ -346,153 +249,86 @@ do_libc_backend_once() {
build_ldflags="${CT_LDFLAGS_FOR_BUILD}"
case "$CT_BUILD" in
- *mingw*|*cygwin*|*msys*|*darwin*)
+ *mingw*|*cygwin*|*msys*|*darwin*|*freebsd*)
# When installing headers on Cygwin, Darwin, MSYS2 and MinGW-w64 sunrpc needs
# gettext for building cross-rpcgen.
build_cppflags="${build_cppflags} -I${CT_BUILDTOOLS_PREFIX_DIR}/include/"
build_ldflags="${build_ldflags} -lintl -liconv"
+ case "$CT_BUILD" in
+ *cygwin*|*freebsd*)
+ # Additionally, stat in FreeBSD, Cygwin, and possibly others
+ # is always 64bit, so replace struct stat64 with stat.
+ build_cppflags="${build_cppflags} -Dstat64=stat"
+ ;;
+ esac
;;
esac
+
+ # Make sure glibc build system respects our provided CFLAGS.
+ extra_make_args+=( default_cflags= )
extra_make_args+=( "BUILD_CFLAGS=${build_cflags}" )
extra_make_args+=( "BUILD_CPPFLAGS=${build_cppflags}" )
extra_make_args+=( "BUILD_LDFLAGS=${build_ldflags}" )
- if [ "${libc_mode}" = "startfiles" -a ! -r "${multi_root}/.libc_headers_installed" ]; then
- CT_DoLog EXTRA "Installing C library headers"
- CT_DoExecLog ALL touch "${multi_root}/.libc_headers_installed"
-
- # use the 'install-headers' makefile target to install the
- # headers
- CT_DoExecLog ALL make ${JOBSFLAGS} \
- install_root=${multi_root} \
- install-bootstrap-headers=yes \
- "${extra_make_args[@]}" \
- install-headers
-
- # For glibc, a few headers need to be manually installed
- if [ "${CT_LIBC}" = "glibc" ]; then
- # Two headers -- stubs.h and features.h -- aren't installed by install-headers,
- # so do them by hand. We can tolerate an empty stubs.h for the moment.
- # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html
- mkdir -p "${CT_HEADERS_DIR}/gnu"
- CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h"
- CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/include/features.h" \
- "${CT_HEADERS_DIR}/features.h"
-
- # Building the bootstrap gcc requires either setting inhibit_libc, or
- # having a copy of stdio_lim.h... see
- # http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html
- CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h"
-
- # Following error building gcc-4.0.0's gcj:
- # error: bits/syscall.h: No such file or directory
- # solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html
- # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
- # Of course, only copy it if it does not already exist
- case "${CT_ARCH}" in
- arm) ;;
- *) if [ -f "${CT_HEADERS_DIR}/bits/syscall.h" ]; then
- CT_DoLog ALL "Not over-writing existing bits/syscall.h"
- elif [ -f "misc/bits/syscall.h" ]; then
- CT_DoExecLog ALL cp -v "misc/bits/syscall.h" \
- "${CT_HEADERS_DIR}/bits/syscall.h"
- else
- # "Old" glibces do not have the above file,
- # but provide this one:
- CT_DoExecLog ALL cp -v "misc/syscall-list.h" \
- "${CT_HEADERS_DIR}/bits/syscall.h"
- fi
- ;;
- esac
- fi
- elif [ "${libc_mode}" = "final" -a -r "${multi_root}/.libc_headers_installed" ]; then
- CT_DoExecLog ALL rm -f "${multi_root}/.libc_headers_installed"
- fi # installing headers
-
- if [ "${libc_mode}" = "startfiles" ]; then
- if [ "${CT_THREADS}" = "nptl" ]; then
- CT_DoLog EXTRA "Installing C library start files"
-
- # there are a few object files needed to link shared libraries,
- # which we build and install by hand
- CT_DoExecLog ALL mkdir -p "${startfiles_dir}"
- CT_DoExecLog ALL make ${JOBSFLAGS} \
- "${extra_make_args[@]}" \
- csu/subdir_lib
- CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \
- "${startfiles_dir}"
-
- # Finally, 'libgcc_s.so' requires a 'libc.so' to link against.
- # However, since we will never actually execute its code,
- # it doesn't matter what it contains. So, treating '/dev/null'
- # as a C source file, we produce a dummy 'libc.so' in one step
- CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" ${multi_flags} \
- -nostdlib \
- -nostartfiles \
- -shared \
- -x c /dev/null \
- -o "${startfiles_dir}/libc.so"
- fi # threads == nptl
- fi # libc_mode = startfiles
-
- if [ "${libc_mode}" = "final" ]; then
- CT_DoLog EXTRA "Building C library"
- CT_DoExecLog ALL make ${JOBSFLAGS} \
- "${extra_make_args[@]}" \
- all
-
- CT_DoLog EXTRA "Installing C library"
- CT_DoExecLog ALL make ${JOBSFLAGS} \
- "${extra_make_args[@]}" \
- install_root="${multi_root}" \
- install
-
- if [ "${CT_BUILD_MANUALS}" = "y" -a "${multi_index}" = "${multi_count}" ]; then
- # We only need to build the manuals once. Only build them on the
- # last multilib target. If it's not multilib, it will happen on the
- # only target.
- CT_DoLog EXTRA "Building and installing the C library manual"
- # Omit JOBSFLAGS as GLIBC has problems building the
- # manuals in parallel
- CT_DoExecLog ALL make pdf html
- CT_DoExecLog ALL mkdir -p ${CT_PREFIX_DIR}/share/doc
- CT_DoExecLog ALL cp -av manual/*.pdf \
- manual/libc \
- ${CT_PREFIX_DIR}/share/doc
- fi
-
- if [ "${CT_LIBC_LOCALES}" = "y" -a "${multi_index}" = "${multi_count}" ]; then
- do_libc_locales
- fi
- fi # libc_mode = final
+ CT_DoLog EXTRA "Building C library"
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} \
+ "${extra_make_args[@]}" \
+ all
+
+ CT_DoLog EXTRA "Installing C library"
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} \
+ "${extra_make_args[@]}" \
+ install_root="${multi_root}" \
+ install
+
+ if [ "${CT_BUILD_MANUALS}" = "y" -a "${multi_index}" = "${multi_count}" ]; then
+ # We only need to build the manuals once. Only build them on the
+ # last multilib target. If it's not multilib, it will happen on the
+ # only target.
+ CT_DoLog EXTRA "Building and installing the C library manual"
+ # Omit CT_JOBSFLAGS as GLIBC has problems building the
+ # manuals in parallel
+ CT_DoExecLog ALL make pdf html
+ CT_DoExecLog ALL mkdir -p ${CT_PREFIX_DIR}/share/doc
+ CT_DoExecLog ALL cp -av manual/*.pdf \
+ manual/libc \
+ ${CT_PREFIX_DIR}/share/doc
+ fi
+
+ if [ "${CT_GLIBC_LOCALES}" = "y" -a "${multi_index}" = "${multi_count}" ]; then
+ glibc_locales
+ fi
CT_EndStep
}
# Build up the addons list, separated with $1
-do_libc_add_ons_list() {
+glibc_add_ons_list()
+{
local sep="$1"
- local addons_list="$( echo "${CT_LIBC_ADDONS_LIST}" \
- |sed -r -e "s/[[:space:],]/${sep}/g;" \
- )"
- if [ "${CT_LIBC_GLIBC_2_20_or_later}" != "y" ]; then
- case "${CT_THREADS}" in
- none) ;;
- *) addons_list="${addons_list}${sep}${CT_THREADS}";;
- esac
+ local addons_list
+
+ if [ "${CT_GLIBC_USE_PORTS_ADDON}" = "y" ]; then
+ addons_list="${addons_list}${sep}ports"
+ fi
+ if [ "${CT_GLIBC_USE_NPTL_ADDON}" = "y" ]; then
+ addons_list="${addons_list}${sep}nptl"
fi
- [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list}${sep}ports"
- # Remove duplicate, leading and trailing separators
- echo "${addons_list}" |sed -r -e "s/${sep}+/${sep}/g; s/^${sep}//; s/${sep}\$//;"
+ if [ "${CT_GLIBC_USE_LIBIDN_ADDON}" = "y" ]; then
+ addons_list="${addons_list}${sep}libidn"
+ fi
+ echo "${addons_list#${sep}}" # Remove leading separator if any
}
# Compute up the minimum supported Linux kernel version
-do_libc_min_kernel_config() {
+glibc_min_kernel_config()
+{
local min_kernel_config
- case "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in
+ case "${CT_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in
*--enable-kernel*) ;;
- *) if [ "${CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS}" = "y" ]; then
+ *) if [ "${CT_GLIBC_KERNEL_VERSION_AS_HEADERS}" = "y" ]; then
+ # TBD do we support that currently? We always seem to install kernel headers
# We can't rely on the kernel version from the configuration,
# because it might not be available if the user uses pre-installed
# headers. On the other hand, both method will have the kernel
@@ -509,9 +345,9 @@ do_libc_min_kernel_config() {
patchlevel=$(((version_code>>8)&0xFF))
sublevel=$((version_code&0xFF))
min_kernel_config="${version}.${patchlevel}.${sublevel}"
- elif [ "${CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN}" = "y" ]; then
+ elif [ "${CT_GLIBC_KERNEL_VERSION_CHOSEN}" = "y" ]; then
# Trim the fourth part of the linux version, keeping only the first three numbers
- min_kernel_config="$( echo "${CT_LIBC_GLIBC_MIN_KERNEL_VERSION}" \
+ min_kernel_config="$( echo "${CT_GLIBC_MIN_KERNEL_VERSION}" \
|sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;' \
)"
fi
@@ -521,11 +357,21 @@ do_libc_min_kernel_config() {
}
# Build and install the libc locales
-do_libc_locales() {
- local src_dir="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}"
+glibc_locales()
+{
+ local src_dir="${CT_SRC_DIR}/glibc"
local -a extra_config
local glibc_cflags
+ # To build locales, we'd need to build glibc for the build machine.
+ # Bail out if the host is not supported.
+ case "${CT_BUILD}" in
+ *-cygwin|*-darwin*)
+ CT_DoLog EXTRA "Skipping GNU libc locales: incompatible build machine"
+ return
+ ;;
+ esac
+
mkdir -p "${CT_BUILD_DIR}/build-localedef"
cd "${CT_BUILD_DIR}/build-localedef"
@@ -535,7 +381,7 @@ do_libc_locales() {
# a harmless: `configure: WARNING: unrecognized options: --with-bugurl...`
# If it's set, use it, if is a recognized option.
if [ ! "${CT_TOOLCHAIN_PKGVERSION}" = "" ]; then
- extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
+ [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
fi
if [ ! "${CT_TOOLCHAIN_BUGURL}" = "" ]; then
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
@@ -544,7 +390,7 @@ do_libc_locales() {
CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
glibc_cflags="-O2 -fno-stack-protector"
- case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in
+ case "${CT_GLIBC_ENABLE_FORTIFIED_BUILD}" in
y) ;;
*) glibc_cflags+=" -U_FORTIFY_SOURCE";;
esac
@@ -578,7 +424,7 @@ do_libc_locales() {
"${extra_config[@]}"
CT_DoLog EXTRA "Building C library localedef"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
# The target's endianness and uint32_t alignment should be passed as options
# to localedef, but glibc's localedef does not support these options, which
@@ -586,7 +432,7 @@ do_libc_locales() {
# only if it has the same endianness and uint32_t alignment as the host's.
CT_DoLog EXTRA "Installing C library locales"
- CT_DoExecLog ALL make ${JOBSFLAGS} \
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS} \
install_root="${CT_SYSROOT_DIR}" \
localedata/install-locales
}
diff --git a/scripts/build/libc/mingw-w64.sh b/scripts/build/libc/mingw-w64.sh
new file mode 100644
index 0000000..54e8d07
--- /dev/null
+++ b/scripts/build/libc/mingw-w64.sh
@@ -0,0 +1,220 @@
+# Copyright 2012 Yann Diorcet
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+mingw_w64_set_install_prefix()
+{
+ MINGW_INSTALL_PREFIX=/usr/${CT_TARGET}
+ if [[ ${CT_MINGW_W64_VERSION} == 2* ]]; then
+ MINGW_INSTALL_PREFIX=/usr
+ fi
+}
+
+mingw_w64_headers() {
+ local -a sdk_opts
+
+ CT_DoStep INFO "Installing C library headers"
+
+ case "${CT_MINGW_DIRECTX}:${CT_MINGW_DDK}" in
+ y:y) sdk_opts+=( "--enable-sdk=all" );;
+ y:) sdk_opts+=( "--enable-sdk=directx" );;
+ :y) sdk_opts+=( "--enable-sdk=ddk" );;
+ :) ;;
+ esac
+
+ if [ "${CT_MINGW_SECURE_API}" = "y" ]; then
+ sdk_opts+=( "--enable-secure-api" )
+ fi
+
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-headers"
+
+ CT_DoLog EXTRA "Configuring Headers"
+
+ mingw_w64_set_install_prefix
+ CT_DoExecLog CFG \
+ ${CONFIG_SHELL} \
+ "${CT_SRC_DIR}/mingw-w64/mingw-w64-headers/configure" \
+ --build=${CT_BUILD} \
+ --host=${CT_TARGET} \
+ --prefix=${MINGW_INSTALL_PREFIX} \
+ "${sdk_opts[@]}"
+
+ CT_DoLog EXTRA "Compile Headers"
+ CT_DoExecLog ALL make
+
+ CT_DoLog EXTRA "Installing Headers"
+ CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR}
+
+ CT_Popd
+
+ # It seems mingw is strangely set up to look into /mingw instead of
+ # /usr (notably when looking for the headers). This symlink is
+ # here to workaround this, and seems to be here to last... :-/
+ CT_DoExecLog ALL ln -sv "usr/${CT_TARGET}" "${CT_SYSROOT_DIR}/mingw"
+
+ CT_EndStep
+}
+
+do_check_mingw_vendor_tuple()
+{
+ CT_DoStep INFO "Checking configured vendor tuple"
+ if [ ${CT_TARGET_VENDOR} = "w64" ]; then
+ CT_DoLog DEBUG "The tuple is set to '${CT_TARGET_VENDOR}', as recommended by mingw-64 developers."
+ else
+ CT_DoLog WARN "The tuple vendor is '${CT_TARGET_VENDOR}', not equal to 'w64' and might break the toolchain!"
+ fi
+ CT_EndStep
+}
+
+do_mingw_tools()
+{
+ local f
+
+ for f in "${CT_MINGW_TOOL_LIST_ARRAY[@]}"; do
+ CT_mkdir_pushd "${f}"
+ if [ ! -d "${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}" ]; then
+ CT_DoLog WARN "Skipping ${f}: not found"
+ CT_Popd
+ continue
+ fi
+
+ CT_DoLog EXTRA "Configuring ${f}"
+ CT_DoExecLog CFG \
+ ${CONFIG_SHELL} \
+ "${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}/configure" \
+ --build=${CT_BUILD} \
+ --host=${CT_HOST} \
+ --target=${CT_TARGET} \
+ --program-prefix=${CT_TARGET}- \
+ --prefix="${CT_PREFIX_DIR}"
+
+ # mingw-w64 has issues with parallel builds, see mingw_w64_main
+ CT_DoLog EXTRA "Building ${f}"
+ CT_DoExecLog ALL make
+ CT_DoLog EXTRA "Installing ${f}"
+ CT_DoExecLog ALL make install
+ CT_Popd
+ done
+}
+
+do_mingw_pthreads()
+{
+ local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count multi_target
+ local libprefix
+ local rcflags dlltoolflags
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'"
+
+ libprefix="${MINGW_INSTALL_PREFIX}/lib/${multi_os_dir}"
+ CT_SanitizeVarDir libprefix
+
+ CT_SymlinkToolsMultilib
+
+ # DLLTOOLFLAGS does not appear to be currently used by winpthread package, but
+ # the master package uses this variable and describes this as one of the changes
+ # needed for i686 in mingw-w64-doc/howto-build/mingw-w64-howto-build-adv.txt
+ case "${multi_target}" in
+ i[3456]86-*)
+ rcflags="-F pe-i386"
+ dlltoolflags="-m i386"
+ ;;
+ x86_64-*)
+ rcflags="-F pe-x86-64"
+ dlltoolflags="-m i386:x86_64"
+ ;;
+ *)
+ CT_Abort "Tuple ${multi_target} is not supported by mingw-w64"
+ ;;
+ esac
+
+ CT_DoLog EXTRA "Configuring mingw-w64-winpthreads"
+
+ CT_DoExecLog CFG \
+ CFLAGS="${multi_flags}" \
+ CXXFLAGS="${multi_flags}" \
+ RCFLAGS="${rcflags}" \
+ DLLTOOLFLAGS="${dlltoolflags}" \
+ ${CONFIG_SHELL} \
+ "${CT_SRC_DIR}/mingw-w64/mingw-w64-libraries/winpthreads/configure" \
+ --with-sysroot=${CT_SYSROOT_DIR} \
+ --prefix=${MINGW_INSTALL_PREFIX} \
+ --libdir=${libprefix} \
+ --build=${CT_BUILD} \
+ --host=${multi_target}
+
+ # mingw-w64 has issues with parallel builds, see mingw_w64_main
+ CT_DoLog EXTRA "Building mingw-w64-winpthreads"
+ CT_DoExecLog ALL make
+
+ CT_DoLog EXTRA "Installing mingw-w64-winpthreads"
+ CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR}
+
+ # Post-install hackery: all libwinpthread-1.dll end up being installed
+ # into /bin, which is broken on multilib install. Hence, stash it back
+ # into /lib - and after iterating over multilibs, copy the default one
+ # back into /bin.
+ if [ "${multi_index}" != 1 -o "${multi_count}" != 1 ]; then
+ CT_DoExecLog ALL mv "${CT_SYSROOT_DIR}${MINGW_INSTALL_PREFIX}/bin/libwinpthread-1.dll" \
+ "${CT_SYSROOT_DIR}${libprefix}/libwinpthread-1.dll"
+ if [ "${multi_index}" = 1 ]; then
+ default_libprefix="${libprefix}"
+ elif [ "${multi_index}" = "${multi_count}" ]; then
+ CT_DoExecLog ALL cp "${CT_SYSROOT_DIR}${default_libprefix}/libwinpthread-1.dll" \
+ "${CT_SYSROOT_DIR}${MINGW_INSTALL_PREFIX}/bin/libwinpthread-1.dll"
+ fi
+ fi
+
+ CT_EndStep
+}
+
+mingw_w64_main()
+{
+ # Used when iterating over libwinpthread
+ local default_libprefix
+
+ do_check_mingw_vendor_tuple
+
+ CT_DoStep INFO "Building mingw-w64"
+
+ CT_DoLog EXTRA "Configuring mingw-w64-crt"
+
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-crt"
+
+ mingw_w64_set_install_prefix
+ CT_DoExecLog CFG \
+ ${CONFIG_SHELL} \
+ "${CT_SRC_DIR}/mingw-w64/mingw-w64-crt/configure" \
+ --with-sysroot=${CT_SYSROOT_DIR} \
+ --prefix=${MINGW_INSTALL_PREFIX} \
+ --build=${CT_BUILD} \
+ --host=${CT_TARGET}
+
+ # mingw-w64-crt has a missing dependency occasionally breaking the
+ # parallel build. See https://github.com/crosstool-ng/crosstool-ng/issues/246
+ # Do not pass ${CT_JOBSFLAGS} - build serially.
+ CT_DoLog EXTRA "Building mingw-w64-crt"
+ CT_DoExecLog ALL make
+
+ CT_DoLog EXTRA "Installing mingw-w64-crt"
+ CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR}
+ CT_EndStep
+
+ if [ "${CT_THREADS}" = "posix" ]; then
+ CT_DoStep INFO "Building mingw-w64-winpthreads"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-winpthreads"
+ CT_IterateMultilibs do_mingw_pthreads pthreads-multilib
+ CT_Popd
+ CT_EndStep
+ fi
+
+ if [ "${CT_MINGW_TOOLS}" = "y" ]; then
+ CT_DoStep INFO "Installing mingw-w64 companion tools"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-tools"
+ do_mingw_tools
+ CT_Popd
+ CT_EndStep
+ fi
+}
diff --git a/scripts/build/libc/mingw.sh b/scripts/build/libc/mingw.sh
deleted file mode 100644
index eb04cb6..0000000
--- a/scripts/build/libc/mingw.sh
+++ /dev/null
@@ -1,178 +0,0 @@
-# Copyright 2012 Yann Diorcet
-# Licensed under the GPL v2. See COPYING in the root of this package
-
-CT_WINAPI_VERSION_DOWNLOADED=
-
-do_libc_get() {
- CT_DoStep INFO "Fetching mingw-w64 source for ${CT_WINAPI_VERSION}"
- if [ "${CT_WINAPI_VERSION}" = "devel" ]; then
- CT_GetGit "mingw-w64" "ref=HEAD" "git://git.code.sf.net/p/mingw-w64/mingw-w64" CT_WINAPI_VERSION_DOWNLOADED
- CT_DoLog EXTRA "Fetched as ${CT_WINAPI_VERSION_DOWNLOADED}"
- else
- CT_GetFile "mingw-w64-v${CT_WINAPI_VERSION}" \
- http://downloads.sourceforge.net/sourceforge/mingw-w64
- CT_WINAPI_VERSION_DOWNLOADED=v${CT_WINAPI_VERSION}
- fi
- CT_EndStep
-}
-
-do_libc_extract() {
- CT_Extract "mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}"
- CT_Pushd "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/"
- CT_Patch nochdir mingw-w64 "${CT_WINAPI_VERSION_DOWNLOADED}"
- CT_Popd
-}
-
-do_set_mingw_install_prefix(){
- MINGW_INSTALL_PREFIX=/usr/${CT_TARGET}
- if [[ ${CT_WINAPI_VERSION} == 2* ]]; then
- MINGW_INSTALL_PREFIX=/usr
- fi
-}
-
-do_libc_start_files() {
- local -a sdk_opts
-
- CT_DoStep INFO "Installing C library headers"
-
- case "${CT_MINGW_DIRECTX}:${CT_MINGW_DDK}" in
- y:y) sdk_opts+=( "--enable-sdk=all" );;
- y:) sdk_opts+=( "--enable-sdk=directx" );;
- :y) sdk_opts+=( "--enable-sdk=ddk" );;
- :) ;;
- esac
-
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-headers"
-
- CT_DoLog EXTRA "Configuring Headers"
-
- do_set_mingw_install_prefix
- CT_DoExecLog CFG \
- ${CONFIG_SHELL} \
- "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-headers/configure" \
- --build=${CT_BUILD} \
- --host=${CT_TARGET} \
- --prefix=${MINGW_INSTALL_PREFIX} \
- "${sdk_opts[@]}"
-
- CT_DoLog EXTRA "Compile Headers"
- CT_DoExecLog ALL make
-
- CT_DoLog EXTRA "Installing Headers"
- CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR}
-
- CT_Popd
-
- # It seems mingw is strangely set up to look into /mingw instead of
- # /usr (notably when looking for the headers). This symlink is
- # here to workaround this, and seems to be here to last... :-/
- CT_DoExecLog ALL ln -sv "usr/${CT_TARGET}" "${CT_SYSROOT_DIR}/mingw"
-
- CT_EndStep
-}
-
-do_check_mingw_vendor_tuple()
-{
- if [[ ${CT_WINAPI_VERSION} == 4* ]]; then
- CT_DoStep INFO "Checking vendor tuple configured in crosstool-ng .config"
- if [[ ${CT_TARGET_VENDOR} == w64 ]]; then
- CT_DoLog EXTRA "The tuple is set to '${CT_TARGET_VENDOR}', as recommended by mingw-64 team."
- else
- CT_DoLog WARN "WARNING! The tuple '${CT_TARGET_VENDOR}', is not equal to w64 and might break the toolchain! WARNING!"
- fi
- CT_EndStep
- fi
-}
-
-do_mingw_tools() {
- for f in gendef genidl genlib genpeimg widl
- do
- if [[ ! -d "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-tools/${f}" ]]; then
- continue;
- fi
-
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-tools/${f}"
-
- CT_DoExecLog CFG \
- ${CONFIG_SHELL} \
- "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-tools/${f}/configure" \
- --build=${CT_BUILD} \
- --host=${CT_HOST} \
- --target=${CT_TARGET} \
- --program-prefix=${CT_TARGET}- \
- --prefix="${CT_PREFIX_DIR}"
-
- CT_DoExecLog ALL ${make} ${JOBSFLAGS}
-
- CT_DoExecLog ALL ${make} install
-
- CT_Popd
- done
-}
-
-do_libc() {
- do_check_mingw_vendor_tuple
-
- CT_DoStep INFO "Building mingw-w64 files"
-
- CT_DoLog EXTRA "Configuring mingw-w64-crt"
-
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-crt"
-
- do_set_mingw_install_prefix
- CT_DoExecLog CFG \
- ${CONFIG_SHELL} \
- "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-crt/configure" \
- --with-sysroot=${CT_SYSROOT_DIR} \
- --prefix=${MINGW_INSTALL_PREFIX} \
- --build=${CT_BUILD} \
- --host=${CT_TARGET} \
-
- # mingw-w64-crt has a missing dependency occasionally breaking the
- # parallel build. See https://github.com/crosstool-ng/crosstool-ng/issues/246
- # Do not pass ${JOBSFLAGS} - build serially.
- CT_DoLog EXTRA "Building mingw-w64-crt"
- CT_DoExecLog ALL make
-
- CT_DoLog EXTRA "Installing mingw-w64-crt"
- CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR}
-
- if [[ ${CT_MINGW_TOOLS} == "y" ]]; then
- CT_DoLog EXTRA "Installing mingw-w64 companion tools"
- do_mingw_tools
- fi
-
- CT_EndStep
-
- if [ "${CT_THREADS}" = "posix" ]; then
- do_pthreads
- fi
-}
-
-do_libc_post_cc() {
- :
-}
-
-do_pthreads() {
- CT_DoStep INFO "Building mingw-w64-winpthreads files"
-
- CT_DoLog EXTRA "Configuring mingw-w64-winpthreads"
-
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-winpthreads"
-
- CT_DoExecLog CFG \
- ${CONFIG_SHELL} \
- "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-libraries/winpthreads/configure" \
- --with-sysroot=${CT_SYSROOT_DIR} \
- --prefix=${MINGW_INSTALL_PREFIX} \
- --build=${CT_BUILD} \
- --host=${CT_TARGET} \
-
- CT_DoLog EXTRA "Building mingw-w64-winpthreads"
- CT_DoExecLog ALL make ${JOBSFLAGS}
-
- CT_DoLog EXTRA "Installing mingw-w64-winpthreads"
- CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR}
-
- CT_EndStep
-}
diff --git a/scripts/build/libc/moxiebox.sh b/scripts/build/libc/moxiebox.sh
new file mode 100644
index 0000000..35e2ea4
--- /dev/null
+++ b/scripts/build/libc/moxiebox.sh
@@ -0,0 +1,79 @@
+# Functions to build the moxiebox runtime.
+
+. "${CT_LIB_DIR}/scripts/build/libc/newlib.sh"
+
+moxiebox_get()
+{
+ CT_Fetch NEWLIB
+ CT_Fetch MOXIEBOX
+}
+
+moxiebox_extract()
+{
+ CT_ExtractPatch NEWLIB
+ CT_ExtractPatch MOXIEBOX
+}
+
+moxiebox_headers()
+{
+ newlib_headers
+}
+
+moxiebox_main()
+{
+ newlib_main
+}
+
+moxiebox_post_cc()
+{
+ CT_DoStep INFO "Installing moxiebox runtime and VM"
+
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-moxiebox"
+ CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/moxiebox/." .
+
+ CT_DoLog EXTRA "Building SHA256-only libcrypto"
+ # Moxiebox needs libcrypto on the host, but it only uses SHA256 digest functions
+ # from it. We don't want to pull the whole OpenSSL for the host; fortunately,
+ # moxiebox comes with a standalone SHA256 implementation - which it only uses
+ # for the target library. Help it use the same implementation for the host.
+ CT_mkdir_pushd openssl
+ CT_DoExecLog ALL cp -v "${CT_LIB_DIR}/packages/moxiebox/"sha*.[ch] ./
+ CT_DoExecLog ALL "${CT_HOST}-gcc" -c sha256_wrap.c -O2 -Wall
+ CT_DoExecLog ALL "${CT_HOST}-ar" cru libcrypto.a sha256_wrap.o
+ CT_Popd
+
+ # Moxiebox includes a VM which we're building for the
+ # host machine.
+ CT_DoLog EXTRA "Configuring moxiebox"
+
+ CT_DoExecLog CFG ./autogen.sh
+
+ # moxiebox build script creates symlinks from the installation location to the build
+ # directory for the moxiebox library. This seems backwards. Instead, pass the search
+ # as part of the MOX_GCC definition.
+ # moxiebox also depends on the tools being named moxiebox-{gcc,as,ar}. However, failure
+ # to detect such tools is non-fatal in the configure and we need to override it in
+ # make's command line anyway.
+ CT_DoExecLog CFG \
+ LDFLAGS="${CT_LDFLAGS_FOR_HOST} -L${CT_BUILD_DIR}/build-libc-moxiebox/openssl" \
+ CFLAGS="${CT_CFLAGS_FOR_HOST} -I${CT_BUILD_DIR}/build-libc-moxiebox" \
+ CXXFLAGS="${CT_CFLAGS_FOR_HOST} -I${CT_BUILD_DIR}/build-libc-moxiebox" \
+ ./configure \
+ --host="${CT_HOST}"
+ CT_DoLog EXTRA "Building moxiebox"
+ CT_DoExecLog CFG make all \
+ MOX_GCC="${CT_TARGET}-gcc -B ${CT_BUILD_DIR}/build-libc-moxiebox/runtime -B ${CT_SYSROOT_DIR}/lib" \
+ MOX_AS="${CT_TARGET}-as" \
+ MOX_AR="${CT_TARGET}-ar"
+
+ CT_DoLog EXTRA "Installing moxiebox"
+
+ # moxiebox does not have install target. Copy the interesting stuff manually.
+ CT_DoExecLog ALL cp -v "${CT_BUILD_DIR}/build-libc-moxiebox/runtime/libsandboxrt.a" \
+ "${CT_BUILD_DIR}/build-libc-moxiebox/runtime/crt0.o" \
+ "${CT_SYSROOT_DIR}/lib/"
+ CT_DoExecLog ALL cp -v "${CT_BUILD_DIR}/build-libc-moxiebox/src/sandbox" \
+ "${CT_PREFIX_DIR}/bin"
+ CT_Popd
+ CT_EndStep
+}
diff --git a/scripts/build/libc/musl.sh b/scripts/build/libc/musl.sh
index 4ccb84c..bc2a2e6 100644
--- a/scripts/build/libc/musl.sh
+++ b/scripts/build/libc/musl.sh
@@ -2,65 +2,31 @@
# Copyright 2013 Timo Teräs
# Licensed under the GPL v2. See COPYING in the root of this package
-do_libc_get() {
- if [ "${CT_LIBC_MUSL_CUSTOM}" = "y" ]; then
- CT_GetCustom "musl" "${CT_LIBC_MUSL_CUSTOM_VERSION}" \
- "${CT_LIBC_MUSL_CUSTOM_LOCATION}"
- else # ! custom location
- CT_GetFile "musl-${CT_LIBC_VERSION}" http://www.musl-libc.org/releases
- fi # ! custom location
+musl_post_cc()
+{
+ # MUSL creates dynamic linker symlink with absolute path - which works on the
+ # target but not on the host. We want our cross-ldd tool to work.
+ CT_MultilibFixupLDSO
}
-do_libc_extract() {
- CT_Extract "musl-${CT_LIBC_VERSION}"
- CT_Patch "musl" "${CT_LIBC_VERSION}"
-}
-
-# Build and install headers and start files
-do_libc_start_files() {
- # Start files and Headers should be configured the same way as the
- # final libc, but built and installed differently.
- do_libc_backend libc_mode=startfiles
-}
-
-# This function builds and install the full C library
-do_libc() {
- do_libc_backend libc_mode=final
-}
-
-do_libc_post_cc() {
- :
-}
-
-do_libc_backend() {
- local libc_mode
- local arg
-
- for arg in "$@"; do
- eval "${arg// /\\ }"
- done
-
- case "${libc_mode}" in
- startfiles) CT_DoStep INFO "Installing C library headers & start files";;
- final) CT_DoStep INFO "Installing C library";;
- *) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";;
- esac
-
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}"
- CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}"
+musl_main()
+{
+ CT_DoStep INFO "Installing C library"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc"
+ CT_IterateMultilibs musl_backend_once multilib
CT_Popd
CT_EndStep
}
# This backend builds the C library
-# Usage: do_libc_backend param=value [...]
+# Usage: musl_backend param=value [...]
# Parameter : Definition : Type : Default
-# libc_mode : 'startfiles' or 'final' : string : (none)
-do_libc_backend_once() {
- local libc_mode
+# multi_* : as defined in CT_IterateMultilibs : (varies) :
+musl_backend_once()
+{
local -a extra_cflags
local -a extra_config
- local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}"
+ local src_dir="${CT_SRC_DIR}/musl"
local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count
local multilib_dir
local hdr_install_subdir
@@ -78,13 +44,6 @@ do_libc_backend_once() {
extra_cflags=( ${multi_flags} )
- # From buildroot:
- # gcc constant folding bug with weak aliases workaround
- # See http://www.openwall.com/lists/musl/2014/05/15/1
- if [ "${CT_CC_GCC_4_9_or_later}" = "y" ]; then
- extra_cflags+=("-fno-toplevel-reorder")
- fi
-
if [ "${CT_LIBC_MUSL_DEBUG}" = "y" ]; then
extra_config+=("--enable-debug")
fi
@@ -93,6 +52,11 @@ do_libc_backend_once() {
extra_config+=("--enable-warnings")
fi
+ case "${CT_SHARED_LIBS}" in
+ y) extra_config+=("--enable-shared");;
+ *) extra_config+=("--disable-shared");;
+ esac
+
extra_config+=( "--enable-optimize=${CT_LIBC_MUSL_OPTIMIZE}" )
# Same problem as with uClibc: different variants sometimes have
@@ -102,13 +66,16 @@ do_libc_backend_once() {
extra_config+=( "--includedir=/usr/include/${hdr_install_subdir}" )
fi
+ CT_SymlinkToolsMultilib
+
# NOTE: musl handles the build/host/target a little bit differently
# then one would expect:
# build : not used
# host : same as --target
# target : the machine musl runs on
CT_DoExecLog CFG \
- CFLAGS="${extra_cflags[*]}" \
+ CFLAGS="${CT_TARGET_CFLAGS} ${extra_cflags[*]}" \
+ LDFLAGS="${CT_TARGET_LDFLAGS}" \
CROSS_COMPILE="${CT_TARGET}-" \
${CONFIG_SHELL} \
${src_dir}/configure \
@@ -119,45 +86,26 @@ do_libc_backend_once() {
--disable-gcc-wrapper \
"${extra_config[@]}"
- if [ "${libc_mode}" = "startfiles" ]; then
- CT_DoLog EXTRA "Installing C library headers"
- CT_DoExecLog ALL make DESTDIR="${multi_root}" install-headers
- CT_DoLog EXTRA "Building C library start files"
- CT_DoExecLog ALL make DESTDIR="${multi_root}" \
- obj/crt/crt1.o obj/crt/crti.o obj/crt/crtn.o
- CT_DoLog EXTRA "Installing C library start files"
- CT_DoExecLog ALL cp -av obj/crt/crt*.o "${multi_root}${multilib_dir}"
- CT_DoExecLog ALL ${CT_TARGET}-${CT_CC} -nostdlib \
- -nostartfiles -shared -x c /dev/null -o "${multi_root}${multilib_dir}/libc.so"
- fi
- if [ "${libc_mode}" = "final" ]; then
- CT_DoLog EXTRA "Cleaning up start files"
- CT_DoExecLog ALL rm -f "${multi_root}${multilib_dir}/crt1.o" \
- "${multi_root}${multilib_dir}/crti.o" \
- "${multi_root}${multilib_dir}/crtn.o" \
- "${multi_root}${multilib_dir}/libc.so"
-
- CT_DoLog EXTRA "Building C library"
- CT_DoExecLog ALL make ${JOBSFLAGS}
-
- CT_DoLog EXTRA "Installing C library"
- CT_DoExecLog ALL make DESTDIR="${multi_root}" install
-
- # Convert /lib/ld-* symlinks to relative paths so that they are valid
- # both on the host and on the target.
- for f in ${multi_root}/ld-musl-*; do
- [ -L "${f}" ] || continue
- l=$( readlink ${f} )
- case "${l}" in
- ${multilib_dir}/*)
- CT_DoExecLog ALL ln -sf "../${l}" "${f}"
- ;;
- esac
- done
-
- # Any additional actions for this architecture
- CT_DoArchMUSLPostInstall
- fi
+ CT_DoLog EXTRA "Building C library"
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
+
+ CT_DoLog EXTRA "Installing C library"
+ CT_DoExecLog ALL make DESTDIR="${multi_root}" install
+
+ # Convert /lib/ld-* symlinks to relative paths so that they are valid
+ # both on the host and on the target.
+ for f in ${multi_root}/ld-musl-*; do
+ [ -L "${f}" ] || continue
+ l=$( readlink ${f} )
+ case "${l}" in
+ ${multilib_dir}/*)
+ CT_DoExecLog ALL ln -sf "../${l}" "${f}"
+ ;;
+ esac
+ done
+
+ # Any additional actions for this architecture
+ CT_DoArchMUSLPostInstall
CT_EndStep
}
diff --git a/scripts/build/libc/newlib.sh b/scripts/build/libc/newlib.sh
index 3b48507..72111a9 100644
--- a/scripts/build/libc/newlib.sh
+++ b/scripts/build/libc/newlib.sh
@@ -5,64 +5,32 @@
# Edited by Martin Lund <mgl@doredevelopment.dk>
#
-do_libc_get() {
- local libc_src="{http://mirrors.kernel.org/sourceware/newlib,
- ftp://sourceware.org/pub/newlib}"
-
- if [ "${CT_LIBC_NEWLIB_CUSTOM}" = "y" ]; then
- CT_GetCustom "newlib" "${CT_LIBC_NEWLIB_CUSTOM_VERSION}" \
- "${CT_LIBC_NEWLIB_CUSTOM_LOCATION}"
- else # ! custom location
- case "${CT_LIBC_VERSION}" in
- linaro-*)
- CT_GetLinaro "newlib" "${CT_LIBC_VERSION}"
- ;;
- *)
- # kernel.org mirror is outdated, keep last as a fallback
- CT_GetFile "newlib-${CT_LIBC_VERSION}" \
- ftp://sourceware.org/pub/newlib \
- http://mirrors.kernel.org/sourceware/newlib \
- http://mirrors.kernel.org/sources.redhat.com/newlib
- ;;
- esac
- fi # ! custom location
-}
-
-do_libc_extract() {
- CT_Extract "newlib-${CT_LIBC_VERSION}"
- CT_Patch "newlib" "${CT_LIBC_VERSION}"
-
- if [ -n "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then
- CT_ConfigureXtensa "newlib" "${CT_LIBC_VERSION}"
- fi
-}
-
-do_libc_start_files() {
- CT_DoStep INFO "Installing C library headers & start files"
- CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/newlib/libc/include/." \
- "${CT_HEADERS_DIR}"
- if [ "${CT_ARCH_xtensa}" = "y" ]; then
+newlib_headers()
+{
+ CT_DoStep INFO "Installing C library headers"
+ CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib/newlib/libc/include/." "${CT_HEADERS_DIR}"
+ if [ "${CT_ARCH_XTENSA}" = "y" ]; then
CT_DoLog EXTRA "Installing Xtensa headers"
- CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/newlib/libc/sys/xtensa/include/." \
+ CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/newlib/newlib/libc/sys/xtensa/include/." \
"${CT_HEADERS_DIR}"
fi
CT_EndStep
}
-do_libc() {
+newlib_main()
+{
local -a newlib_opts
local cflags_for_target
CT_DoStep INFO "Installing C library"
- mkdir -p "${CT_BUILD_DIR}/build-libc"
- cd "${CT_BUILD_DIR}/build-libc"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc"
CT_DoLog EXTRA "Configuring C library"
# Multilib is the default, so if it is not enabled, disable it.
if [ "${CT_MULTILIB}" != "y" ]; then
- extra_config+=("--disable-multilib")
+ newlib_opts+=("--disable-multilib")
fi
if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
@@ -86,16 +54,19 @@ do_libc() {
yn_args="IO_POS_ARGS:newlib-io-pos-args
IO_C99FMT:newlib-io-c99-formats
IO_LL:newlib-io-long-long
-NEWLIB_REGISTER_FINI:newlib-register-fini
+REGISTER_FINI:newlib-register-fini
NANO_MALLOC:newlib-nano-malloc
NANO_FORMATTED_IO:newlib-nano-formatted-io
-ATEXIT_DYNAMIC_ALLOC:atexit-dynamic-alloc
+ATEXIT_DYNAMIC_ALLOC:newlib-atexit-dynamic-alloc
GLOBAL_ATEXIT:newlib-global-atexit
LITE_EXIT:lite-exit
-REENT_SMALL:reent-small
-MULTITHREAD:multithread
+REENT_SMALL:newlib-reent-small
+MULTITHREAD:newlib-multithread
+RETARGETABLE_LOCKING:newlib-retargetable-locking
WIDE_ORIENT:newlib-wide-orient
-UNBUF_STREAM_OPT:unbuf-stream-opt
+FSEEK_OPTIMIZATION:newlib-fseek-optimization
+FVWRITE_IN_STREAMIO:newlib-fvwrite-in-streamio
+UNBUF_STREAM_OPT:newlib-unbuf-stream-opt
ENABLE_TARGET_OPTSPACE:target-optspace
"
@@ -118,7 +89,7 @@ ENABLE_TARGET_OPTSPACE:target-optspace
[ "${CT_LIBC_NEWLIB_LTO}" = "y" ] && \
CT_LIBC_NEWLIB_TARGET_CFLAGS="${CT_LIBC_NEWLIB_TARGET_CFLAGS} -flto"
- cflags_for_target="${CT_TARGET_CFLAGS} ${CT_LIBC_NEWLIB_TARGET_CFLAGS}"
+ cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_NEWLIB_TARGET_CFLAGS}"
# Note: newlib handles the build/host/target a little bit differently
# than one would expect:
@@ -131,7 +102,7 @@ ENABLE_TARGET_OPTSPACE:target-optspace
AR_FOR_TARGET="`which ${CT_TARGET}-gcc-ar`" \
RANLIB_FOR_TARGET="`which ${CT_TARGET}-gcc-ranlib`" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/configure" \
+ "${CT_SRC_DIR}/newlib/configure" \
--host=${CT_BUILD} \
--target=${CT_TARGET} \
--prefix=${CT_PREFIX_DIR} \
@@ -139,7 +110,7 @@ ENABLE_TARGET_OPTSPACE:target-optspace
"${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}"
CT_DoLog EXTRA "Building C library"
- CT_DoExecLog ALL make ${JOBSFLAGS}
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
CT_DoLog EXTRA "Installing C library"
CT_DoExecLog ALL make install
@@ -159,9 +130,6 @@ ENABLE_TARGET_OPTSPACE:target-optspace
"${CT_PREFIX_DIR}/share/doc/newlib"
fi
+ CT_Popd
CT_EndStep
}
-
-do_libc_post_cc() {
- :
-}
diff --git a/scripts/build/libc/none.sh b/scripts/build/libc/none.sh
index 8537a8e..5173afb 100644
--- a/scripts/build/libc/none.sh
+++ b/scripts/build/libc/none.sh
@@ -2,22 +2,12 @@
# Copyright 2008 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package
-do_libc_get() {
+none_get()
+{
:
}
-do_libc_extract() {
- :
-}
-
-do_libc_start_files() {
- :
-}
-
-do_libc() {
- :
-}
-
-do_libc_post_cc() {
+none_extract()
+{
:
}
diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc-ng.sh
index e87abaf..7b81d92 100644
--- a/scripts/build/libc/uClibc.sh
+++ b/scripts/build/libc/uClibc-ng.sh
@@ -2,96 +2,22 @@
# Copyright 2007 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package
-# This is a constant because it does not change very often.
-# We're in 2010, and are still using data from 7 years ago.
-uclibc_locales_version=030818
-uclibc_locale_tarball="uClibc-locale-${uclibc_locales_version}"
-
-if [ "${CT_LIBC_UCLIBC_NG}" = "y" ]; then
- uclibc_name="uClibc-ng"
- libc_src="http://downloads.uclibc-ng.org/releases/${CT_LIBC_VERSION}"
-else
- uclibc_name="uClibc"
- libc_src="http://www.uclibc.org/downloads
- http://www.uclibc.org/downloads/old-releases"
-fi
-
-# Download uClibc
-do_libc_get() {
- if [ "${CT_LIBC_UCLIBC_CUSTOM}" = "y" ]; then
- CT_GetCustom "${uclibc_name}" "${CT_LIBC_UCLIBC_CUSTOM_VERSION}" \
- "${CT_LIBC_UCLIBC_CUSTOM_LOCATION}"
- else
- CT_GetFile "${uclibc_name}-${CT_LIBC_VERSION}" ${libc_src}
- fi
- # uClibc locales
- if [ "${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" = "y" ]; then
- CT_GetFile "${uclibc_locale_tarball}" ${libc_src}
- fi
-
- return 0
-}
-
-# Extract uClibc
-do_libc_extract() {
- CT_Extract "${uclibc_name}-${CT_LIBC_VERSION}"
- CT_Patch "${uclibc_name}" "${CT_LIBC_VERSION}"
-
- # uClibc locales
- # Extracting pregen locales ourselves is kinda
- # broken, so just link it in place...
- if [ "${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" = "y" \
- -a ! -f "${CT_SRC_DIR}/.${uclibc_locale_tarball}.extracted" ]; then
- CT_Pushd "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}/extra/locale"
- CT_DoExecLog ALL ln -s "${CT_TARBALLS_DIR}/${uclibc_locale_tarball}.tgz" .
- CT_Popd
- touch "${CT_SRC_DIR}/.${uclibc_locale_tarball}.extracted"
- fi
-
- return 0
-}
-
-# Build and install headers and start files
-do_libc_start_files() {
- # Start files and Headers should be configured the same way as the
- # final libc, but built and installed differently.
- do_libc_backend libc_mode=startfiles
-}
-
# This function builds and install the full C library
-do_libc() {
- do_libc_backend libc_mode=final
-}
-
-# Common backend for 1st and 2nd passes.
-do_libc_backend() {
- local libc_mode
- local arg
-
- for arg in "$@"; do
- eval "${arg// /\\ }"
- done
-
- case "${libc_mode}" in
- startfiles) CT_DoStep INFO "Installing C library headers & start files";;
- final) CT_DoStep INFO "Installing C library";;
- *) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";;
- esac
-
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}"
- CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}"
-
-
+uClibc_ng_main()
+{
+ CT_DoStep INFO "Installing C library"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc"
+ CT_IterateMultilibs uClibc_ng_backend_once multilib
CT_Popd
CT_EndStep
}
# Common backend for 1st and 2nd passes, once per multilib.
-do_libc_backend_once() {
- local libc_mode
+uClibc_ng_backend_once()
+{
local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count
local multilib_dir startfiles_dir
- local jflag=${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}}
+ local jflag=${CT_JOBSFLAGS}
local -a make_args
local extra_cflags f cfg_cflags cf
local hdr_install_subdir
@@ -102,17 +28,13 @@ do_libc_backend_once() {
CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'"
- # Simply copy files until uClibc has the ability to build out-of-tree
- CT_DoLog EXTRA "Copying sources to build dir"
- CT_DoExecLog ALL cp -aT "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}/." .
-
multilib_dir="lib/${multi_os_dir}"
startfiles_dir="${multi_root}/usr/${multilib_dir}"
CT_SanitizeVarDir multilib_dir startfiles_dir
# Construct make arguments:
# - uClibc uses the CROSS environment variable as a prefix to the compiler
- # tools to use. Since it requires core pass-1, thusly named compiler is
+ # tools to use. Since it requires core compiler, thusly named compiler is
# already available.
# - Note about CFLAGS: In uClibc, CFLAGS are generated by Rules.mak,
# depending on the configuration of the library. That is, they are tailored
@@ -121,20 +43,24 @@ do_libc_backend_once() {
# - We do _not_ want to strip anything for now, in case we specifically
# asked for a debug toolchain, thus the STRIPTOOL= assignment.
make_args=( CROSS_COMPILE="${CT_TARGET}-" \
+ HOSTCC="${CT_BUILD}-gcc" \
PREFIX="${multi_root}/" \
MULTILIB_DIR="${multilib_dir}" \
- LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \
STRIPTOOL=true \
${CT_LIBC_UCLIBC_VERBOSITY} \
)
+ # Simply copy files until uClibc has the ability to build out-of-tree
+ CT_DoLog EXTRA "Copying sources to build dir"
+ CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/uClibc-ng/." .
+
# Force the date of the pregen locale data, as the
# newer ones that are referenced are not available
CT_DoLog EXTRA "Applying configuration"
# Use the default config if the user did not provide one.
if [ -z "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then
- CT_LIBC_UCLIBC_CONFIG_FILE="${CT_LIB_DIR}/contrib/uClibc-defconfigs/${uclibc_name}.config"
+ CT_LIBC_UCLIBC_CONFIG_FILE="${CT_LIB_DIR}/packages/uClibc-ng/config"
fi
manage_uClibc_config "${CT_LIBC_UCLIBC_CONFIG_FILE}" .config "${multi_flags}"
@@ -176,63 +102,11 @@ do_libc_backend_once() {
CT_DoExecLog ALL cp -a "${multi_root}/usr/include" "${multi_root}/usr/include.saved"
fi
- if [ "${libc_mode}" = "startfiles" ]; then
- CT_DoLog EXTRA "Building headers"
- CT_DoExecLog ALL make "${make_args[@]}" headers
-
- # Ensure the directory for installing multilib-specific binaries exists.
- CT_DoExecLog ALL mkdir -p "${startfiles_dir}"
-
- CT_DoLog EXTRA "Installing headers"
- CT_DoExecLog ALL make "${make_args[@]}" install_headers
-
- # The check might look bogus, but it is the same condition as is used
- # by GCC build script to enable/disable shared library support.
- if [ "${CT_THREADS}" = "nptl" ]; then
- CT_DoLog EXTRA "Building start files"
- CT_DoExecLog ALL make ${jflag} "${make_args[@]}" \
- lib/crt1.o lib/crti.o lib/crtn.o
-
- # From: http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=ad5668a7ac7e0436db92e55caaf3fdf782b6ba3b
- # libm.so is needed for ppc, as libgcc is linked against libm.so
- # No problem to create it for other archs.
- CT_DoLog EXTRA "Building dummy shared libs"
- CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -nostdlib -nostartfiles \
- -shared ${multi_flags} -x c /dev/null -o libdummy.so
-
- CT_DoLog EXTRA "Installing start files"
- CT_DoExecLog ALL install -m 0644 lib/crt1.o lib/crti.o lib/crtn.o \
- "${startfiles_dir}"
-
- CT_DoLog EXTRA "Installing dummy shared libs"
- CT_DoExecLog ALL install -m 0755 libdummy.so "${startfiles_dir}/libc.so"
- CT_DoExecLog ALL install -m 0755 libdummy.so "${startfiles_dir}/libm.so"
- fi # CT_THREADS == nptl
- fi # libc_mode == startfiles
-
- if [ "${libc_mode}" = "final" ]; then
- CT_DoLog EXTRA "Cleaning up startfiles"
- CT_DoExecLog ALL rm -f "${startfiles_dir}/crt1.o" \
- "${startfiles_dir}/crti.o" \
- "${startfiles_dir}/crtn.o" \
- "${startfiles_dir}/libc.so" \
- "${startfiles_dir}/libm.so"
-
- CT_DoLog EXTRA "Building C library"
- CT_DoExecLog ALL make "${make_args[@]}" pregen
- CT_DoExecLog ALL make ${jflag} "${make_args[@]}" all
-
- # YEM-FIXME:
- # - we want to install 'runtime' files, eg. lib*.{a,so*}, crti.o and
- # such files, except the headers as they already are installed
- # - "make install_dev" installs the headers, the crti.o... and the
- # static libs, but not the dynamic libs
- # - "make install_runtime" installs the dynamic libs only
- # - "make install" calls install_runtime and install_dev
- # - so we're left with re-installing the headers... Sigh...
- CT_DoLog EXTRA "Installing C library"
- CT_DoExecLog ALL make "${make_args[@]}" install install_utils
- fi # libc_mode == final
+ CT_DoLog EXTRA "Building C library"
+ CT_DoExecLog ALL make "${make_args[@]}" pregen
+ CT_DoExecLog ALL make ${jflag} "${make_args[@]}" all
+ CT_DoLog EXTRA "Installing C library"
+ CT_DoExecLog ALL make "${make_args[@]}" install install_utils
# Now, if installing headers into a subdirectory, put everything in its place.
# Remove the header subdirectory if it existed already.
@@ -249,7 +123,8 @@ do_libc_backend_once() {
# Initialises the .config file to sensible values
# $1: original file
# $2: modified file
-manage_uClibc_config() {
+manage_uClibc_config()
+{
src="$1"
dst="$2"
flags="$3"
@@ -258,13 +133,13 @@ manage_uClibc_config() {
CT_DoExecLog ALL cp "${src}" "${dst}"
case "${CT_ARCH_ENDIAN}" in
- big)
+ big|big,little)
CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${dst}"
CT_KconfigDisableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}"
CT_KconfigEnableOption "ARCH_BIG_ENDIAN" "${dst}"
CT_KconfigEnableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}"
;;
- little)
+ little|little,big)
CT_KconfigDisableOption "ARCH_BIG_ENDIAN" "${dst}"
CT_KconfigDisableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}"
CT_KconfigEnableOption "ARCH_LITTLE_ENDIAN" "${dst}"
@@ -276,6 +151,15 @@ manage_uClibc_config() {
CT_KconfigEnableOption "ARCH_USE_MMU" "${dst}"
else
CT_KconfigDisableOption "ARCH_USE_MMU" "${dst}"
+ CT_KconfigDisableOption "UCLIBC_FORMAT_FDPIC" "${dst}"
+ CT_KconfigDisableOption "UCLIBC_FORMAT_FLAT" "${dst}"
+ CT_KconfigDisableOption "UCLIBC_FORMAT_SHARED_FLAT" "${dst}"
+ case "${CT_ARCH_BINFMT_FLAT},${CT_ARCH_BINFMT_FDPIC},${CT_SHARED_LIBS}" in
+ y,,y) CT_KconfigEnableOption "UCLIBC_FORMAT_SHARED_FLAT" "${dst}";;
+ y,,) CT_KconfigEnableOption "UCLIBC_FORMAT_FLAT" "${dst}";;
+ ,y,*) CT_KconfigEnableOption "UCLIBC_FORMAT_FDPIC" "${dst}";;
+ *) CT_Abort "Unsupported binary format";;
+ esac
fi
if [ "${CT_SHARED_LIBS}" = "y" ]; then
@@ -324,27 +208,14 @@ manage_uClibc_config() {
# entirely if LOCALE is not set. If LOCALE was already set, we'll
# assume the user has already made all the appropriate generation
# arrangements. Note that having the uClibc Makefile download the
- # pregenerated locales is not compatible with crosstool; besides,
- # crosstool downloads them as part of getandpatch.sh.
- CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE" "${dst}"
- case "${CT_LIBC_UCLIBC_LOCALES}:${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" in
- :*)
- ;;
- y:)
+ # pregenerated locales is not compatible with crosstool.
+ if [ -z "${CT_LIBC_UCLIBC_LOCALES}" ]; then
+ CT_KconfigDisableOption "UCLIBC_HAS_LOCALE" "${dst}"
+ else
CT_KconfigEnableOption "UCLIBC_HAS_LOCALE" "${dst}"
CT_KconfigDeleteOption "UCLIBC_PREGENERATED_LOCALE_DATA" "${dst}"
- CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA" \
- "${dst}"
- CT_KconfigDeleteOption "UCLIBC_HAS_XLOCALE" "${dst}"
- ;;
- y:y)
- CT_KconfigEnableOption "UCLIBC_HAS_LOCALE" "${dst}"
- CT_KconfigEnableOption "UCLIBC_PREGENERATED_LOCALE_DATA" "${dst}"
- CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA" \
- "${dst}"
- CT_KconfigDeleteOption "UCLIBC_HAS_XLOCALE" "${dst}"
- ;;
- esac
+ CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA" "${dst}"
+ fi
# WCHAR support
if [ "${CT_LIBC_UCLIBC_WCHAR}" = "y" ]; then
@@ -360,6 +231,13 @@ manage_uClibc_config() {
CT_KconfigDisableOption "UCLIBC_HAS_IPV6" "${dst}"
fi
+ # Iconv support
+ if [ "${CT_LIBC_UCLIBC_LIBICONV}" = "y" ]; then
+ CT_KconfigEnableOption "UCLIBC_HAS_LIBICONV" "${dst}"
+ else
+ CT_KconfigDisableOption "UCLIBC_HAS_LIBICONV" "${dst}"
+ fi
+
# Force on options needed for C++ if we'll be making a C++ compiler.
# I'm not sure locales are a requirement for doing C++... Are they?
if [ "${CT_CC_LANG_CXX}" = "y" ]; then
@@ -368,11 +246,14 @@ manage_uClibc_config() {
fi
# Stack Smash Protection (SSP)
- if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then
+ if [ "${CT_LIBC_UCLIBC_HAS_SSP}" = "y" ]; then
CT_KconfigEnableOption "UCLIBC_HAS_SSP" "${dst}"
- CT_KconfigEnableOption "UCLIBC_BUILD_SSP" "${dst}"
else
CT_KconfigDisableOption "UCLIBC_HAS_SSP" "${dst}"
+ fi
+ if [ "${CT_LIBC_UCLIBC_BUILD_SSP}" = "y" ]; then
+ CT_KconfigEnableOption "UCLIBC_BUILD_SSP" "${dst}"
+ else
CT_KconfigDisableOption "UCLIBC_BUILD_SSP" "${dst}"
fi
@@ -381,28 +262,19 @@ manage_uClibc_config() {
CT_KconfigDisableOption "LINUXTHREADS_OLD" "${dst}"
CT_KconfigDisableOption "LINUXTHREADS_NEW" "${dst}"
CT_KconfigDisableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}"
- case "${CT_THREADS}:${CT_LIBC_UCLIBC_LNXTHRD}" in
- none:)
+ case "${CT_THREADS}" in
+ none)
;;
- linuxthreads:)
- # Newer version of uClibc-ng, no old/new dichotomy
+ linuxthreads)
CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}"
CT_KconfigEnableOption "UCLIBC_HAS_LINUXTHREADS" "${dst}"
;;
- linuxthreads:old)
- CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}"
- CT_KconfigEnableOption "LINUXTHREADS_OLD" "${dst}"
- ;;
- linuxthreads:new)
- CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}"
- CT_KconfigEnableOption "LINUXTHREADS_NEW" "${dst}"
- ;;
- nptl:)
+ nptl)
CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}"
CT_KconfigEnableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}"
;;
*)
- CT_Abort "Incorrect thread settings: CT_THREADS='${CT_THREAD}' CT_LIBC_UCLIBC_LNXTHRD='${CT_LIBC_UCLIBC_LNXTHRD}'"
+ CT_Abort "Incorrect thread settings: CT_THREADS='${CT_THREADS}'"
;;
esac
@@ -445,9 +317,14 @@ manage_uClibc_config() {
# Now allow architecture to tweak as it wants
CT_DoArchUClibcConfig "${dst}"
CT_DoArchUClibcCflags "${dst}" "${flags}"
+
+ # Preserve the config we created (before uclibc's `make olddefconfig`
+ # overrides anything).
+ CT_DoExecLog ALL cp "${dst}" "${dst}.created-by-ct-ng"
}
-do_libc_post_cc() {
+uClibc_ng_post_cc()
+{
# uClibc and GCC disagree where the dynamic linker lives. uClibc always
# places it in the MULTILIB_DIR, while gcc does that for *some* variants
# and expects it in /lib for the other. So, create a symlink from lib
@@ -455,51 +332,9 @@ do_libc_post_cc() {
# file in /lib. Thus, need to do this after all the variants are built.
# Moreover, need to do this after the final compiler is built: on targets
# that use elf2flt, the core compilers cannot find ld when running elf2flt.
- CT_DoStep INFO "Checking dynamic linker symlinks"
- CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-post_cc"
- echo "int main(void) { return 0; }" > test-ldso.c
- CT_IterateMultilibs do_libc_ldso_fixup ldso_fixup
- CT_Popd
- CT_EndStep
-}
+ CT_MultilibFixupLDSO
-do_libc_ldso_fixup() {
- local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count
- local binary
- local ldso ldso_f ldso_d multilib_dir
-
- for arg in "$@"; do
- eval "${arg// /\\ }"
- done
-
- CT_DoLog EXTRA "Checking dynamic linker for multilib '${multi_flags}'"
-
- multilib_dir="/lib/${multi_os_dir}"
- CT_SanitizeVarDir multilib_dir
-
- CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -o test-ldso ../test-ldso.c ${multi_flags}
- if [ -r "test-ldso.gdb" ]; then
- binary="test-ldso.gdb"
- else
- binary="test-ldso"
- fi
- if ${CT_TARGET}-readelf -Wl "${binary}" | grep -q 'Requesting program interpreter: '; then
- ldso=$( ${CT_TARGET}-readelf -Wl "${binary}" | \
- grep 'Requesting program interpreter: ' | \
- sed -e 's,.*: ,,' -e 's,\].*,,' )
- fi
- CT_DoLog DEBUG "Detected dynamic linker for multilib '${multi_flags}': '${ldso}'"
-
- ldso_d="${ldso%/ld*.so.*}"
- ldso_f="${ldso##*/}"
- # Create symlink if GCC produced an executable, dynamically linked, it was requesting
- # a linker not in the current directory, and there is no such file in the expected
- # ldso dir.
- if [ -n "${ldso}" -a "${ldso_d}" != "${multilib_dir}" -a ! -r "${multi_root}${ldso}" ]; then
- # Convert ldso_d to "how many levels we need to go up" and remove
- # leading slash.
- ldso_d=$( echo "${ldso_d#/}" | sed 's,[^/]\+,..,g' )
- CT_DoExecLog ALL ln -sf "${ldso_d}${multilib_dir}/${ldso_f}" \
- "${multi_root}${ldso}"
+ if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then
+ CT_InstallConfigurationFile "${CT_LIBC_UCLIBC_CONFIG_FILE}" libc
fi
}
diff --git a/scripts/build/test_suite.sh b/scripts/build/test_suite.sh
index 8fabf42..e963a99 100644
--- a/scripts/build/test_suite.sh
+++ b/scripts/build/test_suite.sh
@@ -7,8 +7,7 @@
CT_TEST_SUITE_FACILITY_LIST=
for f in "${CT_LIB_DIR}/scripts/build/test_suite/"*.sh; do
_f="$(basename "${f}" .sh)"
- __f="CT_TEST_SUITE_${_f}"
- __f=`echo ${__f} | tr "[:lower:]" "[:upper:]"`
+ __f="CT_TEST_SUITE_${_f^^}"
if [ "${!__f}" = "y" ]; then
CT_DoLog DEBUG "Enabling test suite '${_f}'"
. "${f}"
diff --git a/scripts/build/test_suite/gcc.sh b/scripts/build/test_suite/gcc.sh
index c829a43..6c6e5a7 100644
--- a/scripts/build/test_suite/gcc.sh
+++ b/scripts/build/test_suite/gcc.sh
@@ -18,7 +18,7 @@ do_test_suite_gcc_build() {
CT_DoExecLog ALL cp -av "${CT_LIB_DIR}/contrib/gcc-test-suite/default.cfg" \
"${CT_LIB_DIR}/contrib/gcc-test-suite/Makefile" \
"${CT_LIB_DIR}/contrib/gcc-test-suite/README" \
- "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/testsuite" \
+ "${CT_SRC_DIR}/gcc/gcc/testsuite" \
"${CT_TEST_SUITE_DIR}/gcc"
CT_DoExecLog ALL sed -i -r -e "s/@@DG_TARGET@@/${CT_TARGET}/g;" \