mirror of
https://git.busybox.net/buildroot.git
synced 2024-11-23 13:33:28 +08:00
package/compiler-rt: new package
This patch adds support for the compiler-rt (CLANG runtime) library. It builds a set of static libraries and installs them into the CLANG/LLVM toolchain resource folder. These libraries can then be used by developers in the SDK for building target applications for analysis. What is fuzzing and why libfuzzer? https://www.moritz.systems/blog/an-introduction-to-llvm-libfuzzer/ The compiler-rt fuzzer and address sanitizer tools require additional LLVM binary tools installed to allow stack trace decoding actively during executable analysis. This patch conditionally enables these tools. https://github.com/google/sanitizers/wiki/AddressSanitizerCallStack Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com> Signed-off-by: James Hilliard <james.hilliard1@gmail.com> Cc: Romain Naour <romain.naour@smile.fr> Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com> Cc: Valentin Korenblit <valentinkorenblit@gmail.com> Cc: Michael Drake <michael.drake@codethink.co.uk> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This commit is contained in:
parent
b19126c398
commit
b1fcb596fe
@ -1903,6 +1903,7 @@ F: package/bridge-utils/
|
||||
F: package/checkpolicy/
|
||||
F: package/checksec/
|
||||
F: package/cgroupfs-mount/
|
||||
F: package/compiler-rt/
|
||||
F: package/crda/
|
||||
F: package/cunit/
|
||||
F: package/dacapo/
|
||||
|
@ -1934,6 +1934,7 @@ menu "Other"
|
||||
source "package/cereal/Config.in"
|
||||
source "package/clang/Config.in"
|
||||
source "package/cmocka/Config.in"
|
||||
source "package/compiler-rt/Config.in"
|
||||
source "package/cppcms/Config.in"
|
||||
source "package/cracklib/Config.in"
|
||||
source "package/dawgdic/Config.in"
|
||||
|
14
package/compiler-rt/Config.in
Normal file
14
package/compiler-rt/Config.in
Normal file
@ -0,0 +1,14 @@
|
||||
config BR2_PACKAGE_COMPILER_RT
|
||||
bool "compiler-rt"
|
||||
depends on BR2_PACKAGE_LLVM
|
||||
depends on BR2_TOOLCHAIN_USES_GLIBC # asan lib requires
|
||||
help
|
||||
A collection of runtime libraries primarily used by clang and
|
||||
llvm to provide builtins, sanitizer runtimes, and profiling
|
||||
at runtime.
|
||||
|
||||
https://compiler-rt.llvm.org/
|
||||
|
||||
comment "compiler-rt requires llvm to be enabled and a glibc toolchain"
|
||||
depends on !BR2_PACKAGE_LLVM
|
||||
depends on !BR2_TOOLCHAIN_USES_GLIBC
|
3
package/compiler-rt/compiler-rt.hash
Normal file
3
package/compiler-rt/compiler-rt.hash
Normal file
@ -0,0 +1,3 @@
|
||||
# Locally computed:
|
||||
sha256 def1fc00c764cd3abbba925c712ac38860a756a43b696b291f46fee09e453274 compiler-rt-11.1.0.src.tar.xz
|
||||
sha256 1a8f1058753f1ba890de984e48f0242a3a5c29a6a8f2ed9fd813f36985387e8d LICENSE.TXT
|
37
package/compiler-rt/compiler-rt.mk
Normal file
37
package/compiler-rt/compiler-rt.mk
Normal file
@ -0,0 +1,37 @@
|
||||
################################################################################
|
||||
#
|
||||
# compiler-rt
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# Compiler-RT should be bumped together with LLVM and Clang as the run-time is
|
||||
# tied to the version of those tools
|
||||
COMPILER_RT_VERSION = 11.1.0
|
||||
COMPILER_RT_SOURCE = compiler-rt-$(COMPILER_RT_VERSION).src.tar.xz
|
||||
COMPILER_RT_SITE = https://github.com/llvm/llvm-project/releases/download/llvmorg-$(COMPILER_RT_VERSION)
|
||||
COMPILER_RT_LICENSE = NCSA MIT
|
||||
COMPILER_RT_LICENSE_FILES = LICENSE.TXT
|
||||
COMPILER_RT_DEPENDENCIES = host-clang llvm
|
||||
|
||||
COMPILER_RT_INSTALL_STAGING = YES
|
||||
COMPILER_RT_INSTALL_TARGET = NO
|
||||
|
||||
COMPILER_RT_CONF_OPTS=-DCOMPILER_RT_STANDALONE_BUILD=OFF \
|
||||
-DCOMPILER_RT_STANDALONE_BUILD=ON \
|
||||
-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME) \
|
||||
-DLLVM_CONFIG_PATH=$(HOST_DIR)/usr/bin/llvm-config
|
||||
|
||||
# The installation of the target runtime libraries defaults to DESTDIR, however
|
||||
# host-clang resources directory needs a link so Clang can find the runtime
|
||||
# libraries in the same location they would be if built as part of the Clang
|
||||
# build. The "resources" directory is loosely documented and seems to be
|
||||
# assumed, as compiler-rt is usually build at the same time as Clang and not
|
||||
# standalone.
|
||||
define COMPILER_RT_SETUP_RUNTIME_LIBS
|
||||
mkdir -p $(HOST_DIR)/lib/clang/$(HOST_CLANG_VERSION)/lib
|
||||
ln -sf ../../../../$(GNU_TARGET_NAME)/sysroot/usr/lib/linux $(HOST_DIR)/lib/clang/$(HOST_CLANG_VERSION)/lib/linux
|
||||
ln -sf ../../../../$(GNU_TARGET_NAME)/sysroot/usr/share $(HOST_DIR)/lib/clang/$(HOST_CLANG_VERSION)/share
|
||||
endef
|
||||
COMPILER_RT_POST_INSTALL_STAGING_HOOKS += COMPILER_RT_SETUP_RUNTIME_LIBS
|
||||
|
||||
$(eval $(cmake-package))
|
@ -214,8 +214,7 @@ HOST_LLVM_CONF_OPTS += \
|
||||
# We need to activate LLVM_INCLUDE_TOOLS, otherwise it does not generate
|
||||
# libLLVM.so
|
||||
LLVM_CONF_OPTS += \
|
||||
-DLLVM_INCLUDE_TOOLS=ON \
|
||||
-DLLVM_BUILD_TOOLS=OFF
|
||||
-DLLVM_INCLUDE_TOOLS=ON
|
||||
|
||||
ifeq ($(BR2_PACKAGE_LLVM_RTTI),y)
|
||||
HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_RTTI=ON
|
||||
@ -278,11 +277,25 @@ LLVM_CONF_OPTS += \
|
||||
# directories from STAGING_DIR.
|
||||
# output/staging/usr/bin/llvm-config --includedir
|
||||
# output/staging/usr/include
|
||||
define HOST_LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
|
||||
define LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
|
||||
$(INSTALL) -D -m 0755 $(HOST_DIR)/bin/llvm-config \
|
||||
$(STAGING_DIR)/usr/bin/llvm-config
|
||||
endef
|
||||
HOST_LLVM_POST_INSTALL_HOOKS = HOST_LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
|
||||
HOST_LLVM_POST_INSTALL_HOOKS = LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
|
||||
|
||||
# The llvm-symbolizer binary is used by the Compiler-RT Fuzzer
|
||||
# and AddressSanitizer tools on the target for stack traces.
|
||||
# If we set -DLLVM_BUILD_TOOLS=ON this will also install the llvm-config
|
||||
# target binary to STAGING_DIR, which means we can no longer run it.
|
||||
# Therefore, overwrite it again with the host llvm-config.
|
||||
ifeq ($(BR2_PACKAGE_COMPILER_RT),y)
|
||||
LLVM_CONF_OPTS += \
|
||||
-DLLVM_BUILD_TOOLS=ON
|
||||
LLVM_POST_INSTALL_STAGING_HOOKS = LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
|
||||
else
|
||||
LLVM_CONF_OPTS += \
|
||||
-DLLVM_BUILD_TOOLS=OFF
|
||||
endif
|
||||
|
||||
# By default llvm-tblgen is built and installed on the target but it is
|
||||
# not necessary. Also erase LLVMHello.so from /usr/lib
|
||||
|
Loading…
Reference in New Issue
Block a user