mhz: respect CC and CFLAGS passed by buildsystem
authorRobert Marko <robimarko@gmail.com>
Sat, 2 Sep 2023 15:46:46 +0000 (17:46 +0200)
committerJosef Schlehofer <pepe.schlehofer@gmail.com>
Sun, 3 Sep 2023 08:44:35 +0000 (10:44 +0200)
It seems that the Makefile has both CC and CFLAGS hardcoded and does not
allow overriding them by ones being passed by the buildsystem.

This works fine until CONFIG_PKG_ASLR_PIE_ALL is selected, then building
will fail with:
arm-openwrt-linux-muslgnueabi/bin/ld.bfd: mhz.o: relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
arm-openwrt-linux-muslgnueabi/bin/ld.bfd: mhz.o(.text+0x75c): unresolvable R_ARM_CALL relocation against symbol `__aeabi_l2d@@GCC_3.5

So, lets add a patch pending upstream that allows both CC and CFLAGS to be
overriden so that ones passed by the buildsystem are actually respected.

Fixes: 89123b308f98 ("mhz: add new package")
Signed-off-by: Robert Marko <robimarko@gmail.com>
(cherry picked from commit 6c28f46f37d35dce06c320d9ac7f256c113aea22)

utils/mhz/Makefile
utils/mhz/patches/0001-Makefile-allow-overriding-CC-and-CFLAGS.patch [new file with mode: 0644]

index fa8108917ebd9de1edd7cdbc4d7a9591db9f759e..ac874a068c6162ceaf724c184d01921b5bdb9f28 100644 (file)
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=mhz
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=https://github.com/wtarreau/mhz.git
diff --git a/utils/mhz/patches/0001-Makefile-allow-overriding-CC-and-CFLAGS.patch b/utils/mhz/patches/0001-Makefile-allow-overriding-CC-and-CFLAGS.patch
new file mode 100644 (file)
index 0000000..569bc99
--- /dev/null
@@ -0,0 +1,29 @@
+From d55f7b578eb2126d2e4a7f045321f6ba7df3800a Mon Sep 17 00:00:00 2001
+From: Robert Marko <robimarko@gmail.com>
+Date: Wed, 30 Aug 2023 20:31:07 +0200
+Subject: [PATCH] Makefile: allow overriding CC and CFLAGS
+
+For OpenWrt and Buildroot which support really large amount of different
+architectures and cores it is sometimes required to pass our own CFLAGS.
+This is especially true if hardening options are to be respected.
+
+Also, for cross-compiling CC should be respected as currently it is
+working since both OpenWrt and Buildroot symlink gcc to the cross compiler.
+
+So, lets set the current values as defaults but allow them to be overriden.
+
+Signed-off-by: Robert Marko <robimarko@gmail.com>
+---
+ Makefile | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -1,5 +1,5 @@
+-CC         := gcc
+-CFLAGS     := -O3 -Wall -fomit-frame-pointer
++CC         ?= gcc
++CFLAGS     ?= -O3 -Wall -fomit-frame-pointer
+ all: mhz