[bug] CC_FOR_BUILD not set with autotools
Describe the bug
version: 2.23.0 conan_path: /opt/venv/bin/conan python version: 3.9.19 sys_version: 3.9.19 (main, Sep 4 2024, 23:10:17) [GCC 10.2.1 20210110] sys_executable: /opt/venv/bin/python3 is_frozen: False architecture: x86_64 system version: #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 platform: Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.31 system: Linux release: 6.6.87.2-microsoft-standard-WSL2 cpu:
How to reproduce it
Hello,
The instructions to reproduce are listed here: https://github.com/conan-io/conan-center-index/issues/29073
I am unsure whether this is a recipe or a client issue.
It looks like the CC_FOR_BUILD value is not set to the one for the C compiler in tools.build:compiler_executables when using autotools, which leads to a build failure in this case.
Like mentionned in the ticket, I am aware I could simply load the variable in the profile, but I feel like it should be auto deduced, just like for the CC variable.
Would you mind having a look? Thanks in advance!
Hi @Todiq
The CC_FOR_BUILD variable is set for cross-builds:
if self._is_cross_building and self._conanfile.conf_build:
compilers_build_mapping = (
self._conanfile.conf_build.get("tools.build:compiler_executables", default={},
check_type=dict)
)
if "c" in compilers_build_mapping:
env.define("CC_FOR_BUILD", compilers_build_mapping["c"])
But that doesn't seem the case in the issue you are linking?
So it seems it is more a recipe or library issue that somehow hardcodes the usage of gcc somewhere?
Hello,
I still cannot tell whether this should be fixed here or in the recipe: https://github.com/conan-io/conan-center-index/issues/29073#issuecomment-3633192063
What do you think?
So it seems it is more a recipe or library issue that somehow hardcodes the usage of gcc somewhere?
Yes, unless proven otherwise, it doesn't look like a client issue. It seems the convention of CC_FOR_BUILD is to define a CC that can build native executables for the current "build" machine, for cross-build scenarios. Build systems that are not cross building resolve to the main compiler for this things, up to my knowledge, that is to the default $(CC) variable.
If this is not the case for the flex build system it looks like more like a flex issue than a Conan client issue.
Okay, thanks for your help! I’ll then close the ticket