Skip to contentSkip to conversation

configure: Use strings command from cross development tools

PATCH In review Stefan Weil 5 participants 6 messages May 13, 2018 – May 15, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: Use strings command from cross development tools

This fixes cross builds for the (rare) case where cross binutils but no native binutils are installed.

---
 configure | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
configure +3 -2
index 24c411e346..4f6ace1ed4 100755
@@ -517,6 +517,7 @@ objcopy="${OBJCOPY-${cross_prefix}objcopy}"
 ld="${LD-${cross_prefix}ld}"
 ranlib="${RANLIB-${cross_prefix}ranlib}"
 nm="${NM-${cross_prefix}nm}"
+strings="${STRINGS-${cross_prefix}strings}"
 strip="${STRIP-${cross_prefix}strip}"
 windres="${WINDRES-${cross_prefix}windres}"
 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
@@ -1956,9 +1957,9 @@ int main(int argc, char *argv[]) {
 EOF
 
 if compile_object ; then
-    if strings -a $TMPO | grep -q BiGeNdIaN ; then
+    if "$strings" -a $TMPO | grep -q BiGeNdIaN ; then
         bigendian="yes"
-    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
+    elif "$strings" -a $TMPO | grep -q LiTtLeEnDiAn ; then
         bigendian="no"
     else
         echo big/little test failed
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Stefan Weil

This fixes cross builds for the (rare) case where cross binutils but no native binutils are installed.

Quoted 29 lines
---
 configure | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
configure +3 -2
index 24c411e346..4f6ace1ed4 100755
@@ -517,6 +517,7 @@ objcopy="${OBJCOPY-${cross_prefix}objcopy}"
 ld="${LD-${cross_prefix}ld}"
 ranlib="${RANLIB-${cross_prefix}ranlib}"
 nm="${NM-${cross_prefix}nm}"
+strings="${STRINGS-${cross_prefix}strings}"
 strip="${STRIP-${cross_prefix}strip}"
 windres="${WINDRES-${cross_prefix}windres}"
 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
@@ -1956,9 +1957,9 @@ int main(int argc, char *argv[]) {
 EOF
 
 if compile_object ; then
-    if strings -a $TMPO | grep -q BiGeNdIaN ; then
+    if "$strings" -a $TMPO | grep -q BiGeNdIaN ; then
         bigendian="yes"
-    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
+    elif "$strings" -a $TMPO | grep -q LiTtLeEnDiAn ; then
         bigendian="no"
     else
         echo big/little test failed
#3 lore raw
In reply to Stefan Weil
Quoted 11 lines · Stefan Weil

This fixes cross builds for the (rare) case where cross binutils but no native binutils are installed.

---
  configure | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

+strings="${STRINGS-${cross_prefix}strings}"
strip="${STRIP-${cross_prefix}strip}"

Hmm - we have pre-existing problems in our configure file. More on that below...

configure int main(int argc, char *argv[]) { · line 1960

Quoted 8 lines
  windres="${WINDRES-${cross_prefix}windres}"
  pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
configure +1 -1
@@ -1956,9 +1957,9 @@ int main(int argc, char *argv[]) {
  EOF
 
  if compile_object ; then
-    if strings -a $TMPO | grep -q BiGeNdIaN ; then
+    if "$strings" -a $TMPO | grep -q BiGeNdIaN ; then

I'd much prefer this to be:

if $strings -a $TMPO | grep...

That's because if I have something like this in my environment:

STRINGS='/path/to/strings -a'

it will only work if you allow word splitting on my variable.

...having said that, here's the pre-existing problem with user replacement tools that contain whitespace:

if test "$strip_opt" = "yes" ; then
echo "STRIP=${strip}" >> $config_host_mak
fi

we are improperly quoting the whitespace when populating $config_host_mak, and therefore could end up attempting to execute the user's first argument as a standalone command, rather than the intended result of assigning a two-word command to a single variable.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#4 lore raw
Quoted 29 lines · Eric Blake
Quoted 4 lines · Stefan Weil

This fixes cross builds for the (rare) case where cross binutils but no native binutils are installed.

Quoted 8 lines
---
  configure | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

+strings="${STRINGS-${cross_prefix}strings}"
strip="${STRIP-${cross_prefix}strip}"

Hmm - we have pre-existing problems in our configure file. More on that below...

configure int main(int argc, char *argv[]) { · line 1959

Quoted 7 lines
  windres="${WINDRES-${cross_prefix}windres}"
  pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
configure +1 -1
@@ -1956,9 +1957,9 @@ int main(int argc, char *argv[]) {
  EOF
    if compile_object ; then
-    if strings -a $TMPO | grep -q BiGeNdIaN ; then
+    if "$strings" -a $TMPO | grep -q BiGeNdIaN ; then

I'd much prefer this to be:

Quoted 7 lines

if $strings -a $TMPO | grep...

That's because if I have something like this in my environment:

STRINGS='/path/to/strings -a'

it will only work if you allow word splitting on my variable.

Conversely, if I have STRINGS='/path with spaces/to/strings' in my environment it will only work if you don't do word splitting on it :-)

thanks
-- PMM

#5 lore raw
Quoted 6 lines · Peter Maydell
Quoted 6 lines

I'd much prefer this to be:

if $strings -a $TMPO | grep...

That's because if I have something like this in my environment:

Quoted 7 lines
Quoted 3 lines

STRINGS='/path/to/strings -a'

it will only work if you allow word splitting on my variable.

Conversely, if I have STRINGS='/path with spaces/to/strings' in my environment it will only work if you don't do word splitting on it :-)

Make convention has long been that /path with spaces/ is unacceptable for any of the typical tool replacements, and that you always perform unquoted (and thus word splitting) of a tool name. My most common example is EDITOR='emacs -nw'. You can always add a symlink to a tool from a path without spaces, if you want to provide a tool override to something that normally lives somewhere with spaces.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org