123elf icon indicating copy to clipboard operation
123elf copied to clipboard

binutils.sh throws an error if path to directory contains a blank

Open roboklon opened this issue 2 years ago • 3 comments

binutils.sh fails, if the path to the directory contains a blank.

Example: Compiling binutils in this directory fails: /home/user/Documents/My Documents/123elf

Compiling binutils in this directory works for me (on the same system, Debian Bullseye 11): /home/user/Documents/123elf

roboklon avatar May 31 '22 10:05 roboklon

What's the error? This issue can come from unquoted variables, but I don't see any in the script. Unless the problem is in the binutils tarball from GNU which will be hard to track down without a specific error message.

dtwilliamson avatar May 31 '22 12:05 dtwilliamson

Hmm, that's unfortunate - I just confirmed that binutils can't be built in a directory with a space.

I guess we could mktemp -d -p /tmp or whatever.

@roboklon Is this using WSL2? Another user told me they had to use the "short path", like cd /mnt/c/Documents/mydocu~1/123elf, but I didn't understand it was because of the space until your report.

taviso avatar May 31 '22 14:05 taviso

The bug is upstream, in the binutils Makefile. Shell scripts used to configure sub-components use unqoted variables. Example:

.PHONY: configure-zlib maybe-configure-zlib
maybe-configure-zlib:
maybe-configure-zlib: configure-zlib
configure-zlib: 
	@r=`${PWD_COMMAND}`; export r; \
	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
	test ! -f $(HOST_SUBDIR)/zlib/Makefile || exit 0; \
	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/zlib; \
	$(HOST_EXPORTS)  \
	echo Configuring in $(HOST_SUBDIR)/zlib; \
	cd "$(HOST_SUBDIR)/zlib" || exit 1; \
	case $(srcdir) in \
	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
	  *) topdir=`echo $(HOST_SUBDIR)/zlib/ | \
		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
	esac; \
	module_srcdir=zlib; \
	$(SHELL) \
	  $$s/$$module_srcdir/configure \
	  --srcdir=$${topdir}/$$module_srcdir \
	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
	  --target=${target_alias}  \
	  || exit 1

You can see e.g. unquoted $(srcdir) etc.

This bug should be reported (and eventually fixed) upstream, in GNU binutils.

vrza avatar May 31 '22 17:05 vrza