In order to use Clang as a host cross-compiler for Buildroot, we
need to provide at least the path to the sysroot (using
--sysroot) and some other compiler flags.
This series looks to reuse the toolchain wrapper for GCC since
Clang support most of the gcc flags used in the Buildroot's
toolchain wrapper. The only flag -mfused-madd (deprecated
since gcc 4.6) for mips is not supported by clang. Since
Clang require gcc >= 5.x this flag can never be used.
host-clang refers to an existing GCC-based toolchain (internal or
external) for libstdc++. However, a Buildroot external toolchain
gets a different BR_CROSS_PATH_SUFFIX. Therefore, we can't reuse the
toolchain-wrapper that gets built for the GCC-based toolchain, but
instead have to compile an additional clang-specific wrapper, called
toolchain-wrapper-clang.
After building the clang toolchain wrapper, create the symlinks needed
to force package infrastructure to use clang througt the wrapper.
Initially clang install the clang-8 binary and create all other symlinks:
# clang -> clang-8
# clang++ -> clang
# clang-8
# clang-cl -> clang
# clang-cpp -> clang
Use a post install hook to rename the clang-8 binary to clang-8.br_real
and recreate all symlinks:
# clang -> toolchain-wrapper-clang
# clang++ -> toolchain-wrapper-clang
# clang-8 -> toolchain-wrapper-clang
# clang-8.br_real
# clang++.br_real -> clang-8.br_real
# clang.br_real -> clang-8.br_real
# clang-cl -> toolchain-wrapper-clang
# clang-cl.br_real -> clang-8.br_real
# clang-cpp -> toolchain-wrapper-clang
# clang-cpp.br_real -> clang-8.br_real
NOTE: *.br_real symlinks are needed as the wrapper references them
Use the previously introduced CLANG_VERSION_MAJOR variable to create
theses symlinks.
Set BR_CROSS_PATH_SUFFIX to ".br_real" as for the Buildroot's internal
GCC toolchain backend to find the "real" clang binary installed in
$(HOST_DIR)/bin.
Borrow TOOLCHAIN_WRAPPER_BUILD and TOOLCHAIN_WRAPPER_INSTALL to
build and install the specific clang toolchain wrapper.
Signed-off-by: Romain Naour <romain.naour@smile.fr>
Cc: Valentin Korenblit <valentinkorenblit@gmail.com>
Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
To build libfuzzer package Matthew Weber noticed that (host) clang
doesn't run on the host without "-B $(HOST_DIR)/opt/ext-toolchain"
option. This option add a new search path for binaries and object
files used implicitly.
Without -B clang fail to link due to missing crtbeging.o file and libgcc:
output/host/bin/aarch64-linux-gnu-ld: cannot find crtbegin.o: No such file or directory
output/host/bin/aarch64-linux-gnu-ld: cannot find -lgcc
Indeed, clang search path doesn't include the dafault cross-gcc's search paths:
$ output/host/bin/clang -print-search-dirs
programs: = output/host/bin:output/host/bin:/..//bin
libraries: = output/host/lib/clang/8.0.0:
output/host/bin/../lib64:
/lib/../lib64:
/usr/lib/../lib64:
output/host/bin/../lib:
/lib:/usr/lib
Here is the same command for cross-gcc:
$ output/host/bin/aarch64-linux-gnu-gcc -print-search-dirs
install: output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/
programs: = output/host/opt/ext-toolchain/bin/../libexec/gcc/aarch64-linux-gnu/8.3.0/:
output/host/opt/ext-toolchain/bin/../libexec/gcc/:
output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/aarch64-linux-gnu/8.3.0/:
output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/
libraries: = output/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/:
output/host/opt/ext-toolchain/bin/../lib/gcc/:
output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/aarch64-linux-gnu/8.3.0/:
output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/:
output/host/aarch64-buildroot-linux-gnu/sysroot/lib/aarch64-linux-gnu/8.3.0/:
output/host/aarch64-buildroot-linux-gnu/sysroot/lib/../lib64/:
output/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/8.3.0/:
output/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/../lib64/:
output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/:
output/host/aarch64-buildroot-linux-gnu/sysroot/lib/:
output/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/
We can see that gcc default search path contains
"output/host/opt/ext-toolchain" directory where the external toolchain
has been extracted.
Since we want to use clang without additional option like -B,
patch clang in order to use GCC_INSTALL_PREFIX instead of
using automatic detection (which doesn't work for Buildroot).
We eventually want to relocate the Buildroot SDK containing the clang
cross-compiler, so we provide a relative path to GCC_INSTALL_PREFIX
in order to avoid to hardcode the path to the GCC toolchain.
Also the path between clang and the GCC external toolchain is not always
the same, we have the following case:
* Toolchain to be downloaded and installed
The toolchain is extracted into $(HOST_DIR)/opt/ext-toolchain, so the
path is "../opt/ext-toolchain".
* Pre-installed toolchain
The toolchain is localed somewhere in the host filesystem and
defined by the user using BR2_TOOLCHAIN_EXTERNAL_PATH.
So, set GCC_INSTALL_PREFIX using realpath:
-DGCC_INSTALL_PREFIX:PATH=`realpath --relative-to=$(HOST_DIR)/bin/ $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)`
When we use a Buildroot's internal toolchain, clang will find theses
crt*.o files and libgcc.
http://lists.busybox.net/pipermail/buildroot/2019-August/256204.html
Signed-off-by: Romain Naour <romain.naour@smile.fr>
Cc: Matthew Weber <matthew.weber@rockwellcollins.com>
Cc: Valentin Korenblit <valentinkorenblit@gmail.com>
Tested-by: Matt Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This patch adds CPE ID information for a significant number of
packages.
Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This is similar to the llvm package which also disables shared libs
for the host variant.
Signed-off-by: Michael Nosthoff <buildroot@heine.tech>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Go back to the github url download again.
Cc: Joseph Kogut <joseph.kogut@gmail.com>
Cc: Valentin Korenblit <valentinkorenblit@gmail.com>
Signed-off-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
... so we can drop all config options about it and previous versions.
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Arnout Vandecappelle <arnout@mind.be>
Cc: Peter Korsgaard <peter@korsgaard.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
The github download url doesn't contain the llvm 9.0.0 archive,
so use the previous url.
Since v9.0.0, it was relicensed to the Apache License 2.0 with
LLVM Exceptions. Update the license file hash.
See:
http://releases.llvm.org/9.0.0/tools/clang/docs/ReleaseNotes.html
Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Valentin Korenblit <valentinkorenblit@gmail.com>
Cc: Joseph Kogut <joseph.kogut@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Project moved to github, updated project URL
Signed-off-by: Valentin Korenblit <valentinkorenblit@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Clang no longer needs llvm-config. It now looks for LLVMConfig.cmake,
which is specified by LLVM_DIR option.
The license file hash changed due to a copyright year update:
-Copyright (c) 2007-2018 University of Illinois at Urbana-Champaign.
+Copyright (c) 2007-2019 University of Illinois at Urbana-Champaign.
Signed-off-by: Valentin Korenblit <valentinkorenblit@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
By default clang is assuming the system linker /usr/bin/ld. This
patchset updates the default to point at the cross toolchain ld.
Previously clang had been used on target only, this update is
required for host clang/clang++ to be used as a frontend for
cross-compiling.
Example build command:
output/host/bin/clang++ -mcpu=cortex-a53 \
--sysroot /<abs path>/output/staging/ \
-B /<abs path>/output/host/opt/ext-toolchain/ \
foobar.cc -o foobar
Cc: Valentin Korenblit <valentinkorenblit@gmail.com>
Reviewed-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
LICENSE.TXT hash changed due to the Copyright date update.
Signed-off-by: Valentin Korenblit <valentinkorenblit@gmail.com>
Reviewed-by: Romain Naour <romain.naour@smile.fr>
Tested-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Ferdinand van Aartsen <ferdinand@ombud.nl>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This patch fixes the following error when trying to execute clang compiler
(host-variant):
CommandLine Error: Option 'x86-use-base-pointer' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
The same happens for the other binaries, such as clang-format:
./clang-format
: CommandLine Error: Option 'help-list' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
Clang binaries are tools, and given that DLLVM_LINK_LLVM_DYLIB is set,
they are linked against libLLVM.so. The problem is that binaries are
also linking against some LLVM static libraries, resulting in the error
shown above. However, it is not the same case for libclang, which is also
a tool but links only against libLLVM.so.
To fix this problem, add LLVM_DYLIB_COMPONENTS=all.
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
Tested-by: Joseph Kogut <joseph.kogut@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
5.0.2 is API and ABI compatible with 5.0.0 and 5.0.1 and includes
mitigations for CVE-2017-5715 (Spectre Variant 2) for X86 and MIPS.
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
libclang.so is statically linking against all LLVM static libraries
instead of linking dynamically against libLLVM.so.
This patch fixes this problem by setting LLVM_LINK_LLVM_DYLIB to ON.
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This patch provides Clang tools and libraries for the host and
libclang for the target.
host-clang is needed to build libclc, which is provided in a follow-up
patch.
We need libclang for the target because it is used by most of OpenCL
implementations.
A later patch in this series will enable Clover, the OpenCL
implementation part of Mesa3D, which requires libclang.
clang-tblgen must be copied to HOST_DIR as it is not installed by
default but is needed for cross-compilation:
http://lists.llvm.org/pipermail/cfe-dev/2015-June/043318.html
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
[Thomas:
- Add Config.in comment about BR2_TOOLCHAIN_HAS_GCC_BUG_64735
- Minor reformatting/rewrapping of comments in .mk file]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>