signature hash too long on MinGW

Issue #623 resolved
Chaffra Affouda created an issue

I know this might not be supported but when running on MinGW, compiling dolfin expressions with cmake or distutils for that matter fails because the hash is too long. Windows only handles ~256 characters path. The hack below in dolfin.compilemodules.compilemodule.py seems to do the trick but I am wondering if there is a better solution that would minimize hash collisions with shorter hash strings.

# Create unique module name for this application run
    if module_name is "":
        if sys.platform == 'win32':
            hash = hashlib.md5
        else:
            #breaks on windows because of max path length (Chaffra)
            hash = hashlib.sha1
        module_name = "dolfin_%s" % \
                      hash((repr(code) +
                                   dolfin.__version__ +
                                   str(_interface_version) +
                                   additional_declarations +
                                   str(additional_system_headers) +
                                   repr(instant_kwargs)).encode("utf-8")
                                   ).hexdigest()
        if sys.platform == 'win32':
            module_name = module_name[0:17]

Comments (4)

  1. Martin Sandve Alnæs

    I'm adding a parameter max_signature_length you can use to control this, both to dolfin and ffc.

  2. Martin Sandve Alnæs

    I've added these parameters as workarounds:

    parameters["max_signature_length"] = 18
    parameters["form_compiler"]["max_signature_length"] = 18
    

    But on my system the paths are currently only ~100 chars, so you need to have some serious path length to the root of the instant/dijitso caches to hit this problem. I'm considering this solution a sufficient workaround and would advice using less deep paths on your system as a better approach.

  3. Log in to comment