git: bb383ff0fbcb - main - benchmarks/unixbench: remove march optimization

From: Luca Pizzamiglio <pizzamig_at_FreeBSD.org>
Date: Sun, 26 Mar 2023 14:52:35 UTC
The branch main has been updated by pizzamig:

URL: https://cgit.FreeBSD.org/ports/commit/?id=bb383ff0fbcb0e4cc3f73da30b2f04266da14d30

commit bb383ff0fbcb0e4cc3f73da30b2f04266da14d30
Author:     Luca Pizzamiglio <pizzamig@FreeBSD.org>
AuthorDate: 2023-03-26 14:51:28 +0000
Commit:     Luca Pizzamiglio <pizzamig@FreeBSD.org>
CommitDate: 2023-03-26 14:51:28 +0000

    benchmarks/unixbench: remove march optimization
    
    Introducing OPTIMIZED_CFLAGS option to enable march.
    march is disable by default, as pkg shouldn't be build with this kind
    of low level optimization.
---
 benchmarks/unixbench/Makefile             | 11 +++++++++++
 benchmarks/unixbench/files/patch-Makefile | 32 -------------------------------
 2 files changed, 11 insertions(+), 32 deletions(-)

diff --git a/benchmarks/unixbench/Makefile b/benchmarks/unixbench/Makefile
index 81d71c91c934..71b578e03425 100644
--- a/benchmarks/unixbench/Makefile
+++ b/benchmarks/unixbench/Makefile
@@ -2,6 +2,7 @@ PORTNAME=	unixbench
 DISTVERSIONPREFIX=	v
 DISTVERSION=	5.1.3-51
 DISTVERSIONSUFFIX=	-g6705203
+PORTREVISION=	1
 CATEGORIES=	benchmarks
 
 MAINTAINER=	pizzamig@FreeBSD.org
@@ -22,9 +23,19 @@ USE_XORG=	x11 xext
 CFLAGS+=	-I${LOCALBASE}/include \
 			-L${LOCALBASE}/lib
 
+OPTIONS_DEFINE=	OPTIMIZED_CFLAGS
+OPTIONS_EXCLUDE_aarch64=	OPTIMIZED_CFLAGS
+MAKE_ENV=	"UB_GCC_OPTIONS=-O3 -ffast-math -fomit-frame-pointer"
+#march generates code that can be incompatibe with previous CPU generations
+OPTIMIZED_CFLAGS_MAKE_ENV=	"UB_GCC_OPTIONS=-O3 -ffast-math -fomit-frame-pointer -march=native"
+
 SUB_FILES=	unixbench
 SHEBANG_FILES=	Run pgms/gfx-x11
 
+post-patch:
+	${REINPLACE_CMD} -e 's/^CC=gcc/#CC=gcc/' ${WRKSRC}/Makefile
+	${REINPLACE_CMD} -e 's/^# GRAPHIC_TESTS = defined/GRAPHIC_TESTS = defined/' ${WRKSRC}/Makefile
+
 do-install:
 	${INSTALL_SCRIPT} ${WRKDIR}/unixbench ${STAGEDIR}${PREFIX}/bin/
 	${MKDIR} ${STAGEDIR}${PREFIX}/libexec/unixbench
diff --git a/benchmarks/unixbench/files/patch-Makefile b/benchmarks/unixbench/files/patch-Makefile
deleted file mode 100644
index 3c2539dc046d..000000000000
--- a/benchmarks/unixbench/files/patch-Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
---- Makefile.orig	2023-02-07 23:18:07.000000000 +0100
-+++ Makefile	2023-03-26 13:40:57.699042000 +0200
-@@ -46,7 +46,7 @@
- # X11 libraries on your system. (e.g. libX11-devel mesa-libGL-devel)
- #
- # Comment the line out to disable these tests.
--# GRAPHIC_TESTS = defined
-+GRAPHIC_TESTS = defined
- 
- # Set "GL_LIBS" to the libraries needed to link a GL program.
- GL_LIBS = -lGL -lXext -lX11
-@@ -55,7 +55,7 @@
- # COMPILER CONFIGURATION: Set "CC" to the name of the compiler to use
- # to build the binary benchmarks.  You should also set "$cCompiler" in the
- # Run script to the name of the compiler you want to test.
--CC=gcc
-+#CC=gcc
- 
- # OPTIMISATION SETTINGS:
- # Use gcc option if defined UB_GCC_OPTIONS via "Environment variable" or "Command-line arguments".
-@@ -113,6 +113,13 @@
-     CFLAGS += -Wa,-q
-   endif
- 
-+  ifeq ($(OSNAME),FreeBSD)
-+	ifeq ($(ARCH),aarch64)
-+	  OPTON += -fomit-frame-pointer
-+	else
-+	  OPTON += -march=native -mtune=native -fomit-frame-pointer
-+    endif
-+  endif
- endif