d8291fde5e
- Add new build dependencies to lld and llvm - Add host-gcc and gcc >= 7.x dependency since clang doesn't build with gcc 6.3 [ 28%] Building CXX object utils/TableGen/CMakeFiles/obj.clang-tblgen.dir/TableGen.cpp.o output/build/host-clang-15.0.3/utils/TableGen/RISCVVEmitter.cpp: In instantiation of ‘{anonymous}::SemaSignatureTable::init(llvm::ArrayRef<{anonymous}::SemaRecord>)::<lambda(auto:2&)> [with auto:2 = const llvm::SmallVector<clang::RISCV::PrototypeDescriptor>]’: /usr/include/c++/6/bits/stl_algo.h:3769:5: required from ‘_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = std::_Rb_tree_const_iterator<llvm::SmallVector<clang::RISCV::PrototypeDescriptor> >; _Funct = {anonymous}::SemaSignatureTable::init(llvm::ArrayRef<{anonymous}::SemaRecord>)::<lambda(auto:2&)>]’ output/host/include/llvm/ADT/STLExtras.h:1611:23: required from ‘UnaryFunction llvm::for_each(R&&, UnaryFunction) [with R = std::set<llvm::SmallVector<clang::RISCV::PrototypeDescriptor>, {anonymous}::SemaSignatureTable::init(llvm::ArrayRef<{anonymous}::SemaRecord>)::Compare>&; UnaryFunction = {anonymous}::SemaSignatureTable::init(llvm::ArrayRef<{anonymous}::SemaRecord>)::<lambda(auto:2&)>]’ output/build/host-clang-15.0.3/utils/TableGen/RISCVVEmitter.cpp:249:64: required from here output/build/host-clang-15.0.3/utils/TableGen/RISCVVEmitter.cpp:249:50: error: cannot call member function ‘void {anonymous}::SemaSignatureTable::insert(llvm::ArrayRef<clang::RISCV::PrototypeDescriptor>)’ without object llvm::for_each(Signatures, [this](auto &Sig) { insert(Sig); }); ^~~~~~ utils/TableGen/CMakeFiles/obj.clang-tblgen.dir/build.make:313: recipe for target 'utils/TableGen/CMakeFiles/obj.clang-tblgen.dir/RISCVVEmitter.cpp.o' failed make[4]: *** [utils/TableGen/CMakeFiles/obj.clang-tblgen.dir/RISCVVEmitter.cpp.o] Error 1 Indeed LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN is OFF, the CheckCompilerVersion.cmake trigger an error if gcc < 7.x. Indded since llvm 15 this option check for C++17 [1] The last gcc 7.x version (7.5) has been released in 2019. Fixing llvm/clang issues for old compiler maybe it's not worth it. - Remove LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN since gcc >= 7 is mendatory. When updating LLVM, we also need to update the version of SPIRV_LLVM_TRANSLATOR because its CMakeLists.txt verifies the LLVM base version [2]. The patch package/llvm/0002-Add-missing-cstdint-header-to-Signals.h.patch has been included in tag llvmorg-15.0.0 of llvm-project. [1]4c72deb613
[2]5be08b8bb9/CMakeLists.txt (LL82C6-L82C6)
Signed-off-by: Daniel Lang <d.lang@abatec.at> Signed-off-by: Romain Naour <romain.naour@smile.fr> Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr> Tested-by: Adam Duskett <adam.duskett@amarulasolutions.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
138 lines
5.1 KiB
Makefile
138 lines
5.1 KiB
Makefile
################################################################################
|
|
#
|
|
# clang
|
|
#
|
|
################################################################################
|
|
|
|
CLANG_VERSION_MAJOR = $(LLVM_PROJECT_VERSION_MAJOR)
|
|
CLANG_VERSION = $(LLVM_PROJECT_VERSION)
|
|
CLANG_SITE = $(LLVM_PROJECT_SITE)
|
|
CLANG_SOURCE = clang-$(CLANG_VERSION).src.tar.xz
|
|
CLANG_LICENSE = Apache-2.0 with exceptions
|
|
CLANG_LICENSE_FILES = LICENSE.TXT
|
|
CLANG_CPE_ID_VENDOR = llvm
|
|
CLANG_SUPPORTS_IN_SOURCE_BUILD = NO
|
|
CLANG_INSTALL_STAGING = YES
|
|
|
|
HOST_CLANG_DEPENDENCIES = host-llvm host-libxml2
|
|
CLANG_DEPENDENCIES = llvm host-clang
|
|
|
|
# This option is needed, otherwise multiple shared libs
|
|
# (libclangAST.so, libclangBasic.so, libclangFrontend.so, etc.) will
|
|
# be generated. As a final shared lib containing all these components
|
|
# (libclang.so) is also generated, this resulted in the following
|
|
# error when trying to use tools that use libclang:
|
|
# $ CommandLine Error: Option 'track-memory' registered more than once!
|
|
# $ LLVM ERROR: inconsistency in registered CommandLine options
|
|
# By setting BUILD_SHARED_LIBS to OFF, we generate multiple static
|
|
# libraries (the same way as host's clang build) and finally
|
|
# libclang.so to be installed on the target.
|
|
HOST_CLANG_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
|
|
CLANG_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
|
|
|
|
# Default is Debug build, which requires considerably more disk space
|
|
# and build time. Release build is selected for host and target
|
|
# because the linker can run out of memory in Debug mode.
|
|
HOST_CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
|
|
CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
|
|
|
|
CLANG_CONF_OPTS += -DCMAKE_CROSSCOMPILING=1
|
|
|
|
# We need to build tools because libclang is a tool
|
|
HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
|
|
CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
|
|
|
|
HOST_CLANG_CONF_OPTS += \
|
|
-DCLANG_BUILD_EXAMPLES=OFF \
|
|
-DCLANG_INCLUDE_DOCS=OFF \
|
|
-DCLANG_INCLUDE_TESTS=OFF
|
|
|
|
CLANG_CONF_OPTS += \
|
|
-DCLANG_BUILD_EXAMPLES=OFF \
|
|
-DCLANG_INCLUDE_DOCS=OFF \
|
|
-DCLANG_INCLUDE_TESTS=OFF
|
|
|
|
HOST_CLANG_CONF_OPTS += -DLLVM_DIR=$(HOST_DIR)/lib/cmake/llvm \
|
|
-DCLANG_DEFAULT_LINKER=$(TARGET_LD)
|
|
CLANG_CONF_OPTS += -DLLVM_DIR=$(STAGING_DIR)/usr/lib/cmake/llvm \
|
|
-DCMAKE_MODULE_PATH=$(HOST_DIR)/lib/cmake/llvm \
|
|
-DCLANG_TABLEGEN:FILEPATH=$(HOST_DIR)/bin/clang-tblgen \
|
|
-DLLVM_TABLEGEN_EXE:FILEPATH=$(HOST_DIR)/bin/llvm-tblgen
|
|
|
|
# Clang can't be used as compiler on the target since there are no
|
|
# development files (headers) and other build tools. So remove clang
|
|
# binaries and some other unnecessary files from target.
|
|
CLANG_FILES_TO_REMOVE = \
|
|
/usr/bin/clang* \
|
|
/usr/bin/c-index-test \
|
|
/usr/bin/git-clang-format \
|
|
/usr/bin/scan-build \
|
|
/usr/bin/scan-view \
|
|
/usr/libexec/c++-analyzer \
|
|
/usr/libexec/ccc-analyzer \
|
|
/usr/share/clang \
|
|
/usr/share/opt-viewer \
|
|
/usr/share/scan-build \
|
|
/usr/share/scan-view \
|
|
/usr/share/man/man1/scan-build.1 \
|
|
/usr/lib/clang
|
|
|
|
define CLANG_CLEANUP_TARGET
|
|
rm -rf $(addprefix $(TARGET_DIR),$(CLANG_FILES_TO_REMOVE))
|
|
endef
|
|
CLANG_POST_INSTALL_TARGET_HOOKS += CLANG_CLEANUP_TARGET
|
|
|
|
# clang-tblgen is not installed by default, however it is necessary
|
|
# for cross-compiling clang
|
|
define HOST_CLANG_INSTALL_CLANG_TBLGEN
|
|
$(INSTALL) -D -m 0755 $(HOST_CLANG_BUILDDIR)/bin/clang-tblgen \
|
|
$(HOST_DIR)/bin/clang-tblgen
|
|
endef
|
|
HOST_CLANG_POST_INSTALL_HOOKS = HOST_CLANG_INSTALL_CLANG_TBLGEN
|
|
|
|
# This option must be enabled to link libclang dynamically against libLLVM.so
|
|
HOST_CLANG_CONF_OPTS += -DLLVM_LINK_LLVM_DYLIB=ON
|
|
CLANG_CONF_OPTS += -DLLVM_LINK_LLVM_DYLIB=ON
|
|
|
|
# Prevent clang binaries from linking against LLVM static libs
|
|
HOST_CLANG_CONF_OPTS += -DLLVM_DYLIB_COMPONENTS=all
|
|
CLANG_CONF_OPTS += -DLLVM_DYLIB_COMPONENTS=all
|
|
|
|
# Help host-clang to find our external toolchain, use a relative path from the clang
|
|
# installation directory to the external toolchain installation directory in order to
|
|
# not hardcode the toolchain absolute path.
|
|
ifeq ($(BR2_TOOLCHAIN_EXTERNAL),y)
|
|
HOST_CLANG_CONF_OPTS += -DGCC_INSTALL_PREFIX:PATH=`realpath --relative-to=$(HOST_DIR)/bin/ $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)`
|
|
endif
|
|
|
|
define HOST_CLANG_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
|
|
$(Q)cd $(HOST_DIR)/bin; \
|
|
rm -f clang-$(CLANG_VERSION_MAJOR).br_real; \
|
|
mv clang-$(CLANG_VERSION_MAJOR) clang-$(CLANG_VERSION_MAJOR).br_real; \
|
|
ln -sf toolchain-wrapper-clang clang-$(CLANG_VERSION_MAJOR); \
|
|
for i in clang clang++ clang-cl clang-cpp; do \
|
|
ln -snf toolchain-wrapper-clang $$i; \
|
|
ln -snf clang-$(CLANG_VERSION_MAJOR).br_real $$i.br_real; \
|
|
done
|
|
endef
|
|
|
|
define HOST_CLANG_TOOLCHAIN_WRAPPER_BUILD
|
|
$(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_WRAPPER_ARGS) \
|
|
-s -Wl,--hash-style=$(TOOLCHAIN_WRAPPER_HASH_STYLE) \
|
|
toolchain/toolchain-wrapper.c \
|
|
-o $(@D)/toolchain-wrapper-clang
|
|
endef
|
|
|
|
define HOST_CLANG_TOOLCHAIN_WRAPPER_INSTALL
|
|
$(INSTALL) -D -m 0755 $(@D)/toolchain-wrapper-clang \
|
|
$(HOST_DIR)/bin/toolchain-wrapper-clang
|
|
endef
|
|
|
|
HOST_CLANG_TOOLCHAIN_WRAPPER_ARGS += -DBR_CROSS_PATH_SUFFIX='".br_real"'
|
|
HOST_CLANG_POST_BUILD_HOOKS += HOST_CLANG_TOOLCHAIN_WRAPPER_BUILD
|
|
HOST_CLANG_POST_INSTALL_HOOKS += HOST_CLANG_TOOLCHAIN_WRAPPER_INSTALL
|
|
HOST_CLANG_POST_INSTALL_HOOKS += HOST_CLANG_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
|
|
|
|
$(eval $(cmake-package))
|
|
$(eval $(host-cmake-package))
|