简体   繁体   English

如果编译器绝对路径硬编码在 makefile 中,我应该如何使用 ccache?

[英]How should I use ccache if the compiler absolute path is hard-coded in the makefile?

It's not an option for me to modify the complicated nest of makefiles that builds our code, and in various places they construct absolute paths to very specific compilers, eg /home/arm2gcc/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi-gcc修改构建我们代码的复杂的 makefile 嵌套对我来说不是一个选项,并且在不同的地方他们构建了非常特定的编译器的绝对路径,例如/home/arm2gcc/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi-gcc

That makes it hard to use ccache either as a prefix or by putting it first in the path.这使得很难将 ccache 用作前缀或将其放在路径中的首位。

So I wonder about moving the compiler installations on my personal machine to eg /home/arm2gcc-real and putting fake scripts in /home/arm2gcc that redirect to the real compilers.所以我想知道将我个人机器上的编译器安装移动到例如/home/arm2gcc-real并将假脚本放入重定向到真实编译器的/home/arm2gcc中。

Can anyone suggest how to do this?谁能建议如何做到这一点? Or is there a better way?或者,还有更好的方法?

Disclaimer: I've only limited experience with Ccache and CMake.免责声明:我对 Ccache 和 CMake 的经验有限。

Can you try adding this in the root CMakeLists.txt file:您可以尝试将其添加到根 CMakeLists.txt 文件中吗:

find_program(CCACHE ccache)
if(CCACHE)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
endif()

If that does not work, I think we may need some more info on how the compilers are setup exactly in your CMakeLists.txt files.如果这不起作用,我认为我们可能需要更多关于如何在 CMakeLists.txt 文件中准确设置编译器的信息。

I suggest:我建议:

mv .../bin/arm-none-eabi-gcc .../bin/arm-none-eabi-gcc.real

Then, create a script to replace .../bin/arm-none-eabi-gcc with this content:然后,创建一个脚本以将.../bin/arm-none-eabi-gcc替换为以下内容:

#!/bin/sh
exec ccache ${0}.real "$@"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 scanf格式的硬编码字符串 - Hard-coded string in the format of scanf 如何使用python变量而不是硬编码值创建ctypes变量? - How to creating ctypes variables using python variables instead of hard-coded values? 如何在Make中使用ccache? - How to use ccache with Make? 带有返回硬编码字符串文字的函数的字符串存储在哪里? - Where is the string stored with functions that return a hard-coded string literal? 将(uint32_t)与硬编码值进行比较是否安全? - Is it safe to compare an (uint32_t) with an hard-coded value? c - 定义的值比硬编码的数字慢 - c - Are defined values slower than hard-coded numbers 在C中返回递归所需的硬编码数组是否正确? - Is it correct to return a hard-coded array needed for recursion in C? 使用L前缀(Visual C ++编译器)时,如何#define硬编码字符串? - How to #define hard coded strings when L prefix (Visual C++ compiler) is used? 为什么使用fgets()读取的命令不能与execlp()一起使用,但硬编码的相同命令是否正常工作? - Why does my command read with fgets() not work with execlp(), but the same command hard-coded works correctly? 尝试递归匹配2个硬编码数组中的数字,不能超过1个成功周期 - Trying to Recursively match numbers in 2 hard-coded arrays, unable to go further than 1 successful cycle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM