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

Visual Studio 2010 #18

Closed
mellon85 opened this issue Oct 16, 2013 · 9 comments
Closed

Visual Studio 2010 #18

mellon85 opened this issue Oct 16, 2013 · 9 comments

Comments

@mellon85
Copy link

I am trying to run clcache with Visual Studio 2010.

I have tried putting it inthe PATH of my user, of the whole system and even replacing my cl.exe with this launcher and speicyfing CLCACHE_CL to the correct compiler (renamed to cl.real.exe). My code let me specify where to find clcache.py, plus I am having problems with py2exe and my windows is x86_64.

In the current setup I have these variable set

CLCACHE_DIR = C:\clcache
CLCACHE_CL = C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.real.exe
CLCACHE_HARDLINK = 1
CLCACHE_LOG = 1
CLCACHE_PATH = C:\sources\clcache
#include <string>
#include <stdlib.h>

int main( int argc, char* argv[] )
{
    // Checking standard variables
    char *CLCACHE_PATH = getenv("CLCACHE_PATH");
    std::string cmd = "python "; 
    if (CLCACHE_PATH)
    {
        cmd += CLCACHE_PATH;
        cmd += '/';
    }
    cmd += "clcache.py ";
    for ( int i = 1; i < argc; ++i )
    {
        cmd += ' ';
        cmd += argv[i];
    }
    return system(cmd.c_str());
}

with the PATH modifications it wasn't being called, with this launcher I can manage to make it work if I manually call it, but visual studio will return me

The system cannot execute the specified program.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(62,5): error MSB6006: "CL.exe" exited with code 1.

How can I setup Visual Studio 2010 to actually use clcache?

@inorton
Copy link
Contributor

inorton commented Oct 16, 2013

What I've found works is this:

rename cl.exe to cl_real.exe
rename cl.exe.config to cl_real.exe.config
copy clcache.exe to cl.exe

then set CLCACHE_CL to the full path to cl_real.exe

Whatever you do, make sure that the real compiler's .config file is appropriately named

@mellon85
Copy link
Author

I already renamed the configuration file correctly.. I tried now switching from cl.real.exe to cl_real.exe .. but it doesn't work yet, I still have the same issue

@mellon85
Copy link
Author

Your cl.exe is the generated py2exe file?

@mellon85
Copy link
Author

Ok, I managed to install python 32bit and py2exe 32 bit and it's being called. Unfortunately I am getting these erors

1>c:\sources\development\main\testmain.cpp : fatal error C1033: cannot open program database 'c:\sources\development\main\testmain"debug\vc100.pdb"'

and

2>cl : Command line warning D9028: minimal rebuild failure, reverting to normal build
2> stdafx.cpp
2>c1xx : fatal error C1083: Cannot open compiler intermediate file: '"C:\sources\Development\Main\Report\Debug\Win32\ReporD.pch"': Invalid argument

@inorton
Copy link
Contributor

inorton commented Oct 16, 2013

Ah right, AIUI, clcache doens't support pre-compiled headers or external pdb files, but it should handle it more cleanly.

what do you see if you build your project under msbuild?

@mellon85
Copy link
Author

I can't test it right now. I will see on Monday :-)
Thanks for the support.
Il 16/ott/2013 17:37 "Ian Norton" notifications@github.com ha scritto:

Ah right, AIUI, clcache doens't support pre-compiled headers or external
pdb files, but it should handle it more cleanly.

what do you see if you build your project under msbuild?


Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-26429259
.

@mellon85
Copy link
Author

Sorry I was currently busy :)
Anyhow, I wrote a pull request to ignore /Yu and /Yc and remove them from
the command line.
I still have the issue of the .pdb file though

@webmaster128
Copy link
Contributor

I was also having problems with py2exe, so I now use the following clcache.bat as my CXX

@echo off
@setlocal 

set CLCACHE_HARDLINK=1
set CLCACHE_NODIRECT=1

python.exe C:\Users\myuser\clcache-bin\clcache.py %*

Can this be closed? I guess it is getting too wide now.

frerich pushed a commit that referenced this issue Jun 24, 2016
It's apparently not too easy to make Visual Studio pick up clcache. I
don't use the IDE myself, but others described that replacing the
original binary works. So let's at least mention this approach.

Resolves #18.
@NicolasDorier
Copy link

NicolasDorier commented Jun 29, 2019

@frerich I think your instructions are needlessly complicated for integration with visual studio.
You just have to integrate

<PropertyGroup>
    <CLToolExe>clcache.exe</CLToolExe>
    <CLToolPath>C:\ProgramData\chocolatey\bin\</CLToolPath>
    <TrackFileAccess>false</TrackFileAccess>
  </PropertyGroup>

In you project file.

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

4 participants