Page 1 of 1

using ccache

Posted: Sat Dec 21, 2019 9:02 pm
by N7DR
I typically use "ccache g++" instead of "g++" to invoke the compiler in large, complex projects.

How do I change a codelite project so that it will use "ccache g++" (or "ccache /usr/bin/g++") to invoke the compiler instead of the default string "/usr/bin/g++"? I don't want to change anything else, just this invocation string.

Re: using ccache

Posted: Sat Dec 21, 2019 11:57 pm
by DavidGH
Hi,

I expect the details will vary depending on distro/version, but I have used two ways (actually three, but the third, involving colorgcc, is now defunct):

1) The original way was to insert something like this line into the project's Compiler settings (or Environmental Variables or... it was some years ago):
CXX="codelitegcc ccache /usr/bin/g++-4.7" CC="codelitegcc gcc"

2) The better way, if it's available to you, is to prepend to your $PATH, something like:
PATH=/usr/lib/ccache/:$PATH
That's for debian. You may need to change it to /usr/lib64/ccache/ or similar.
Put that line in ~/.bashrc and ccache should automatically be used however you compile.

Regards,

David

Re: using ccache

Posted: Sun Dec 22, 2019 1:28 am
by N7DR
> 1) The original way was to insert something like this line into the project's Compiler settings (or Environmental Variables or... it was some years ago):
> CXX="codelitegcc ccache /usr/bin/g++-4.7" CC="codelitegcc gcc"

If I set that in the environment, then I get:

/bin/sh: 1: codelitegcc ccache /usr/bin/g++-4.7: not found

Even if I simply say:
CXX="codelitegcc ccache /usr/bin/g++"
which makes more sense to me... [my system knows nothing about any g++ version 4.7, and my code makes heavy use of C++17 features added after 4.7] then I get the similar error:
/bin/sh: 1: codelitegcc ccache /usr/bin/g++: not found
even though /usr/bin/g++ definitely does exist, as does ccache:
[HN:web] ls -al /usr/bin/g++
lrwxrwxrwx 1 root root 5 Apr 8 2017 /usr/bin/g++ -> g++-6
[HN:web] ls -al /usr/bin/ccache
-rwxr-xr-x 1 root root 133200 Feb 17 2017 /usr/bin/ccache
[HN:web]

There is no codelitegcc:
[HN:web] whereis codelitegcc
codelitegcc:
[HN:web] codelitegcc
-bash: codelitegcc: command not found
[HN:web]

----

Changing the PATH isn't a good idea, because I definitely do not want this to happen as a matter of course, just in some large codelite projects.

Re: using ccache

Posted: Sun Dec 22, 2019 1:51 am
by DavidGH
If I set that in the environment, then I get:
/bin/sh: 1: codelitegcc ccache /usr/bin/g++-4.7: not found
Yes, of course. I was pasting what had worked some years ago, not suggesting that exactly that command would work now.
Changing the PATH isn't a good idea, because I definitely do not want this to happen as a matter of course, just in some large codelite projects.
(I doubt if it would have any negative side-effects, but) That's OK; just alter $PATH in your project's Environment Settings.

Re: using ccache

Posted: Mon Dec 23, 2019 6:58 pm
by N7DR
> $PATH in your project's Environment Settings.

OK, I've done that, but codelite is still just calling g++. For example, in the "build" window I still see no reference to ccache:

/usr/bin/g++ -c "/home/n7dr/projects/adif-qsl/src/qsldb.cpp" -g3 -O2 -Wall -DLINUX -Wno-reorder -o ./Debug/up_up_projects_adif-qsl_src_qsldb.cpp.o -I. -I/home/n7dr/projects/adif-qsl/include

Re: using ccache

Posted: Mon Dec 23, 2019 8:23 pm
by DavidGH
One last suggestion. You could try putting:
PATH=/usr/lib/ccache/:$PATH
into the appropriate set of Settings > Environmental variables

If that still fails, I suggest you try to 'debug' the reason e.g. look at the 'raw' settings in the ${project-name}.project file; does it show what you were expecting?

Re: using ccache

Posted: Mon Dec 23, 2019 11:50 pm
by eranif
Right click on the project -> environment -> CXX=ccache g++
This should work

CodeLite's generated makefile honors the CXX and CC environment variables
So you can use the (the way I showed above)

You can also set it globally from: Settings->Environment variable