diff mbox series

[2/2] package/binutils: add BPF support

Message ID 20220809094109.2279598-2-james.hilliard1@gmail.com
State Changes Requested
Headers show
Series [1/2] package/gcc/gcc-bpf: add BPF target support | expand

Commit Message

James Hilliard Aug. 9, 2022, 9:41 a.m. UTC
In order for our BPF target builds to work correctly we also need to
build BPF targeted binutils.

To build BPF binutils at the same time as our normal binutils use an
isolated build directory similar to the one created by
HOST_GCC_CONFIGURE_SYMLINK and execute the build stages for both
targets.

Cc: Jose E. Marchesi <jose.marchesi@oracle.com>
Cc: David Faust <david.faust@oracle.com>
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 package/binutils/Config.in.host |   5 ++
 package/binutils/binutils.mk    | 100 ++++++++++++++++++++++++++++++--
 2 files changed, 101 insertions(+), 4 deletions(-)

Comments

Arnout Vandecappelle Sept. 30, 2023, 3:22 p.m. UTC | #1
On 09/08/2022 11:41, James Hilliard wrote:
> In order for our BPF target builds to work correctly we also need to
> build BPF targeted binutils.
> 
> To build BPF binutils at the same time as our normal binutils use an
> isolated build directory similar to the one created by
> HOST_GCC_CONFIGURE_SYMLINK and execute the build stages for both
> targets.

  Again, I think it's better to make this a binutils-bpf package that shares no 
logic with binutils, and has a fixed version.


  Regards,
  Arnout

> 
> Cc: Jose E. Marchesi <jose.marchesi@oracle.com>
> Cc: David Faust <david.faust@oracle.com>
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
[snip]
diff mbox series

Patch

diff --git a/package/binutils/Config.in.host b/package/binutils/Config.in.host
index 9fa0cc4e8d..be46a12ae0 100644
--- a/package/binutils/Config.in.host
+++ b/package/binutils/Config.in.host
@@ -1,5 +1,10 @@ 
 comment "Binutils Options"
 
+config BR2_PACKAGE_HOST_BINUTILS_SUPPORTS_BPF
+	bool
+	default y if BR2_BINUTILS_VERSION_2_37_X
+	default y if BR2_BINUTILS_VERSION_2_38_X
+
 config BR2_PACKAGE_HOST_BINUTILS_SUPPORTS_CFI
 	bool
 	default y
diff --git a/package/binutils/binutils.mk b/package/binutils/binutils.mk
index 6362cb1641..78fd26b612 100644
--- a/package/binutils/binutils.mk
+++ b/package/binutils/binutils.mk
@@ -77,24 +77,116 @@  endif
 
 # "host" binutils should actually be "cross"
 # We just keep the convention of "host utility" for now
-HOST_BINUTILS_CONF_OPTS = \
+HOST_BINUTILS_COMMON_CONF_OPTS = \
+	--prefix="$(HOST_DIR)" \
+	--sysconfdir="$(HOST_DIR)/etc" \
+	--localstatedir="$(HOST_DIR)/var" \
 	--disable-multilib \
 	--disable-werror \
-	--target=$(GNU_TARGET_NAME) \
 	--disable-shared \
 	--enable-static \
-	--with-sysroot=$(STAGING_DIR) \
-	--enable-poison-system-directories \
+	--disable-gtk-doc \
+	--disable-gtk-doc-html \
+	--disable-doc \
+	--disable-docs \
+	--disable-documentation \
+	--disable-debug \
+	--with-xmlto=no \
+	--with-fop=no \
+	--disable-nls \
 	--without-debuginfod \
 	--enable-plugins \
 	--enable-lto \
 	$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
 	$(BINUTILS_EXTRA_CONFIG_OPTIONS)
 
+HOST_BINUTILS_CONF_OPTS = \
+	$(HOST_BINUTILS_COMMON_CONF_OPTS) \
+	--target=$(GNU_TARGET_NAME) \
+	--with-sysroot=$(STAGING_DIR)
+
+HOST_BINUTILS_BPF_CONF_OPTS = \
+	$(HOST_BINUTILS_COMMON_CONF_OPTS) \
+	--target=$(BPF_TARGET_NAME)
+
 # binutils run configure script of subdirs at make time, so ensure
 # our TARGET_CONFIGURE_ARGS are taken into consideration for those
 BINUTILS_MAKE_ENV = $(TARGET_CONFIGURE_ARGS)
 
+HOST_BINUTILS_TARGET_BUILDDIR = build
+HOST_BINUTILS_BPF_BUILDDIR = build-bpf
+
+define HOST_BINUTILS_TARGET_CONFIGURE_SYMLINK
+	mkdir -p $(@D)/$(HOST_BINUTILS_TARGET_BUILDDIR)
+	ln -sf ../configure $(@D)/$(HOST_BINUTILS_TARGET_BUILDDIR)/configure
+endef
+HOST_BINUTILS_PRE_CONFIGURE_HOOKS += HOST_BINUTILS_TARGET_CONFIGURE_SYMLINK
+
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT_BPF),y)
+define HOST_BINUTILS_BPF_CONFIGURE_SYMLINK
+	mkdir -p $(@D)/$(HOST_BINUTILS_BPF_BUILDDIR)
+	ln -sf ../configure $(@D)/$(HOST_BINUTILS_BPF_BUILDDIR)/configure
+endef
+HOST_BINUTILS_PRE_CONFIGURE_HOOKS += HOST_BINUTILS_BPF_CONFIGURE_SYMLINK
+endif
+
+define HOST_BINUTILS_TARGET_CONFIGURE_CMDS
+	(cd $(@D)/$(HOST_BINUTILS_TARGET_BUILDDIR) && rm -rf config.cache; \
+		$(HOST_CONFIGURE_OPTS) \
+		CFLAGS="$(HOST_CFLAGS)" \
+		LDFLAGS="$(HOST_LDFLAGS)" \
+		$(HOST_BINUTILS_CONF_ENV) \
+		./configure \
+		$(QUIET) $(HOST_BINUTILS_CONF_OPTS) \
+	)
+endef
+
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT_BPF),y)
+define HOST_BINUTILS_BPF_CONFIGURE_CMDS
+	(cd $(@D)/$(HOST_BINUTILS_BPF_BUILDDIR) && rm -rf config.cache; \
+		$(HOST_CONFIGURE_OPTS) \
+		CFLAGS="$(HOST_CFLAGS)" \
+		LDFLAGS="$(HOST_LDFLAGS)" \
+		$(HOST_BINUTILS_CONF_ENV) \
+		./configure \
+		$(QUIET) $(HOST_BINUTILS_BPF_CONF_OPTS) \
+	)
+endef
+endif
+
+define HOST_BINUTILS_CONFIGURE_CMDS
+	$(HOST_BINUTILS_TARGET_CONFIGURE_CMDS)
+	$(HOST_BINUTILS_BPF_CONFIGURE_CMDS)
+endef
+
+define HOST_BINUTILS_TARGET_BUILD_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) $(HOST_BINUTILS_MAKE_OPTS) -C $(@D)/$(HOST_BINUTILS_TARGET_BUILDDIR)
+endef
+
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT_BPF),y)
+define HOST_BINUTILS_BPF_BUILD_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) $(HOST_BINUTILS_MAKE_OPTS) -C $(@D)/$(HOST_BINUTILS_BPF_BUILDDIR)
+endef
+endif
+
+define HOST_BINUTILS_BUILD_CMDS
+	$(HOST_BINUTILS_TARGET_BUILD_CMDS)
+	$(HOST_BINUTILS_BPF_BUILD_CMDS)
+endef
+
+define HOST_BINUTILS_TARGET_INSTALL_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) $(HOST_BINUTILS_INSTALL_OPTS) -C $(@D)/$(HOST_BINUTILS_TARGET_BUILDDIR)
+endef
+
+define HOST_BINUTILS_BPF_INSTALL_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) $(HOST_BINUTILS_INSTALL_OPTS) -C $(@D)/$(HOST_BINUTILS_BPF_BUILDDIR)
+endef
+
+define HOST_BINUTILS_INSTALL_CMDS
+	$(HOST_BINUTILS_TARGET_INSTALL_CMDS)
+	$(HOST_BINUTILS_BPF_INSTALL_CMDS)
+endef
+
 # We just want libbfd, libiberty and libopcodes,
 # not the full-blown binutils in staging
 define BINUTILS_INSTALL_STAGING_CMDS