bazza
Posts: 19
Joined: Thu Apr 17, 2014 8:26 am

GCC 6 Cross Compiler

Fri Mar 09, 2018 8:17 pm

Does anyone know of where there is a prebuilt gcc-6 cross compiler toolchain.

I have found (after a while away) that gcc-4xx no longer generates code that will link against the current libraries in Raspbian Stretch.

Thanks

LdB
Posts: 1006
Joined: Wed Dec 07, 2016 2:29 pm

Re: GCC 6 Cross Compiler

Sat Mar 10, 2018 1:10 am

The official arm toolchain has mac, windows & 64 bit linux cross versions
https://developer.arm.com/open-source/g ... /downloads

You didn't say which O/S you wanted the cross from :-)

bazza
Posts: 19
Joined: Thu Apr 17, 2014 8:26 am

Re: GCC 6 Cross Compiler

Sat Mar 10, 2018 11:17 am

Thanks. I also found crosstools-ng has a RPi3 configuration for gcc-6. Built OK.

qsrc
Posts: 6
Joined: Tue Oct 04, 2016 8:39 pm

Re: GCC 6 Cross Compiler

Wed Oct 03, 2018 10:34 pm

Note that the "official ARM toolchain" pointed to by @LdB is for bare-metal applications (arm-none-eabi).

Linaro provides pre-built cross-compilation toolchain releases for Linux targets (armv8l-linux-gnueabihf) here:
https://www.linaro.org/latest/downloads/

jblumenkamp
Posts: 5
Joined: Sat Aug 11, 2018 11:46 am

Re: GCC 6 Cross Compiler

Sun Feb 10, 2019 1:01 pm

Hi,

I also want to cross compile and since I need some C++14 features the cross compiler provided here is not working.

I have downloaded gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz as well as sysroot-glibc-linaro-2.23-2017.05-arm-linux-gnueabihf.tar.xz from here and I created the following testing project:

main.cpp:

Code: Select all

#include <iostream>
int main()
{
  std::cout << "Hello world" << std::endl;
}
CMakeLists.txt:

Code: Select all

cmake_minimum_required(VERSION 3.0)
project(test)
set(CMAKE_CXX_STANDARD 14)
add_executable(run main.cpp)
Toolchain.cmake:
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)

SET(CMAKE_C_COMPILER /home/[...]/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /home/[...]/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-c++)

SET(CMAKE_FIND_ROOT_PATH /home/[...]/sysroot-glibc-linaro-2.23-2017.05-arm-linux-gnueabihf)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
If I now call

Code: Select all

cmake .. -DCMAKE_TOOLCHAIN_FILE=../../../cross_compile/cpp14/6.3/Toolchain-rpi_cpp14.cmake -DCMAKE_BUILD_TYPE=Debug && make
and execute the generated binary on a Raspberry Pi Zero, I receive a Segmentation fault. GDB shows me that it occurs already before the actual application starts:

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
0x0005f9d2 in ?? ()
(gdb) bt
#0  0x0005f9d2 in ?? ()
#1  0x0001081e in _start () at ../sysdeps/arm/start.S:113
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
So, what is the problem? Have I selected the wrong cross compiler?

Best,
Jan

swampdog
Posts: 164
Joined: Fri Dec 04, 2015 11:22 am

Re: GCC 6 Cross Compiler

Wed Feb 13, 2019 6:43 pm

I can't help much except to say I built gcc-6.3.0 some time ago using the following crosstools-ng (1.23.0) ".config"..

Code: Select all

CT_CONFIGURE_has_static_link=y
CT_CONFIGURE_has_wget=y
CT_CONFIGURE_has_curl=y
CT_CONFIGURE_has_stat_flavor_GNU=y
CT_CONFIGURE_has_libtool_2_4_or_newer=y
CT_CONFIGURE_has_libtoolize_2_4_or_newer=y
CT_CONFIGURE_has_autoconf_2_63_or_newer=y
CT_CONFIGURE_has_autoreconf_2_63_or_newer=y
CT_CONFIGURE_has_automake_1_15_or_newer=y
CT_CONFIGURE_has_gnu_m4_1_4_12_or_newer=y
CT_CONFIGURE_has_svn=y
CT_CONFIGURE_has_git=y
CT_MODULES=y



CT_LOCAL_TARBALLS_DIR="${HOME}/usr/src/pi/pkg"
CT_SAVE_TARBALLS=y
CT_WORK_DIR="${CT_TOP_DIR}/.build"
CT_BUILD_TOP_DIR="${CT_WORK_DIR}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}"
CT_PREFIX_DIR="/usr/local/RPI/${CT_TARGET}"
CT_RM_RF_PREFIX_DIR=y
CT_REMOVE_DOCS=y
CT_PREFIX_DIR_RO=y
CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES=y

CT_DOWNLOAD_AGENT_WGET=y
CT_CONNECT_TIMEOUT=10
CT_DOWNLOAD_WGET_OPTIONS="--passive-ftp --tries=3 -nc --progress=dot:binary"

CT_OVERRIDE_CONFIG_GUESS_SUB=y
CT_PATCH_BUNDLED=y
CT_PATCH_ORDER="bundled"

CT_PARALLEL_JOBS=0
CT_LOAD=""
CT_USE_PIPES=y
CT_EXTRA_CFLAGS_FOR_BUILD=""
CT_EXTRA_LDFLAGS_FOR_BUILD=""
CT_EXTRA_CFLAGS_FOR_HOST=""
CT_EXTRA_LDFLAGS_FOR_HOST=""
CT_CONFIG_SHELL_BASH=y
CT_CONFIG_SHELL="${bash}"

CT_LOG_EXTRA=y
CT_LOG_LEVEL_MAX="EXTRA"
CT_LOG_PROGRESS_BAR=y
CT_LOG_TO_FILE=y
CT_LOG_FILE_COMPRESS=y

CT_ARCH="arm"
CT_ARCH_arm=y
CT_ARCH_alpha_AVAILABLE=y
CT_ARCH_arm_AVAILABLE=y
CT_ARCH_avr_AVAILABLE=y
CT_ARCH_m68k_AVAILABLE=y
CT_ARCH_microblaze_AVAILABLE=y
CT_ARCH_mips_AVAILABLE=y
CT_ARCH_nios2_AVAILABLE=y
CT_ARCH_powerpc_AVAILABLE=y
CT_ARCH_s390_AVAILABLE=y
CT_ARCH_sh_AVAILABLE=y
CT_ARCH_sparc_AVAILABLE=y
CT_ARCH_x86_AVAILABLE=y
CT_ARCH_xtensa_AVAILABLE=y
CT_ARCH_SUFFIX="v6"

CT_DEMULTILIB=y
CT_ARCH_SUPPORTS_BOTH_MMU=y
CT_ARCH_DEFAULT_HAS_MMU=y
CT_ARCH_USE_MMU=y
CT_ARCH_SUPPORTS_BOTH_ENDIAN=y
CT_ARCH_DEFAULT_LE=y
CT_ARCH_LE=y
CT_ARCH_ENDIAN="little"
CT_ARCH_SUPPORTS_32=y
CT_ARCH_SUPPORTS_64=y
CT_ARCH_DEFAULT_32=y
CT_ARCH_BITNESS=32
CT_ARCH_32=y

CT_ARCH_SUPPORTS_WITH_ARCH=y
CT_ARCH_SUPPORTS_WITH_CPU=y
CT_ARCH_SUPPORTS_WITH_TUNE=y
CT_ARCH_SUPPORTS_WITH_FLOAT=y
CT_ARCH_SUPPORTS_WITH_FPU=y
CT_ARCH_SUPPORTS_SOFTFP=y
CT_ARCH_EXCLUSIVE_WITH_CPU=y
CT_ARCH_ARCH="armv6"
CT_ARCH_CPU=""
CT_ARCH_TUNE=""
CT_ARCH_FPU=""
CT_ARCH_FLOAT_HW=y
CT_TARGET_CFLAGS=""
CT_TARGET_LDFLAGS=""
CT_ARCH_FLOAT="hard"

CT_ARCH_ARM_MODE="arm"
CT_ARCH_ARM_MODE_ARM=y
CT_ARCH_ARM_EABI_FORCE=y
CT_ARCH_ARM_EABI=y
CT_ARCH_ARM_TUPLE_USE_EABIHF=y


CT_FORCE_SYSROOT=y
CT_USE_SYSROOT=y
CT_SYSROOT_NAME="sysroot"
CT_SYSROOT_DIR_PREFIX=""
CT_WANTS_STATIC_LINK=y
CT_WANTS_STATIC_LINK_CXX=y
CT_TOOLCHAIN_PKGVERSION=""
CT_TOOLCHAIN_BUGURL=""

CT_TARGET_VENDOR="rpi"
CT_TARGET_ALIAS_SED_EXPR=""
CT_TARGET_ALIAS="arm-linux-gnueabihf"

CT_CROSS=y
CT_TOOLCHAIN_TYPE="cross"

CT_BUILD=""
CT_BUILD_PREFIX=""
CT_BUILD_SUFFIX=""


CT_KERNEL_SUPPORTS_SHARED_LIBS=y
CT_KERNEL="linux"
CT_KERNEL_VERSION="4.10.8"
CT_KERNEL_linux=y
CT_KERNEL_bare_metal_AVAILABLE=y
CT_KERNEL_linux_AVAILABLE=y
CT_KERNEL_V_4_10=y
CT_KERNEL_windows_AVAILABLE=y

CT_SHARED_LIBS=y

CT_KERNEL_LINUX_VERBOSITY_0=y
CT_KERNEL_LINUX_VERBOSE_LEVEL=0
CT_KERNEL_LINUX_INSTALL_CHECK=y

CT_ARCH_BINFMT_ELF=y
CT_BINUTILS="binutils"
CT_BINUTILS_binutils=y

CT_BINUTILS_VERSION="2.28"
CT_BINUTILS_V_2_28=y
CT_BINUTILS_2_27_or_later=y
CT_BINUTILS_2_26_or_later=y
CT_BINUTILS_2_25_1_or_later=y
CT_BINUTILS_2_25_or_later=y
CT_BINUTILS_2_24_or_later=y
CT_BINUTILS_2_23_2_or_later=y
CT_BINUTILS_HAS_HASH_STYLE=y
CT_BINUTILS_HAS_GOLD=y
CT_BINUTILS_GOLD_SUPPORTS_ARCH=y
CT_BINUTILS_GOLD_SUPPORT=y
CT_BINUTILS_HAS_PLUGINS=y
CT_BINUTILS_HAS_PKGVERSION_BUGURL=y
CT_BINUTILS_FORCE_LD_BFD_DEFAULT=y
CT_BINUTILS_LINKER_LD=y
CT_BINUTILS_LINKERS_LIST="ld"
CT_BINUTILS_LINKER_DEFAULT="bfd"
CT_BINUTILS_EXTRA_CONFIG_ARRAY=""


CT_LIBC="glibc"
CT_LIBC_VERSION="2.25"
CT_LIBC_glibc=y
CT_LIBC_avr_libc_AVAILABLE=y
CT_LIBC_glibc_AVAILABLE=y
CT_THREADS="nptl"
CT_LIBC_GLIBC_V_2_25=y
CT_LIBC_GLIBC_2_23_or_later=y
CT_LIBC_GLIBC_2_20_or_later=y
CT_LIBC_GLIBC_2_17_or_later=y
CT_LIBC_mingw_AVAILABLE=y
CT_LIBC_musl_AVAILABLE=y
CT_LIBC_newlib_AVAILABLE=y
CT_LIBC_none_AVAILABLE=y
CT_LIBC_uClibc_AVAILABLE=y
CT_LIBC_SUPPORT_THREADS_ANY=y
CT_LIBC_SUPPORT_THREADS_NATIVE=y

CT_THREADS_NATIVE=y
CT_LIBC_XLDD=y

CT_LIBC_GLIBC_NEEDS_PORTS=y
CT_LIBC_glibc_family=y
CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY=""
CT_LIBC_GLIBC_CONFIGPARMS=""
CT_LIBC_GLIBC_EXTRA_CFLAGS=""
CT_LIBC_OLDEST_ABI=""
CT_LIBC_GLIBC_FORCE_UNWIND=y
CT_LIBC_ADDONS_LIST=""
CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS=y
CT_LIBC_GLIBC_MIN_KERNEL="4.10.8"

CT_CC="gcc"
CT_CC_CORE_PASSES_NEEDED=y
CT_CC_CORE_PASS_1_NEEDED=y
CT_CC_CORE_PASS_2_NEEDED=y
CT_CC_gcc=y
CT_CC_GCC_VERSION="6.3.0"
CT_CC_GCC_V_6_3_0=y
CT_CC_GCC_4_8_or_later=y
CT_CC_GCC_4_9_or_later=y
CT_CC_GCC_5_or_later=y
CT_CC_GCC_6=y
CT_CC_GCC_6_or_later=y
CT_CC_GCC_HAS_LIBMPX=y
CT_CC_GCC_ENABLE_CXX_FLAGS=""
CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY=""
CT_CC_GCC_EXTRA_CONFIG_ARRAY=""
CT_CC_GCC_STATIC_LIBSTDCXX=y
CT_CC_GCC_CONFIG_TLS=m

CT_CC_GCC_USE_GRAPHITE=y
CT_CC_GCC_USE_LTO=y

CT_CC_GCC_ENABLE_TARGET_OPTSPACE=y

CT_CC_CXA_ATEXIT=y
CT_CC_GCC_SJLJ_EXCEPTIONS=m
CT_CC_GCC_LDBL_128=m
CT_CC_GCC_LNK_HASH_STYLE_DEFAULT=y
CT_CC_GCC_LNK_HASH_STYLE=""
CT_CC_GCC_DEC_FLOAT_AUTO=y
CT_CC_SUPPORT_CXX=y
CT_CC_SUPPORT_FORTRAN=y
CT_CC_SUPPORT_JAVA=y
CT_CC_SUPPORT_ADA=y
CT_CC_SUPPORT_OBJC=y
CT_CC_SUPPORT_OBJCXX=y
CT_CC_SUPPORT_GOLANG=y

CT_CC_LANG_CXX=y


CT_COMPLIBS_NEEDED=y
CT_LIBICONV_NEEDED=y
CT_GETTEXT_NEEDED=y
CT_GMP_NEEDED=y
CT_MPFR_NEEDED=y
CT_ISL_NEEDED=y
CT_MPC_NEEDED=y
CT_NCURSES_NEEDED=y
CT_COMPLIBS=y
CT_LIBICONV=y
CT_GETTEXT=y
CT_GMP=y
CT_MPFR=y
CT_ISL=y
CT_MPC=y
CT_NCURSES=y
CT_LIBICONV_V_1_15=y
CT_LIBICONV_VERSION="1.15"
CT_GETTEXT_V_0_19_8_1=y
CT_GETTEXT_VERSION="0.19.8.1"
CT_GMP_V_6_1_2=y
CT_GMP_5_0_2_or_later=y
CT_GMP_VERSION="6.1.2"
CT_MPFR_V_3_1_5=y
CT_MPFR_VERSION="3.1.5"
CT_ISL_V_0_16_1=y
CT_ISL_V_0_16_or_later=y
CT_ISL_V_0_15_or_later=y
CT_ISL_V_0_14_or_later=y
CT_ISL_V_0_12_or_later=y
CT_ISL_VERSION="0.16.1"
CT_MPC_V_1_0_3=y
CT_MPC_VERSION="1.0.3"
CT_NCURSES_V_6_0=y
CT_NCURSES_VERSION="6.0"
CT_NCURSES_HOST_CONFIG_ARGS=""
CT_NCURSES_HOST_DISABLE_DB=y
CT_NCURSES_HOST_FALLBACKS="linux,xterm,xterm-color,xterm-256color,vt100"
CT_NCURSES_TARGET_CONFIG_ARGS=""
CT_NCURSES_TARGET_FALLBACKS=""


CT_COMP_TOOLS_automake=y
CT_AUTOMAKE_V_1_15=y
CT_AUTOMAKE_VERSION="1.15"
CT_COMP_TOOLS_make=y
CT_MAKE_V_4_2_1=y
CT_MAKE_VERSION="4.2.1"
..on linux mint which resulted in this "g++ -v"..

Code: Select all

Using built-in specs.
COLLECT_GCC=armv6-rpi-linux-gnueabihf-g++
COLLECT_LTO_WRAPPER=/usr/local/RPI/armv6-rpi-linux-gnueabihf/libexec/gcc/armv6-rpi-linux-gnueabihf/6.3.0/lto-wrapper
Target: armv6-rpi-linux-gnueabihf
Configured with: /home/foo/usr/src/pi/ctng/.build/src/gcc-6.3.0/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=armv6-rpi-linux-gnueabihf --prefix=/usr/local/RPI/armv6-rpi-linux-gnueabihf --with-sysroot=/usr/local/RPI/armv6-rpi-linux-gnueabihf/armv6-rpi-linux-gnueabihf/sysroot --enable-languages=c,c++ --with-arch=armv6 --with-float=hard --with-pkgversion='crosstool-NG crosstool-ng-1.23.0' --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --disable-libmpx --with-gmp=/home/foo/usr/src/pi/ctng/.build/armv6-rpi-linux-gnueabihf/buildtools --with-mpfr=/home/foo/usr/src/pi/ctng/.build/armv6-rpi-linux-gnueabihf/buildtools --with-mpc=/home/foo/usr/src/pi/ctng/.build/armv6-rpi-linux-gnueabihf/buildtools --with-isl=/home/foo/usr/src/pi/ctng/.build/armv6-rpi-linux-gnueabihf/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --disable-plugin --disable-nls --disable-multilib --with-local-prefix=/usr/local/RPI/armv6-rpi-linux-gnueabihf/armv6-rpi-linux-gnueabihf/sysroot --enable-long-long
Thread model: posix
gcc version 6.3.0 (crosstool-NG crosstool-ng-1.23.0)
..which I just used for a 'cout<<"Hello World"' test which ran on an rpi zero. Attributes for the cross built binary are "readelf -A"..

Code: Select all

Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "6"
  Tag_CPU_arch: v6
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_FP_arch: VFPv2
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_rounding: Needed
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6
I'll have to leave it to you to decide if the above is useful. It's as far as I got with the project but one further point. For some reason I used gcc-4.9.4 to bootstrap the whole thing..

Code: Select all

#!/bin/sh

NAM=`basename "$0"`

PTH=/usr/local/crosstool/bin:/usr/local/GCC/4.9.4/bin
LDP="/usr/local/GCC/4.9.2/lib64:/usr/local/GCC/4.9.4/lib"

fcp_usage ()
{
cat<<EOF
${NAM}: [ --help | -h ]
${NAM}: [ cfg ]
${NAM}: [ mak ]
EOF
}

fcp_cfg ()
{
 PATH="$PTH":"$PATH" \
 ct-ng menuconfig
}

# LD_LIBRARY_PATH="$LDP":"$LD_LIBRARY_PATH" \
fcp_mak ()
{
 PATH="$PTH":"$PATH" \
 ct-ng build
}

case "$1" in
	--help | -h)
	fcp_usage
	exit 0
	;;

	cfg)
	fcp_cfg
	;;

	mak)
	fcp_mak
	;;

	*)
	fcp_usage
	exit 1
	;;
esac
..can't remember why!

Return to “C/C++”