Skip to content
This repository has been archived by the owner on Feb 4, 2020. It is now read-only.

Infinite recursion while finding cl.exe #312

Open
nyanpasu64 opened this issue Apr 20, 2018 · 2 comments
Open

Infinite recursion while finding cl.exe #312

nyanpasu64 opened this issue Apr 20, 2018 · 2 comments

Comments

@nyanpasu64
Copy link

nyanpasu64 commented Apr 20, 2018

I have quite a complex setup, with a "path" folder stored under %userprofile%/Dropbox/encrypted/dirlinks/path, and symlinked to %userprofile%/encrypted/dirlinks/path and %userprofile%/path. I also have ConEmu installed.

I only added %userprofile%/path to my PATH variable, while building in Visual Studio.

When I copy clcache.exe to cl.exe and execute it, it enters infinite recursion, unless:

  1. %CD% current directory does not contain cl.exe.
  2. %PATH% contains the normalized path to path folder, and not a path to that folder, but containing symlinks along the way.

If 2 is not true, findCompilerBinary() returns the wrong path since myExecutablePath() (sys.executable.upper()) differs from path.upper() (from %PATH%), even if cl.exe is the same file, accessed via different symlinks.

If 1 is not true, I don't know what's wrong since I don't know how to debug py2exe programs.


I could set CLCACHE_CL, but the default folder differs by host and EXE architecture, making me feel somewhat uncomfortable about setting it up (hard-coded to match one VS project and configuration).


Maybe you should use os.path.realpath(...) or Path.resolve() to normalize paths, to fix 2. I'm not sure if that will fix 1.

@nyanpasu64
Copy link
Author

nyanpasu64 commented Apr 21, 2018

I tried running a build in Visual Studio with CLCACHE_CL set. The build never started (I'm not sure if CLCACHE_CL was passed into clcache.exe properly) complained CL.exe path was too long (must be below 260 characters or something). Ctrl-F through Diagnostic logs showed that error was the only occurrence of cl.exe (it never got called).


In [5]: from pathlib import Path

In [13]: Path('/users/jimbo1qaz/path').resolve()
Out[13]: WindowsPath('C:/Users/jimbo1qaz/Dropbox/encrypted/dirlinks/path')

In [14]: Path('/users/jimbo1qaz/path').resolve() ==  Path('/users/jimbo1qaz/dropbox/encrypted/dirlinks/path').resolve()
Out[14]: True

In [15]: Path('/users/jimbo1qaz/path') ==  Path('/users/jimbo1qaz/dropbox/encrypted/dirlinks/path')
Out[15]: False

In [16]: Path('/users') == Path('/Users')
Out[16]: True

In [17]: os.path.realpath('/users') ==  os.path.realpath('/userS')
Out[17]: False

Pathlib was introduced in 3.4. Apparently you've dropped Python 3.3 and 2.x already.

@nyanpasu64
Copy link
Author

nyanpasu64 commented May 18, 2018

  • Call path: C:\path\cl.exe -> python C:\path\cl(which doesn't exist) -> loads the actual clcache package from directory tree.
    • This may be wrong.
  • hasattr(sys, "frozen") is false.
  • sys.argv[0] is "C:\path\cl" (which doesn't exist, only C:\path\cl.exe exists)
  • When searching for cl.exe, ensure cl.exe -> (Path(_).resolve(), os.path.splitext(_)[0], Path(_)) != Path(sys.argv[0]).resolve().
    • This fixes the bug for me, but is very ugly.

I'd send a pull request, but this project seems unmaintained.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant