Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ccache when cross-compiling with autotools

I know the standard way of cross compiling an autoconf-based project:

$ ./configure --host=i686-w64-mingw32

However, what if I want to use ccache?

I know I can override the CC and CXX variables (e.g CC="ccache i686-w64-mingw32-gcc" ./configure --host=i686-w64-mingw32). However, this seems redundant and error prone.

Is there a standard way, I'm missing, like some CC_PREFIX variable?

like image 1000
Ace17 Avatar asked Feb 09 '16 08:02

Ace17


People also ask

Why is cross compiling so hard?

"building a cross-compiler is significantly harder than building a compiler that targets the platform it runs on." The problem exists due to the way libraries are built and accessed. In the normal situation all the libraries are located in a specific spot, and are used by all apps on that system.

Can GCC cross compile?

GCC, a free software collection of compilers, can be set up to cross compile. It supports many platforms and languages. Cross-compiling GCC requires that a portion of the target platform's C standard library be available on the host platform.


1 Answers

There isn't, if you want to use ccache you'll have to change your CC/CXX parameters as well as passing --host.

By the way, prefer

./configure --host=i686-w64-mingw32 \
    CC="ccache i686-w64-mingw32-gcc" CXX="ccache i686-w64-mingw32-g++"

rather than pre-fixing the environment variables. This way they will be correctly recorded as overrides in config.log/config.cache if you're using maintainer mode.

like image 157
Diego Elio Pettenò Avatar answered Sep 22 '22 15:09

Diego Elio Pettenò