Configure mishandling quotes in compiler and flags settings

Issue #496 resolved
Paul Hargrove created an issue

As noted indirectly in pull request 370 comments, the following configure command is not handled correctly:

$ [path_to]/configure CXX='g++ -Dfoo=bar' CC='gcc -Dhi="thereyou"' --without-mpicc

The issue is that in the subsequent make step, GASNet is configured as show below, where one can see that the double-quote marks have been lost from the constructed --with-cc.

$ make
Configuring debug-mode build of GASNet
/Users/phargrov/upcxx/V/bld/GASNet-stable/configure "--without-mpicc" --with-cflags="" --with-cxxflags="" --enable-smp --disable-parsync --enable-seq --enable-par --enable-pthreads --disable-segment-everything --enable-debug --with-cc='/usr/bin/gcc -Dhi=thereyou' --with-cxx='/usr/bin/g++ -Dfoo=bar'

Use of --with-cc=... in place of CC=... shows the same problem.
However, --with-option='gcc -Dhi="thereyou"' appears to be passed to GASNet's configure without loss of the double-quotes. So, this narrows the problem to the special handling of CC and CXX (and probably CFLAGS and CXXFLAGS).

Comments (5)

  1. Paul Hargrove reporter
    • changed status to open

    I am going to work on this.

    Current goal is to accept the following contrived command:

    GASNET_CONFIGURE_ARGS=--with-foo='"a horse walks into a bar"' \
    ../configure \
            --without-mpicc \
            CXX='g++ -Dpart1="Twinkle, twinkle,"' \
            CFLAGS='-Dpart2="little star."' \
            --with-cc='gcc -Dpart3="How I wonder"' \
            --with-cxxflags='-Dpart4="what you are."'
    

    Presently, several missing applications of eval in utils/system-checks.sh are leading to failures due to the spaces in values. Even without the whitespace complications, the passing of CC and CXX to GASNet's configure has the original issue with double-quotes.

  2. Paul Hargrove reporter

    Improve configure processing of CC, CXX and flags

    This commit resolves issue 496 by making two groups of changes to the handling of CC, CXX, CFLAGS and CXXFLAGS.

    The first set of changes is to add missing eval to several compiler invocations in utils/system-checks.sh. These are necessary to deal properly with quotation marks appearing in these variables' values, especially when used to preserve white space.

    The second change is to modify the mechanism by which the compiler settings are passed to GASNet's configure to match that already in use for the flags.

    The result is that the following contrived example command runs to completion and the subsequent make passes the correctly quoted arguments to GASNet's configure (which will choke on white space in CC and/or CFLAGS, but that is an autoconf problem, not in-scope for support in UPC++ or GASNet).

    $ GASNET_CONFIGURE_ARGS='--with-foo="a horse walks into a bar"' \
      ../configure \
            --without-mpicc \
            CXX='g++ -Dpart1="Twinkle, twinkle,"' \
            CFLAGS='-Dpart2="little star."' \
            --with-cc='gcc -Dpart3="How I wonder"' \
            --with-cxxflags='-Dpart4="what you are."'
    

    → <<cset ce1ce7cd8d91>>

  3. Log in to comment