Problem building iozone for bcm27xx/bcm2712 but works fine for x86/64

I put a Makefile together to compile iozone. The build is successful for x86/64 but ld is returning errors when I build for an ARM target. Any thoughts to fix the build are welcome.

include $(TOPDIR)/rules.mk

PKG_NAME:=iozone3
PKG_VERSION:=506
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar
PKG_SOURCE_URL:=https://www.iozone.org/src/current/
PKG_HASH:=114ce5c071873b9a2c7ba6e73d05d5ef7e66564392acbfcdc0b3261db10fcbe7
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)

PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=COPYING

include $(INCLUDE_DIR)/package.mk

define Package/iozone
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=A filesystem benchmark tool
  URL:=http://iozone.org
endef

define Package/iozone/description
 IOzone is a filesystem benchmark tool that can measure
 a variety of file operations.
endef

define Build/Compile
	$(MAKE) -j1 -C $(PKG_BUILD_DIR)/src/current linux-arm \
		CFLAGS="$(TARGET_CFLAGS/-fhonour-copts/)" \
		CXXFLAGS="$(TARGET_CXXFLAGS)" \
		LDFLAGS="$(TARGET_LDFLAGS)" \
		CC="$(TARGET_CC)"
endef

define Package/iozone/install
	$(INSTALL_DIR) $(1)/usr/bin/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/current/iozone $(1)/usr/bin/
endef

$(eval $(call BuildPackage,iozone))

Note that the linux-arm above needs to be changed to linux-AMD64 if building for x86/64.

Here is the build log for bcm27xx/bcm2712
For reference, here is the successful build for x86/64

As a test, I compiled iozone on Arch ARM 64-bit using make -j1 linux-arm and it completed without error and the resulting executable ran just fine.

EDIT: even if I modify the upstream makefile to not build fileop_linux-arm.o, the resulting executable that gets compiled will not run on the OpenWrt device.

--- a/src/current/makefile
+++ b/src/current/makefile
@@ -217,10 +217,9 @@ linux-powerpc64: iozone_linux-powerpc64.
 #
 # GNU 'C' compiler Linux build with threads, largefiles, async I/O 
 #
-linux-arm:     iozone_linux-arm.o  libbif.o libasync.o fileop_linux-arm.o pit_server.o
+linux-arm:     iozone_linux-arm.o  libbif.o libasync.o pit_server.o
        $(CC) -O3 $(LDFLAGS) iozone_linux-arm.o libbif.o libasync.o \
                -lrt -lpthread -o iozone
-       $(CC) -O3 -Dlinux fileop_linux-arm.o -o fileop
        $(CC) -O3 -Dlinux pit_server.o -o pit_server
 #
 # GNU 'C' or Clang compiler Linux build with threads, largefiles, async I/O
exec format error: /usr/bin/iozone

It's like the host is compiling the code, not the cross compiler.

EDIT2: yes, that is what's happening.

# file /usr/bin/iozone
/usr/bin/iozone: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, with debug_info, not stripped

Well, modeling my Build/Compile after utils/lvm2/Makefile fixed the problem. I guess defining those extra variables screwed up the compilation. For reference, the functional below is a patch to build this:

diff --git a/utils/iozone/Makefile b/utils/iozone/Makefile
new file mode 100644
index 000000000000..d92cfa704482
--- /dev/null
+++ b/utils/iozone/Makefile
@@ -0,0 +1,40 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iozone3
+PKG_VERSION:=506
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar
+PKG_SOURCE_URL:=https://www.iozone.org/src/current/
+PKG_HASH:=114ce5c071873b9a2c7ba6e73d05d5ef7e66564392acbfcdc0b3261db10fcbe7
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)
+
+PKG_LICENSE:=GPL-2.0-or-later
+PKG_LICENSE_FILES:=COPYING
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/iozone
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=A filesystem benchmark tool
+  URL:=http://iozone.org
+endef
+
+define Package/iozone/description
+ IOzone is a filesystem benchmark tool that can measure
+ a variety of file operations.
+endef
+
+define Build/Compile
+	$(MAKE) -j1 -C $(PKG_BUILD_DIR)/src/current linux-arm \
+		CC="$(TARGET_CC)" \
+		CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(FPIC)"
+endef
+
+define Package/iozone/install
+	$(INSTALL_DIR) $(1)/usr/bin/
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/current/iozone $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,iozone))
diff --git a/utils/iozone/patches/010-64-bit.patch b/utils/iozone/patches/010-64-bit.patch
new file mode 100644
index 000000000000..2b8bce5dc37a
--- /dev/null
+++ b/utils/iozone/patches/010-64-bit.patch
@@ -0,0 +1,14 @@
+--- a/src/current/makefile
++++ b/src/current/makefile
+@@ -217,10 +217,9 @@ linux-powerpc64: iozone_linux-powerpc64.
+ #
+ # GNU 'C' compiler Linux build with threads, largefiles, async I/O
+ #
+-linux-arm:	iozone_linux-arm.o  libbif.o libasync.o fileop_linux-arm.o pit_server.o
++linux-arm:	iozone_linux-arm.o  libbif.o libasync.o pit_server.o
+ 	$(CC) -O3 $(LDFLAGS) iozone_linux-arm.o libbif.o libasync.o \
+ 		-lrt -lpthread -o iozone
+-	$(CC) -O3 -Dlinux fileop_linux-arm.o -o fileop
+ 	$(CC) -O3 -Dlinux pit_server.o -o pit_server
+ #
+ # GNU 'C' or Clang compiler Linux build with threads, largefiles, async I/O
-- 
2.48.1

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.