Bug 11112

Summary: Building gcc-source fails when $PATH contains spaces
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Kai Ruhnau <kai.ruhnau>
Component: devtools / tool chainAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: Low CC: meta.mr.watcher, meta.watcher
Version: 2.2   
Target Milestone: 2.3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Kai Ruhnau 2017-02-28 21:17:50 UTC
I'm trying to build my distro using Bash on Ubuntu on Windows and it stumbles over the gcc-source_6.2.bb recipe (see below).

The reason is that my PATH contains something like "[...]:/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn:[...]" and the missing quoting / escaping before calling gnu-configize.

I have manually added two "s and compilation succeeds, but setting the PATH as seen makes me wonder what it's for in the first place.



ERROR: gcc-source-6.2.0-6.2.0-r0 do_preconfigure: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_preconfigure(d)
     0003:
File: '/home/kai/source/Target-sg/yocto/poky/meta/recipes-devtools/gcc/gcc-source.inc', lineno: 24, function: do_preconfigure
     0020:
     0021:python do_preconfigure () {
     0022:    import subprocess
     0023:    cmd = d.expand('cd ${S} && PATH=${PATH} gnu-configize')
 *** 0024:    subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
     0025:    # See 0044-gengtypes.patch, we need to regenerate this file
     0026:    bb.utils.remove(d.expand("${S}/gcc/gengtype-lex.c"))
     0027:    cmd = d.expand("sed -i 's/BUILD_INFO=info/BUILD_INFO=/' ${S}/gcc/configure")
     0028:    subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
File: '/usr/lib/python3.5/subprocess.py', lineno: 626, function: check_output
     0622:        # empty string. That is maintained here for backwards compatibility.
     0623:        kwargs['input'] = '' if kwargs.get('universal_newlines', False) else b''
     0624:
     0625:    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
 *** 0626:               **kwargs).stdout
     0627:
     0628:
     0629:class CompletedProcess(object):
     0630:    """A process that has finished running.
File: '/usr/lib/python3.5/subprocess.py', lineno: 708, function: run
     0704:            raise
     0705:        retcode = process.poll()
     0706:        if check and retcode:
     0707:            raise CalledProcessError(retcode, process.args,
 *** 0708:                                     output=stdout, stderr=stderr)
     0709:    return CompletedProcess(process.args, retcode, stdout, stderr)
     0710:
     0711:
     0712:def list2cmdline(seq):
Exception: subprocess.CalledProcessError: Command 'cd /home/kai/source/build/tmp/work-shared/gcc-6.2.0-r0/gcc-6.2.0 && PATH="{PATH}" gnu-configize' returned non-zero exit status 127

Subprocess output:
/bin/sh: 1: gnu-configize: not found

ERROR: gcc-source-6.2.0-6.2.0-r0 do_preconfigure: Function failed: do_preconfigure
ERROR: Logfile of failure stored in: /home/kai/source/build/tmp/work-shared/gcc-6.2.0-r0/temp/log.do_preconfigure.29057
ERROR: Task (/home/kai/source/Target-sg/yocto/poky/meta/recipes-devtools/gcc/gcc-source_6.2.bb:do_preconfigure) failed with exit code '1'
Comment 1 Kai Ruhnau 2017-02-28 21:19:06 UTC
Sorry, wrong stacktrace:

ERROR: gcc-source-6.2.0-6.2.0-r0 do_preconfigure: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_preconfigure(d)
     0003:
File: '/home/kai/source/Target-sg/yocto/poky/meta/recipes-devtools/gcc/gcc-source.inc', lineno: 24, function: do_preconfigure
     0020:
     0021:python do_preconfigure () {
     0022:    import subprocess
     0023:    cmd = d.expand('cd ${S} && PATH=${PATH} gnu-configize')
 *** 0024:    subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
     0025:    # See 0044-gengtypes.patch, we need to regenerate this file
     0026:    bb.utils.remove(d.expand("${S}/gcc/gengtype-lex.c"))
     0027:    cmd = d.expand("sed -i 's/BUILD_INFO=info/BUILD_INFO=/' ${S}/gcc/configure")
     0028:    subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
File: '/usr/lib/python3.5/subprocess.py', lineno: 626, function: check_output
     0622:        # empty string. That is maintained here for backwards compatibility.
     0623:        kwargs['input'] = '' if kwargs.get('universal_newlines', False) else b''
     0624:
     0625:    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
 *** 0626:               **kwargs).stdout
     0627:
     0628:
     0629:class CompletedProcess(object):
     0630:    """A process that has finished running.
File: '/usr/lib/python3.5/subprocess.py', lineno: 708, function: run
     0704:            raise
     0705:        retcode = process.poll()
     0706:        if check and retcode:
     0707:            raise CalledProcessError(retcode, process.args,
 *** 0708:                                     output=stdout, stderr=stderr)
     0709:    return CompletedProcess(process.args, retcode, stdout, stderr)
     0710:
     0711:
     0712:def list2cmdline(seq):
Exception: subprocess.CalledProcessError: Command 'cd /home/kai/source/build/tmp/work-shared/gcc-6.2.0-r0/gcc-6.2.0 && PATH=/home/kai/source/build/tmp/sysroots-uninative/x86_64-linux/usr/bin:/home/kai/source/Target-sg/yocto/poky/scripts:/home/kai/source/build/tmp/sysroots/x86_64-linux/usr/bin/arm-target-linux-gnueabi:/home/kai/source/build/tmp/sysroots/f500sx/usr/bin/crossscripts:/home/kai/source/build/tmp/sysroots/x86_64-linux/usr/sbin:/home/kai/source/build/tmp/sysroots/x86_64-linux/usr/bin:/home/kai/source/build/tmp/sysroots/x86_64-linux/sbin:/home/kai/source/build/tmp/sysroots/x86_64-linux/bin:/home/kai/source/Target-sg/yocto/poky/scripts:/home/kai/source/Target-sg/yocto/poky/bitbake/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/mnt/c/Program Files/Microsoft DNX/Dnvm:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/dotnet:/mnt/c/Users/kairu/AppData/Local/Microsoft/WindowsApps gnu-configize' returned non-zero exit status 127

Subprocess output:
/bin/sh: 1: Files/Microsoft: not found

ERROR: gcc-source-6.2.0-6.2.0-r0 do_preconfigure: Function failed: do_preconfigure
ERROR: Logfile of failure stored in: /home/kai/source/build/tmp/work-shared/gcc-6.2.0-r0/temp/log.do_preconfigure.13810
ERROR: Task (/home/kai/source/Target-sg/yocto/poky/meta/recipes-devtools/gcc/gcc-source_6.2.bb:do_preconfigure) failed with exit code '1'
Comment 2 Richard Purdie 2017-03-02 15:49:52 UTC
Basically we simply can't support path names with spaces in. The reason is that autotools itself doesn't cope with this and much of our software is autotools based.

Whilst this particular case is probably fixable, you'd eventually find cases which were not fixable without rewriting autotools.

I'd suggest instead using a PATH environment without spaces to try and run this build.
Comment 3 Richard Purdie 2017-03-02 15:50:17 UTC
I would also take a sanity test patch to test for spaces in PATH and erroring in that case btw.