From 5a3da5ef50a5ccfc5888d82585e5f153c66a4da5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 24 Jan 2020 08:12:20 -0600 Subject: [PATCH] tools/testbuild.sh: Restore ability to select type of new and delete operators This capability was erroneously removed by a previous commit. This setting is necessary when the C++ code generated by the compiler uses the new and delete operators provided in libs/libxx. Here is an example of an error scenario where this capability is required: 1. CONFIG_CXX_NEWLONG=y in the defconfig file 2. This causes libs/libxx to to generate a delete operator of this form: void delete(void*, unsigned long); 3. But the compiler expects to link with a delete operator of this form: void delete(void*, unsigned int); That results in a link-time failure and the ONLY solution for avoiding that link time failure (short of some complete redesign) is to have a control over the CONFIG_CXX_NEWLONG setting and make sture that it is always disabled for that toolchain. Other toolchains will require that CONFIG_CXX_NEWLONG=y in all cases. This cannot be predicted because it is dependndent on the definitions provided by C libraries and header files that were build into binary toolchain. --- tools/testbuild.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/testbuild.sh b/tools/testbuild.sh index 58f5ddefa5e..59b02186086 100755 --- a/tools/testbuild.sh +++ b/tools/testbuild.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # tools/testbuild.sh # -# Copyright (C) 2016-2019 Gregory Nutt. All rights reserved. +# Copyright (C) 2016-2020 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -37,6 +37,7 @@ nuttx=$WD/../nuttx progname=$0 fail=0 +sizet=default APPSDIR=../apps MAKE_FLAGS=-k MAKE=make @@ -46,16 +47,22 @@ unset JOPTION function showusage { echo "" - echo "USAGE: $progname [-l|m|c|u|g|n] [-d] [-x] [-j ] [-a ] [-t ] " + echo "USAGE: $progname [-l|m|c|u|g|n] [-si|-sl>] [-d] [-x] [-j ] [-a ] [-t ] " echo " $progname -h" echo "" echo "Where:" echo " -l|m|c|u|g|n selects Linux (l), macOS (m), Cygwin (c)," echo " Ubuntu under Windows 10 (u), MSYS/MSYS2 (g) or Windows native (n). Default Linux" + echo " -si|-sl selected the type of size_t used within the compiler. This necessary because" + echo " the compiler will generate calls to new and delete operators using its internal" + echo " understanding which must match the usage in libs/libxx. -si indicates that the" + echo " underlying size_t is 'unsigned int'; -sl indicates unsigned long. Default: Use" + echo " the setting from the defconfig file." echo " -d enables script debug output" echo " -x exit on build failures" echo " -j passed on to make. Default: No -j make option." echo " -a provides the relative path to the apps/ directory. Default ../apps" + echo " -u" echo " -t provides the absolute path to top nuttx/ directory. Default $PWD/../nuttx" echo " -h will show this help test and terminate" echo " selects the list of configurations to test. No default" @@ -88,6 +95,12 @@ while [ ! -z "$1" ]; do shift JOPTION="-j $1" ;; + -si ) + sizet=uint + ;; + -sl ) + sizet=ulong + ;; -t ) shift nuttx="$1" @@ -159,6 +172,13 @@ function configure { sed -i -e "/$varname/d" $nuttx/.config fi + if [ "X$sizet" != "Xdefault" ]; then + sed -i -e "/CONFIG_CXX_NEWLONG/d" $nuttx/.config + if [ "X$sizet" == "Xulong" ]; then + sed -i -e "\$aCONFIG_CXX_NEWLONG=y" $nuttx/.config + fi + fi + echo " Enabling $toolchain" echo "$toolchain=y" >> $nuttx/.config