godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

Linking for mingw/x86_64 on MSYS2 fails

Open feiyunw opened this issue 1 year ago • 5 comments

This PR closes #1059:

  • subprocess.Popen() seems to have some deadlock problem. Use subprocess.run() as the document recommends.
  • Some improvement was made to speed up the "ar" command execution. I confirmed that a command of 8149 bytes works with the MSYS2 MinGW 64-bit shell, while 8171 doesn't.

FYI: subprocess

feiyunw avatar Mar 31 '23 16:03 feiyunw

Command line length=8153 is OK, while 8159 is broken.

feiyunw avatar Apr 02 '23 15:04 feiyunw

Godot scons config is using almost the same code and seems to be working fine (but I guess godot-cpp is linking more file, so this might be the issue). If MSYS have 8159 line limits, the same probably should be done in the main repo.

bruvzg avatar Apr 02 '23 16:04 bruvzg

For my curiosity about subprocess.run() implementation, in Python-3.10.10\Lib\subprocess.py:

def run(*popenargs,
        input=None, capture_output=False, timeout=None, check=False, **kwargs):
...
    with Popen(*popenargs, **kwargs) as process:
        try:
            stdout, stderr = process.communicate(input, timeout=timeout)
        except TimeoutExpired as exc:
            process.kill()
            if _mswindows:
                # Windows accumulates the output in a single blocking
                # read() call run on child threads, with the timeout
                # being done in a join() on those threads.  communicate()
                # _after_ kill() is required to collect that and add it
                # to the exception.
                exc.stdout, exc.stderr = process.communicate()
            else:
                # POSIX _communicate already populated the output so
                # far into the TimeoutExpired exception.
                process.wait()
            raise
        except:  # Including KeyboardInterrupt, communicate handled that.
            process.kill()
            # We don't call process.wait() as .__exit__ does that for us.
            raise
        retcode = process.poll()
        if check and retcode:
            raise CalledProcessError(retcode, process.args,
                                     output=stdout, stderr=stderr)
    return CompletedProcess(process.args, retcode, stdout, stderr)

feiyunw avatar Apr 04 '23 00:04 feiyunw

Godot scons config is using almost the same code and seems to be working fine (but I guess godot-cpp is linking more file, so this might be the issue). If MSYS have 8159 line limits, the same probably should be done in the main repo.

Agreed. Better with the whole godot-cpp/tools solution, or a quick fix if somebody reports a similar problem.

feiyunw avatar Apr 04 '23 00:04 feiyunw

Command line length=8158 is the maximum, and 8159 is broken.

feiyunw avatar Apr 04 '23 11:04 feiyunw