Suggested changes for ./build-toolchain.sh --debug

Asked by Joe Gorse on 2013-05-17

Building with ./build-toolchain.sh --debug fails on Mac OS X 10.7 for lack of quotes for multivariable arguments to variables in the following way--

Excepted Build Log:
<...snip>
+ pushd /STM32/devtools/gae-mac-build/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/gcc-final
/STM32/devtools/gae-mac-build/gcc-arm-none-eabi-4_7-2013q1-20130313/build-native/gcc-final /STM32/devtools/gae-mac-build/gcc-arm-none-eabi-4_7-2013q1-20130313/src
+ /STM32/devtools/gae-mac-build/gcc-arm-none-eabi-4_7-2013q1-20130313/src/gcc/configure --target=arm-none-eabi --prefix=/STM32/devtools/gae-mac-build/gcc-arm-none-eabi-4_7-2013q1-20130313/install-native

<...snip...>

+ GCC_FINAL_CFLAGS=
+ '[' 'x -O0 -g ' '!=' xno ']'
+ GCC_FINAL_CFLAGS='CFLAGS= -O0 -g '
+ make -j1 CFLAGS= -O0 -g INHIBIT_LIBC_CFLAGS=-DUSE_TM_CLONE_REGISTRY=0
make: invalid option -- O
make: invalid option -- 0
make: invalid option -- g
Usage: make [options] [target] ...

Suggested change (1) to build-toolchain.sh is from line 61.old to 61, wherein we insert single quotes to explicitly denote the string of build options:
 60 --debug)
 61.old DEBUG_BUILD_OPTIONS=" -O0 -g "
 61 DEBUG_BUILD_OPTIONS="' -O0 -g '"
 62 ;;

Suggested change (2) to build-toolchain.sh is from line 296.o to 296, wherein we again insert single quotes to explicitly denote the string of build options:
295 make -j$JOBS ${GCC_FINAL_CFLAGS} \
296.o INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"
296 INHIBIT_LIBC_CFLAGS="'-DUSE_TM_CLONE_REGISTRY=0'"
297

This appeared to build properly with the '/build-toolchain.sh --debug' command.

Cheers,
Joe

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Joe Gorse
Solved:
2013-05-18
Last query:
2013-05-18
Last reply:
Joe Gorse (jhgorse) said : #1

I apologize, those proposed fixes do not actually work as integrated into the entire script.

Joe Gorse (jhgorse) said : #2

Here is the proper working patch (so far):

/gae-mac-build # diff -u tmp/gcc-arm-none-eabi-4_7-2013q1-20130313-original/build-toolchain.sh gcc-arm-none-eabi-4_7-2013q1-20130313/build-toolchain.sh
--- tmp/gcc-arm-none-eabi-4_7-2013q1-20130313-original/build-toolchain.sh 2013-03-12 14:37:56.000000000 -0400
+++ gcc-arm-none-eabi-4_7-2013q1-20130313/build-toolchain.sh 2013-05-17 13:22:16.000000000 -0400
@@ -285,7 +285,7 @@

 GCC_FINAL_CFLAGS=
 if [ "x$DEBUG_BUILD_OPTIONS" != "xno" ] ; then
- GCC_FINAL_CFLAGS="""CFLAGS=$DEBUG_BUILD_OPTIONS"""
+ GCC_FINAL_CFLAGS="""CFLAGS=\'$DEBUG_BUILD_OPTIONS\'"""
 fi

 # Passing USE_TM_CLONE_REGISTRY=0 via INHIBIT_LIBC_CFLAGS to disable
@@ -293,7 +293,7 @@
 # This is a workaround. Better approach is have a t-* to set this flag via
 # CRTSTUFF_T_CFLAGS
 make -j$JOBS ${GCC_FINAL_CFLAGS} \
- INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"
+ INHIBIT_LIBC_CFLAGS="'-DUSE_TM_CLONE_REGISTRY=0'"

 make install install-html install-pdf

Joe Gorse (jhgorse) said : #3

Apparently the escape mechanisms for echo and bash are not the same. I am testing yet another fix and will post the diff if it actually succeeds on the compile. Cheers.

Joe Gorse (jhgorse) said : #4

I suppose if you can't get Bash to escape correctly when you send the command to make, it's best not to fight it too hard and just get make to expand the variables (putting variable names inside parenths()'s ). So much for Bash.

/devtools/gae-mac-build # diff -u tmp/gcc-arm-none-eabi-4_7-2013q1-20130313-original/build-toolchain.sh gcc-arm-none-eabi-4_7-2013q1-20130313/build-toolchain.sh
--- tmp/gcc-arm-none-eabi-4_7-2013q1-20130313-original/build-toolchain.sh 2013-03-12 14:37:56.000000000 -0400
+++ gcc-arm-none-eabi-4_7-2013q1-20130313/build-toolchain.sh 2013-05-18 10:01:06.000000000 -0400
@@ -128,7 +128,7 @@
     "--with-pkgversion=$PKGVERSION"

 if [ "x$DEBUG_BUILD_OPTIONS" != "xno" ] ; then
- make CFLAGS="-I$BUILDDIR_NATIVE/host-libs/zlib/include $DEBUG_BUILD_OPTIONS" -j$JOBS
+ make CFLAGS='-I$(BUILDDIR_NATIVE)/host-libs/zlib/include $(DEBUG_BUILD_OPTIONS)' -j$JOBS
 else
     make -j$JOBS
 fi
@@ -285,7 +285,7 @@

 GCC_FINAL_CFLAGS=
 if [ "x$DEBUG_BUILD_OPTIONS" != "xno" ] ; then
- GCC_FINAL_CFLAGS="""CFLAGS=$DEBUG_BUILD_OPTIONS"""
+ GCC_FINAL_CFLAGS=CFLAGS='$(DEBUG_BUILD_OPTIONS)'
 fi

 # Passing USE_TM_CLONE_REGISTRY=0 via INHIBIT_LIBC_CFLAGS to disable
@@ -374,7 +374,7 @@
     "--with-pkgversion=$PKGVERSION"

 if [ "x$DEBUG_BUILD_OPTIONS" != "xno" ] ; then
- make CFLAGS="-I$BUILDDIR_NATIVE/host-libs/zlib/include $DEBUG_BUILD_OPTIONS" -j$JOBS
+ make CFLAGS='-I$(BUILDDIR_NATIVE)/host-libs/zlib/include $(DEBUG_BUILD_OPTIONS)' -j$JOBS
 else
     make -j$JOBS
 fi

Terry Guo (terry.guo) said : #5

Thanks Joe. This issue is confirmed and should be fixed in next release.