tools/dwarves: add host package
authorTony Ambardar <itugrok@yahoo.com>
Tue, 24 Nov 2020 22:15:09 +0000 (14:15 -0800)
committerFelix Fietkau <nbd@nbd.name>
Sat, 11 Dec 2021 12:53:01 +0000 (13:53 +0100)
dwarves is a set of tools that use the debugging information inserted in
ELF binaries by compilers such as GCC. Utilities in the dwarves suite
include pahole, which can be used to find alignment holes in structs and
classes, and also extracts other information such as CPU cacheline
alignment, helping pack those structures to achieve more cache hits.

These tools are also used to encode and read the BTF type information
format used with the bpf syscall, making this a Linux build dependency
when using kernel BTF information.

Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
toolchain/Config.in
tools/Makefile
tools/dwarves/Makefile [new file with mode: 0644]

index 366f5c8b486c462372ae3f1f187a363c249c531e..fb14006055582e051840c21ed0c07d1d4aa0ca86 100644 (file)
@@ -247,6 +247,14 @@ comment "Binary tools"
 
 source "toolchain/binutils/Config.in"
 
+config DWARVES
+       bool
+       prompt "Build pahole" if TOOLCHAINOPTS
+       depends on !HOST_OS_MACOS
+       default n
+       help
+         Enable if you want to build pahole and the dwarves tools.
+
 comment "Compiler"
        depends on TOOLCHAINOPTS
 
index 686d5294d3e7fbad517a99ce6a3b120456003737..d7d18835849c8a90ad246cd07f8601a1943df70c 100644 (file)
@@ -36,6 +36,7 @@ tools-$(CONFIG_TARGET_tegra) += cbootimage cbootimage-configs
 tools-$(CONFIG_USES_MINOR) += kernel2minor
 tools-$(CONFIG_USE_SPARSE) += sparse
 tools-$(CONFIG_USE_LLVM_BUILD) += llvm-bpf
+tools-$(CONFIG_DWARVES) += dwarves
 
 # builddir dependencies
 $(curdir)/autoconf/compile := $(curdir)/m4/compile
diff --git a/tools/dwarves/Makefile b/tools/dwarves/Makefile
new file mode 100644 (file)
index 0000000..2fa7469
--- /dev/null
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=dwarves
+
+PKG_SOURCE_VERSION:=v1.21
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://git.kernel.org/pub/scm/devel/pahole/pahole.git
+PKG_MIRROR_HASH:=da617b5a6ef93e0a1dabd7e4b21212644a3797df2fa11c98e64533ce1358c042
+PKG_LICENSE:=GPL-2.0-only
+PKG_LICENSE_FILES:=COPYING
+
+HOST_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+CMAKE_HOST_OPTIONS += \
+       -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH \
+       -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \
+       -DCMAKE_BUILD_TYPE=Release \
+       -D__LIB=lib \
+       -DCMAKE_INSTALL_RPATH="$(STAGING_DIR_HOST)/lib" \
+       -DCMAKE_SKIP_RPATH=FALSE
+
+define Host/Clean
+       rm -f $(STAGING_DIR_HOST)/bin/{codiff,ctracer,dtagnames,pahole,pdwtags}
+       rm -f $(STAGING_DIR_HOST)/bin/{pfunct,pglobal,prefcnt,scncopy,syscse}
+       rm -f $(STAGING_DIR_HOST)/bin/{ostra-cg,btfdiff,fullcircle}
+       rm -f $(STAGING_DIR_HOST)/lib/libdwarves*.so*
+       rm -f $(STAGING_DIR_HOST)/share/man/man1/pahole.1
+       rm -rf $(STAGING_DIR_HOST)/include/dwarves
+       rm -rf $(STAGING_DIR_HOST)/share/dwarves
+       $(call Host/Clean/Default)
+endef
+
+$(eval $(call HostBuild))