You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/01/24 14:21:25 UTC

[incubator-nuttx] branch pr159 updated: tools/testbuild.sh: Restore ability to select type of new and delete operators

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch pr159
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/pr159 by this push:
     new 5a3da5e  tools/testbuild.sh:  Restore ability to select type of new and delete operators
5a3da5e is described below

commit 5a3da5ef50a5ccfc5888d82585e5f153c66a4da5
Author: Gregory Nutt <gn...@nuttx.org>
AuthorDate: Fri Jan 24 08:12:20 2020 -0600

    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 58f5dde..59b0218 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 <gn...@nuttx.org>
 #
 # 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 <ncpus>] [-a <appsdir>] [-t <topdir>] <testlist-file>"
+  echo "USAGE: $progname [-l|m|c|u|g|n] [-si|-sl>] [-d] [-x] [-j <ncpus>] [-a <appsdir>] [-t <topdir>] <testlist-file>"
   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 <ncpus> passed on to make.  Default:  No -j make option."
   echo "  -a <appsdir> provides the relative path to the apps/ directory.  Default ../apps"
+  echo "  -u<l|i>"
   echo "  -t <topdir> provides the absolute path to top nuttx/ directory.  Default $PWD/../nuttx"
   echo "  -h will show this help test and terminate"
   echo "  <testlist-file> 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