Skip to content

Setting CXX to 'python …/emcc.py' confuses some configure scripts (follow-up to #5967) #6378

Closed

Description

@cpitclaudel

As requested in the discussion on #5967, here's a use case that recently broke:

Here's a small excerpt of Z3's mk_make script:

AR=getenv("AR", "ar")

def which(program):
    import os
    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in getenv("PATH", "").split(os.pathsep):
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file
    return None

def check_ar():
    if is_verbose():
        print("Testing ar...")
    if which(AR) is None:
        raise MKException('%s (archive tool) was not found' % AR)

The call to which(AR) fails when AR is set to python …/cmar.py, because that's not a single program.

Here's another relevant part:

def test_cxx_compiler(cc):
    if is_verbose():
        print("Testing %s..." % cc)
    t = TempFile('tst.cpp')
    t.add('#include<iostream>\nint main() { return 0; }\n')
    t.commit()
    return exec_compiler_cmd([cc, CPPFLAGS, CXXFLAGS, 'tst.cpp', LDFLAGS]) == 0

def find_cxx_compiler():
    global CXX, CXX_COMPILERS
    if CXX is not None:
        if test_cxx_compiler(CXX):
            return CXX
    for cxx in CXX_COMPILERS:
        if test_cxx_compiler(cxx):
            CXX = cxx
            return CXX
    raise MKException('C++ compiler was not found. Try to set the environment variable CXX with the C++ compiler available in your system.')

The code for exec_compiler_cmd is a bit long to copy here; see https://github.com/Z3Prover/z3/blob/master/scripts/mk_util.py#L203. But it fails, too, because it tries to run python …/emcc.py as a single program with a space in its name.

Thanks!

Activity

  1. changed the title [-]Setting EMCC to 'python …/emcc.py' confuses some configure scripts (follow-up to #5967)[/-] [+]Setting CXX to 'python …/emcc.py' confuses some configure scripts (follow-up to #5967)[/+] on Mar 25, 2018
  2. kripken commented on Mar 28, 2018

    @kripken
    Member

    Thanks for filing @cpitclaudel !

    @saschanaz , do you have time to look at this?

  3. saschanaz commented on Mar 29, 2018

    @saschanaz
    Collaborator

    That change was to not trigger multiple Py3 warnings in a single command, not sure what should be done. Any ideas?

    I'm still seeing multiple duplicated warnings when I build system libraries, so it definitely needs a fix.

  4. kripken commented on Mar 30, 2018

    @kripken
    Member

    @saschanaz is the Py3 warning the one we emit for Py3 no longer being officially supported? if so then I believe we removed that warning, as we now consider Py3 fully supported (or did we just plan to do that?) so could we undo this change to fix the issue?

  5. saschanaz commented on Mar 30, 2018

    @saschanaz
    Collaborator

    Ah, that's great! In that case, yes, we can just revert this change.

  6. kripken commented on Apr 2, 2018

    @kripken
    Member

    Turns out we just intended to allow 2 and 3, but didn't do it. I opened #6415 which does that, and also fixes this issue.

    The one missing thing there is to add a test for the issue here that is being fixed. @cpitclaudel, your summary of the issue above is pretty good, but I'm not sure offhand how to create a small testcase for it?

  7. cpitclaudel commented on Apr 2, 2018

    @cpitclaudel
    Author

    A small test case would be ensuring that the which function posted above returns a string (not None) when passed the value of getenv("CXX"), I think.

    I was going to rewrite that function to avoid licensing issues… until I realized it came from https://stackoverflow.com/questions/377017/test-if-executable-exists-in-python .

  8. kripken commented on Apr 2, 2018

    @kripken
    Member

    Thanks @cpitclaudel , I modified that a little and added a test based on it now.

  9. cpitclaudel commented on Apr 2, 2018

    @cpitclaudel
    Author

    Excellent, thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions