Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc invoked even with passing CC=clang to make #1303

Closed
tstellar opened this issue Feb 12, 2021 · 6 comments
Closed

gcc invoked even with passing CC=clang to make #1303

tstellar opened this issue Feb 12, 2021 · 6 comments
Labels
question Question asked by issue author.

Comments

@tstellar
Copy link

tstellar commented Feb 12, 2021

I'm trying to build the Fedora kernel with clang and the build system is still invoking gcc even when I pass CC=clang to make. The failing command is:

/usr/bin/make V=1 CC=clang 'HOSTCFLAGS=-O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg -fstack-protector-strong -fcommon -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' 'HOSTLDFLAGS=-Wl,-z,relro -Wl,--as-needed -Wl,-z,now ' ARCH=x86_64 olddefconfig

gcc: error: unrecognized command-line option '--config'; did you mean '-mpconfig'?
make[1]: *** [scripts/Makefile.host:95: scripts/basic/fixdep] Error 1
make: *** [Makefile:539: scripts_basic] Error 2

The Fedora build scripts runs a lot of commands before this, so I've attached the full build.log.

@nathanchance
Copy link
Member

CC is used for compiling the kernel, HOSTCC is used for compiling the host utilities like the kconfig tool, which is what is happening in this instance. Specify HOSTCC=clang in addition to CC=clang for the intended result. Additionally, LLVM=1 will do that automatically and use all of the LLVM utilities.

@nickdesaulniers nickdesaulniers added the question Question asked by issue author. label Feb 12, 2021
@nickdesaulniers
Copy link
Member

Yes; you should either be doing:

$ make CC=clang HOSTCC=clang ...

or

$ make LLVM=1 ...

@dileks
Copy link

dileks commented Feb 13, 2021

@tstellar
Details see [1].

make LLVM=1 has some benefits but I am not very happy with it.
make LLVM=1 points to clang, ld.lld, llvm-ar, llvm-nm means without version-suffix etc.

Cannot speak for Red Hat based distros, but Debian offers the opportunity to co-install several LLVM toolchain versions.
llvm-toolchain-XX is a meta-package whereof Debian packages like llvm-12, clang-12 and lld-12 (here: XX=12) are generated.
This means in your system's and user's path you will have clang-12 etc.
Of course you can install llvm, clang and lld metapages, but they differ in XX for Debian stable/testing/unstable/experimental and I suggest not to install them when you plan to use more than one llvm-toolchain-XX.
Example: clang meta-package in Debian/bullseye symlinks to clang-11.
@tstellar
How is your distribution organizing its LLVM packages for misc LLVM versions?

To fullfill and as a workaround I added to my linux-kernel build-script:

### GCC and LLVM version settings
GCC_MAJOR_VER="10"
LLVM_MAJOR_VER="12"

### LLVM toolchain path options
# Explicitly set PATH to simplify LLVM=1 handling (see LLVM tools options)
# Option-1: Use system's LLVM toolchain
# Option-2: Use selfmade LLVM toolchain (here: ThinLTO+PGO optimized via tc-build)
# Option-3: Set custom PATH in ~/.bashrc
##LLVM_TOOLCHAIN_PATH="/usr/lib/llvm-${LLVM_MAJOR_VER}/bin"
LLVM_TOOLCHAIN_PATH="/opt/llvm-toolchain/bin"
if [ -d ${LLVM_TOOLCHAIN_PATH} ]; then
   export PATH="${LLVM_TOOLCHAIN_PATH}:${PATH}"
fi

XXX: TODO: Distinguish install-path for misc selfmade llvm-toolchain-XX?

Each time I want to test something in bash with my selfmade LLVM toolchain v12.0.0-rc1 and make LLVM=1 I have to be very careful.
Mostly, I do a cut'n'paste from my build-script.

Currently, I switched to and use my selfmade LLVM toolchain v12.0.0-rc1 and will upgrade with each v12.0.0-rcX until v12.0.0 final.

Why a selfmade LLVM toolchain?

  1. stage1-toolchain approx. 10% faster than Debian's equivalent
  2. ThinLTO+PGO optimized multistage-toolchain saves here approx. 33% of build-time.

I would like to have an whatever option to pass a custom LLVM_VER_SUFFIX to make.

[1] https://www.kernel.org/doc/html/latest/kbuild/llvm.html#llvm-utilities
[2] https://sources.debian.org/search/llvm-toolchain-12/
[3] https://packages.debian.org/bullseye/clang

@tstellar
Copy link
Author

@dileks In Fedora, we just ship one version of the clang/llvm toolchain. We do provide compatibility packages with older versions of the clang/llvm libraries, but without the executables, like clang, llc, etc.

@dileks
Copy link

dileks commented Feb 15, 2021

@tstellar
Thanks for the info.
Sometimes it is good to focus on one release/thing.
Do One Thing And Do It Well. (Unix philosophy)

@nickdesaulniers
Copy link
Member

@tstellar please reopen if you still observe GCC invoked when building via make LLVM=1, otherwise feel free to open new issues for different bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question asked by issue author.
Projects
None yet
Development

No branches or pull requests

4 participants