From 812cc838ebe8bec59831273d5e296f32ade0ffa4 Mon Sep 17 00:00:00 2001 From: Robert Quattlebaum Date: Wed, 29 Mar 2017 13:22:07 -0700 Subject: [PATCH] build: Fixes for cross-compilation. (#1527) This commit includes two changes: * Removes existing `AC_NO_EXECUTABLES` from `configure.ac`, since it is a hack only intended to be used by the GCC project. * Adds a new configure argument: `--enable-no-executables-hack`, which restores `AC_NO_EXECUTABLES` for broken build environemnts which require it. * Removes `--target` from example makefiles, since it is only appropriate when compiling compilers. As a side effect of the second change, cross compiling with the makefiles now no longer causes the `arm-none-eabi-` prefix to be prepended to all built executables. This change updates all of the documentation accordingly. --- .travis/script.sh | 56 +++++++++++++-------------- configure.ac | 35 +++++++++-------- examples/Makefile-cc2538 | 1 - examples/Makefile-cc2650 | 1 - examples/Makefile-da15000 | 1 - examples/Makefile-nrf52840 | 1 - examples/apps/windows/README.md | 2 +- examples/platforms/cc2538/README.md | 2 +- examples/platforms/cc2650/README.md | 4 +- examples/platforms/da15000/README.md | 2 +- examples/platforms/nrf52840/README.md | 4 +- 11 files changed, 54 insertions(+), 55 deletions(-) diff --git a/.travis/script.sh b/.travis/script.sh index 3a431d0fd..794838411 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -54,35 +54,35 @@ set -x git clean -xfd || die ./bootstrap || die COMMISSIONER=1 JOINER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-cc2538 || die - arm-none-eabi-size output/cc2538/bin/arm-none-eabi-ot-cli-ftd || die - arm-none-eabi-size output/cc2538/bin/arm-none-eabi-ot-cli-mtd || die - arm-none-eabi-size output/cc2538/bin/arm-none-eabi-ot-ncp-ftd || die - arm-none-eabi-size output/cc2538/bin/arm-none-eabi-ot-ncp-mtd || die + arm-none-eabi-size output/cc2538/bin/ot-cli-ftd || die + arm-none-eabi-size output/cc2538/bin/ot-cli-mtd || die + arm-none-eabi-size output/cc2538/bin/ot-ncp-ftd || die + arm-none-eabi-size output/cc2538/bin/ot-ncp-mtd || die git checkout -- . || die git clean -xfd || die ./bootstrap || die COMMISSIONER=1 JOINER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-da15000 || die - arm-none-eabi-size output/da15000/bin/arm-none-eabi-ot-cli-ftd || die - arm-none-eabi-size output/da15000/bin/arm-none-eabi-ot-cli-mtd || die - arm-none-eabi-size output/da15000/bin/arm-none-eabi-ot-ncp-ftd || die - arm-none-eabi-size output/da15000/bin/arm-none-eabi-ot-ncp-mtd || die + arm-none-eabi-size output/da15000/bin/ot-cli-ftd || die + arm-none-eabi-size output/da15000/bin/ot-cli-mtd || die + arm-none-eabi-size output/da15000/bin/ot-ncp-ftd || die + arm-none-eabi-size output/da15000/bin/ot-ncp-mtd || die git checkout -- . || die git clean -xfd || die ./bootstrap || die COMMISSIONER=1 JOINER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-nrf52840 || die - arm-none-eabi-size output/nrf52840/bin/arm-none-eabi-ot-cli-ftd || die - arm-none-eabi-size output/nrf52840/bin/arm-none-eabi-ot-cli-mtd || die - arm-none-eabi-size output/nrf52840/bin/arm-none-eabi-ot-ncp-ftd || die - arm-none-eabi-size output/nrf52840/bin/arm-none-eabi-ot-ncp-mtd || die + arm-none-eabi-size output/nrf52840/bin/ot-cli-ftd || die + arm-none-eabi-size output/nrf52840/bin/ot-cli-mtd || die + arm-none-eabi-size output/nrf52840/bin/ot-ncp-ftd || die + arm-none-eabi-size output/nrf52840/bin/ot-ncp-mtd || die git checkout -- . || die git clean -xfd || die ./bootstrap || die make -f examples/Makefile-cc2650 || die - arm-none-eabi-size output/cc2650/bin/arm-none-eabi-ot-cli-mtd || die - arm-none-eabi-size output/cc2650/bin/arm-none-eabi-ot-ncp-mtd || die + arm-none-eabi-size output/cc2650/bin/ot-cli-mtd || die + arm-none-eabi-size output/cc2650/bin/ot-ncp-mtd || die } [ $BUILD_TARGET != arm-gcc54 ] || { @@ -92,35 +92,35 @@ set -x git clean -xfd || die ./bootstrap || die COMMISSIONER=1 JOINER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-cc2538 || die - arm-none-eabi-size output/cc2538/bin/arm-none-eabi-ot-cli-ftd || die - arm-none-eabi-size output/cc2538/bin/arm-none-eabi-ot-cli-mtd || die - arm-none-eabi-size output/cc2538/bin/arm-none-eabi-ot-ncp-ftd || die - arm-none-eabi-size output/cc2538/bin/arm-none-eabi-ot-ncp-mtd || die + arm-none-eabi-size output/cc2538/bin/ot-cli-ftd || die + arm-none-eabi-size output/cc2538/bin/ot-cli-mtd || die + arm-none-eabi-size output/cc2538/bin/ot-ncp-ftd || die + arm-none-eabi-size output/cc2538/bin/ot-ncp-mtd || die git checkout -- . || die git clean -xfd || die ./bootstrap || die COMMISSIONER=1 JOINER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-da15000 || die - arm-none-eabi-size output/da15000/bin/arm-none-eabi-ot-cli-ftd || die - arm-none-eabi-size output/da15000/bin/arm-none-eabi-ot-cli-mtd || die - arm-none-eabi-size output/da15000/bin/arm-none-eabi-ot-ncp-ftd || die - arm-none-eabi-size output/da15000/bin/arm-none-eabi-ot-ncp-mtd || die + arm-none-eabi-size output/da15000/bin/ot-cli-ftd || die + arm-none-eabi-size output/da15000/bin/ot-cli-mtd || die + arm-none-eabi-size output/da15000/bin/ot-ncp-ftd || die + arm-none-eabi-size output/da15000/bin/ot-ncp-mtd || die git checkout -- . || die git clean -xfd || die ./bootstrap || die COMMISSIONER=1 JOINER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-nrf52840 || die - arm-none-eabi-size output/nrf52840/bin/arm-none-eabi-ot-cli-ftd || die - arm-none-eabi-size output/nrf52840/bin/arm-none-eabi-ot-cli-mtd || die - arm-none-eabi-size output/nrf52840/bin/arm-none-eabi-ot-ncp-ftd || die - arm-none-eabi-size output/nrf52840/bin/arm-none-eabi-ot-ncp-mtd || die + arm-none-eabi-size output/nrf52840/bin/ot-cli-ftd || die + arm-none-eabi-size output/nrf52840/bin/ot-cli-mtd || die + arm-none-eabi-size output/nrf52840/bin/ot-ncp-ftd || die + arm-none-eabi-size output/nrf52840/bin/ot-ncp-mtd || die git checkout -- . || die git clean -xfd || die ./bootstrap || die make -f examples/Makefile-cc2650 || die - arm-none-eabi-size output/cc2650/bin/arm-none-eabi-ot-cli-mtd || die - arm-none-eabi-size output/cc2650/bin/arm-none-eabi-ot-ncp-mtd || die + arm-none-eabi-size output/cc2650/bin/ot-cli-mtd || die + arm-none-eabi-size output/cc2650/bin/ot-ncp-mtd || die } [ $BUILD_TARGET != posix ] || { diff --git a/configure.ac b/configure.ac index d14202224..3845f2eea 100644 --- a/configure.ac +++ b/configure.ac @@ -88,11 +88,10 @@ AC_CONFIG_MACRO_DIR([third_party/nlbuild-autotools/repo/autoconf/m4]) AC_CONFIG_HEADERS([include/openthread-config.h]) # -# Figure out what the canonical build, host and target tuples are. +# Figure out what the canonical build and host tuples are. # AC_CANONICAL_BUILD AC_CANONICAL_HOST -AC_CANONICAL_TARGET # # Mac OS X / Darwin ends up putting some versioning cruft on the end of its @@ -102,7 +101,6 @@ AC_CANONICAL_TARGET NL_FILTERED_CANONICAL_BUILD NL_FILTERED_CANONICAL_HOST -NL_FILTERED_CANONICAL_TARGET # # Configure automake with the desired options, indicating that this is not @@ -132,10 +130,10 @@ AM_SILENT_RULES([yes]) AM_MAINTAINER_MODE # -# Check for target +# Host-os-specific checks # -case ${target_os} in +case ${host_os} in *darwin*) OPENTHREAD_TARGET=darwin @@ -161,16 +159,22 @@ AC_SUBST(OPENTHREAD_TARGET_DEFINES) # Checks for build host programs # -# If we are cross-compiling and we are on an embedded target that -# doesn't support independent, standalone executables, then all -# compiler tests that attempt to create an executable will fail. In -# such circumstances, set AC_NO_EXECUTABLES (see http://sourceware.org/ -# ml/newlib/2006/msg00353.html). - +# This is a hack to restore some old broken behavior that was +# removed in pull request #1527. It's use is highly discouraged, +# you should try to fix your build environment instead. +AC_ARG_ENABLE(no-executables-hack, + [AS_HELP_STRING([--enable-no-executables-hack], + [Enable hack that prevents link checks at configure time. Highly discouraged.])]) AC_MSG_CHECKING([whether to disable executable checking]) -if test "$cross_compiling" = yes; then - AC_NO_EXECUTABLES +if test "${enable_no_executables_hack}" = "yes" +then AC_MSG_RESULT([yes]) + AC_NO_EXECUTABLES + # Here we guess conservative values for tests that require link checks + # to test for these features. This will prevent these checks from + # being performed later in the configuration process. + ac_cv_func_strlcat=${ac_cv_func_strlcat-no} + ac_cv_func_strlcpy=${ac_cv_func_strlcpy-no} else AC_MSG_RESULT([no]) fi @@ -1114,9 +1118,8 @@ AC_MSG_NOTICE([ Interface : ${LIBOPENTHREAD_VERSION_INFO//:/.} Build system : ${build} Host system : ${host} - Target system : ${target} - Target architecture : ${target_cpu} - Target OS : ${target_os} + Host architecture : ${host_cpu} + Host OS : ${host_os} Cross compiling : ${cross_compiling} Build shared libraries : ${enable_shared} Build static libraries : ${enable_static} diff --git a/examples/Makefile-cc2538 b/examples/Makefile-cc2538 index 0768052f8..2dc1e1a31 100644 --- a/examples/Makefile-cc2538 +++ b/examples/Makefile-cc2538 @@ -154,7 +154,6 @@ $(ECHO) " CONFIG $(TargetTuple)..." INSTALL="$(INSTALL) $(INSTALLFLAGS)" \ CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \ --host=arm-none-eabi \ ---target=arm-none-eabi \ --prefix=/ \ --exec-prefix=/$(TargetTuple) \ $(configure_OPTIONS)) diff --git a/examples/Makefile-cc2650 b/examples/Makefile-cc2650 index e053a8647..9c7cc5de8 100644 --- a/examples/Makefile-cc2650 +++ b/examples/Makefile-cc2650 @@ -143,7 +143,6 @@ $(ECHO) " CONFIG $(TargetTuple)..." INSTALL="$(INSTALL) $(INSTALLFLAGS)" \ CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \ --host=arm-none-eabi \ ---target=arm-none-eabi \ --prefix=/ \ --exec-prefix=/$(TargetTuple) \ $(configure_OPTIONS)) diff --git a/examples/Makefile-da15000 b/examples/Makefile-da15000 index 96c471148..0cdd6c4dd 100644 --- a/examples/Makefile-da15000 +++ b/examples/Makefile-da15000 @@ -153,7 +153,6 @@ $(ECHO) " CONFIG $(TargetTuple)..." INSTALL="$(INSTALL) $(INSTALLFLAGS)" \ CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \ --host=arm-none-eabi \ ---target=arm-none-eabi \ --prefix=/ \ --exec-prefix=/$(TargetTuple) \ $(configure_OPTIONS)) diff --git a/examples/Makefile-nrf52840 b/examples/Makefile-nrf52840 index dd4b01a40..425aef8e6 100644 --- a/examples/Makefile-nrf52840 +++ b/examples/Makefile-nrf52840 @@ -207,7 +207,6 @@ $(ECHO) " CONFIG $(TargetTuple)..." INSTALL="$(INSTALL) $(INSTALLFLAGS)" \ CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" CCAS="$(CCAS)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CCASFLAGS="$(CCASFLAGS)" LDFLAGS="$(LDFLAGS)" \ --host=arm-none-eabi \ ---target=arm-none-eabi \ --prefix=/ \ --exec-prefix=/$(TargetTuple) \ $(configure_OPTIONS)) diff --git a/examples/apps/windows/README.md b/examples/apps/windows/README.md index e1b3f698b..d3b2e8fd0 100644 --- a/examples/apps/windows/README.md +++ b/examples/apps/windows/README.md @@ -23,4 +23,4 @@ The server listens to the clients. The client sends a message to the server and the server echos that message back to the client. -![Talk Functionality](../../../doc/images/windows-app-talk-client.png) \ No newline at end of file +![Talk Functionality](../../../doc/images/windows-app-talk-client.png) diff --git a/examples/platforms/cc2538/README.md b/examples/platforms/cc2538/README.md index bc45c36ef..5f6d7583b 100644 --- a/examples/platforms/cc2538/README.md +++ b/examples/platforms/cc2538/README.md @@ -28,7 +28,7 @@ After a successful build, the `elf` files are found in `/output/cc2538/bin`. You can convert them to `bin` files using `arm-none-eabi-objcopy`: ```bash -$ arm-none-eabi-objcopy -O binary arm-none-eabi-ot-cli-ftd arm-none-eabi-ot-cli-ftd.bin +$ arm-none-eabi-objcopy -O binary ot-cli-ftd ot-cli-ftd.bin ``` ## Flash Binaries diff --git a/examples/platforms/cc2650/README.md b/examples/platforms/cc2650/README.md index 9d28e9991..97d9d0154 100644 --- a/examples/platforms/cc2650/README.md +++ b/examples/platforms/cc2650/README.md @@ -67,14 +67,14 @@ To flash the images with [Flash Programmer 2][ti-flash-programmer-2], the files must have the `*.elf` extension. ```bash $ cd /output/cc2650/bin -$ cp arm-none-eabi-ot-cli arm-none-eabi-ot-cli.elf +$ cp ot-cli ot-cli.elf ``` To load the images with the [serial bootloader][ti-cc2650-bootloader], the images must be converted to `bin`. This is done using `arm-none-eabi-objcopy` ```bash $ cd /output/cc2650/bin -$ arm-none-eabi-objcopy -O binary arm-none-eabi-ot-cli arm-none-eabi-ot-cli.bin +$ arm-none-eabi-objcopy -O binary ot-cli ot-cli.bin ``` The [cc2538-bsl.py script][cc2538-bsl-tool] provides a convenient method for flashing a CC2650 via the UART. diff --git a/examples/platforms/da15000/README.md b/examples/platforms/da15000/README.md index f79987464..a86158db7 100755 --- a/examples/platforms/da15000/README.md +++ b/examples/platforms/da15000/README.md @@ -38,7 +38,7 @@ Flash Binaries: 2. Return to previous terminal window and execute a command in order to flash the board: ```bash - $ ./cli_programmer gdbserver write_qspi_exec ../../../output/da15000/bin/arm-none-eabi-ot-cli-ftd.bin + $ ./cli_programmer gdbserver write_qspi_exec ../../../output/da15000/bin/ot-cli-ftd.bin ``` ## Interact: diff --git a/examples/platforms/nrf52840/README.md b/examples/platforms/nrf52840/README.md index 0ec2a7dae..e6187222c 100644 --- a/examples/platforms/nrf52840/README.md +++ b/examples/platforms/nrf52840/README.md @@ -26,7 +26,7 @@ After a successful build, the `elf` files can be found in `/output/nrf52840/bin`. You can convert them to `hex` files using `arm-none-eabi-objcopy`: ```bash -$ arm-none-eabi-objcopy -O ihex arm-none-eabi-ot-cli-ftd arm-none-eabi-ot-cli-ftd.hex +$ arm-none-eabi-objcopy -O ihex ot-cli-ftd ot-cli-ftd.hex ``` ## Flashing the binaries @@ -37,7 +37,7 @@ part of the [nRF5x Command Line Tools][nRF5x-Command-Line-Tools]. [nRF5x-Command-Line-Tools]: https://www.nordicsemi.com/eng/Products/nRF52840#Downloads ```bash -$ nrfjprog -f nrf52 --chiperase --program output/nrf52840/bin/arm-none-eabi-ot-cli-ftd.hex +$ nrfjprog -f nrf52 --chiperase --program output/nrf52840/bin/ot-cli-ftd.hex $ nrfjprog -f nrf52 -r ```