toolchain: gcc: enable sanitizers for glibc toolchain

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
master
Yousong Zhou 5 years ago
parent ed6ba2801c
commit 69b9f0161e

@ -138,6 +138,122 @@ define Package/libstdcpp/config
endef
define Package/libasan
$(call Package/gcc/Default)
NAME:=libasan
TITLE:=Runtime library for AddressSanitizer in GCC
DEPENDS:=@USE_GLIBC +librt +libstdcpp
ABI_VERSION:=5
endef
define Package/libasan/config
menu "Configuration"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libasan
config LIBASAN_ROOT_DIR
string
prompt "libasan shared library base directory"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libasan
default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
default "/" if NATIVE_TOOLCHAIN
config LIBASAN_FILE_SPEC
string
prompt "libasan shared library files (use wildcards)"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libasan
default "./lib/libasan.so.*"
endmenu
endef
define Package/libtsan
$(call Package/gcc/Default)
NAME:=libtsan
TITLE:=Runtime library for ThreadSanitizer in GCC
DEPENDS:=@USE_GLIBC +librt +libstdcpp
ABI_VERSION:=0
endef
define Package/libtsan/config
menu "Configuration"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libtsan
config LIBTSAN_ROOT_DIR
string
prompt "libtsan shared library base directory"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libtsan
default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
default "/" if NATIVE_TOOLCHAIN
config LIBTSAN_FILE_SPEC
string
prompt "libtsan shared library files (use wildcards)"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libtsan
default "./lib/libtsan.so.*"
endmenu
endef
define Package/liblsan
$(call Package/gcc/Default)
NAME:=liblsan
TITLE:=Runtime library for LeakSanitizer in GCC
DEPENDS:=@USE_GLIBC +librt +libstdcpp
ABI_VERSION:=0
endef
define Package/liblsan/config
menu "Configuration"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_liblsan
config LIBLSAN_ROOT_DIR
string
prompt "liblsan shared library base directory"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_liblsan
default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
default "/" if NATIVE_TOOLCHAIN
config LIBLSAN_FILE_SPEC
string
prompt "liblsan shared library files (use wildcards)"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_liblsan
default "./lib/liblsan.so.*"
endmenu
endef
define Package/libubsan
$(call Package/gcc/Default)
NAME:=libubsan
TITLE:=Runtime library for UndefinedBehaviorSanitizer in GCC
DEPENDS:=@USE_GLIBC +librt +libstdcpp
ABI_VERSION:=1
endef
define Package/libubsan/config
menu "Configuration"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libubsan
config LIBUBSAN_ROOT_DIR
string
prompt "libubsan shared library base directory"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libubsan
default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
default "/" if NATIVE_TOOLCHAIN
config LIBUBSAN_FILE_SPEC
string
prompt "libubsan shared library files (use wildcards)"
depends on EXTERNAL_TOOLCHAIN && PACKAGE_libubsan
default "./lib/libubsan.so.*"
endmenu
endef
define Package/libc/Default
SECTION:=libs
CATEGORY:=Base system
@ -413,6 +529,26 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
$(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
endef
define Package/libasan/install
$(INSTALL_DIR) $(1)/lib
$(CP) $(TOOLCHAIN_DIR)/lib/libasan.so.* $(1)/lib/
endef
define Package/libtsan/install
$(INSTALL_DIR) $(1)/lib
$(CP) $(TOOLCHAIN_DIR)/lib/libtsan.so.* $(1)/lib/
endef
define Package/liblsan/install
$(INSTALL_DIR) $(1)/lib
$(CP) $(TOOLCHAIN_DIR)/lib/liblsan.so.* $(1)/lib/
endef
define Package/libubsan/install
$(INSTALL_DIR) $(1)/lib
$(CP) $(TOOLCHAIN_DIR)/lib/libubsan.so.* $(1)/lib/
endef
define Package/glibc/install
$(CP) ./glibc-files/* $(1)/
rm -f $(1)/etc/localtime
@ -550,6 +686,38 @@ else
exit 0
endef
define Package/libasan/install
for file in $(call qstrip,$(CONFIG_LIBASAN_FILE_SPEC)); do \
$(INSTALL_DIR) $(1)/lib ; \
$(CP) $(call qstrip,$(CONFIG_LIBASAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
done ; \
exit 0
endef
define Package/libtsan/install
for file in $(call qstrip,$(CONFIG_LIBTSAN_FILE_SPEC)); do \
$(INSTALL_DIR) $(1)/lib ; \
$(CP) $(call qstrip,$(CONFIG_LIBTSAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
done ; \
exit 0
endef
define Package/liblsan/install
for file in $(call qstrip,$(CONFIG_LIBLSAN_FILE_SPEC)); do \
$(INSTALL_DIR) $(1)/lib ; \
$(CP) $(call qstrip,$(CONFIG_LIBLSAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
done ; \
exit 0
endef
define Package/libubsan/install
for file in $(call qstrip,$(CONFIG_LIBUBSAN_FILE_SPEC)); do \
$(INSTALL_DIR) $(1)/lib ; \
$(CP) $(call qstrip,$(CONFIG_LIBUBSAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
done ; \
exit 0
endef
define Package/libc/install
for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
$(INSTALL_DIR) $(1)/lib ; \
@ -623,6 +791,10 @@ $(eval $(call BuildPackage,libgcc))
$(eval $(call BuildPackage,libatomic))
$(eval $(call BuildPackage,libssp))
$(eval $(call BuildPackage,libstdcpp))
$(eval $(call BuildPackage,libasan))
$(eval $(call BuildPackage,libtsan))
$(eval $(call BuildPackage,liblsan))
$(eval $(call BuildPackage,libubsan))
$(eval $(call BuildPackage,libpthread))
$(eval $(call BuildPackage,libthread-db))
$(eval $(call BuildPackage,librt))

@ -4,7 +4,6 @@ include ../common.mk
GCC_CONFIGURE += \
--with-headers=$(TOOLCHAIN_DIR)/include \
--disable-libsanitizer \
--enable-languages=$(TARGET_LANGUAGES) \
--enable-shared \
--enable-threads \
@ -12,6 +11,10 @@ GCC_CONFIGURE += \
--enable-lto \
--with-libelf=$(TOPDIR)/staging_dir/host
ifndef CONFIG_USE_GLIBC
GCC_CONFIGURE += --disable-libsanitizer
endif
ifdef CONFIG_USE_MUSL
GCC_MAKE += gcc_cv_libc_provides_ssp=yes
endif

Loading…
Cancel
Save