Replies: 1 comment 4 replies
|
so c_compilers = 'cc' doesn't mean look for command line cc, it means load the cc tool. It does sound like detecting FreeBSD and setting clang as the first to search for may be called for. |
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
While investigating a build issue on FreeBSD, I noticed that SCons' default POSIX tool selection currently prefers GCC over the platform compiler:
Tool/init.py
Also, this is a discrepancy between the documentation and the implementation, as the manual says:
On all other platforms, including POSIX (Linux and UNIX) and macOS platforms, SCons searches in order for the GCC tool chain, the LLVM/Clang tools, and the Intel compiler tools.
However, the implementation also searches for the generic platform compiler as a final fallback (not mentioned).
This means that if a versioned GCC (e.g. gcc14) is installed anywhere on the system, SCons will select the gcc tool, even when:
CC/CXX are not set,
the project's SConstruct does not mention GCC,
the platform's default compiler is cc,
and gcc14 is after cc and clang in the PATH order.
On FreeBSD, for example:
/usr/bin/cc is Clang (the supported base system compiler),
CC is unset,
yet Environment() initializes the gcc/g++ tools because a GCC installation is present in /usr/local/bin.
This surprised me because I expected SCons to follow the platform compiler by default, and only use GCC when explicitly requested.
On many modern Unix systems, cc is the platform's canonical C compiler interface, regardless of the underlying implementation.
Would it make more sense for the search order to prefer cc (and c++) before compiler-specific names? For example:
or perhaps another ordering that respects the platform's native compiler while still allowing users to select GCC explicitly via CC, CXX, or the appropriate tool.
I might be mistaken, but other existing build tools (Meson, CMake) tends to prefer 'cc' over 'gcc' or 'clang'.
I'm interested in understanding the historical rationale for the current ordering and if this reason still applies today?
All reactions