Files
buildroot/package/miyoo/retroarch/libretro-mednafen-wswan/0001-Makefile-optimize-pgo-flags.patch

61 lines
2.0 KiB
Diff

From e2d231e9839e27d1c7a2692496c1edc6cb2dec95 Mon Sep 17 00:00:00 2001
From: Apaczer <94932128+Apaczer@users.noreply.github.com>
Date: Sun, 16 Feb 2025 21:00:26 +0100
Subject: [PATCH 1/2] Makefile: optimize & pgo flags
---
Makefile | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index ef2deca..eb8ecbd 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,8 @@ filter_out2 = $(call filter_out1,$(call filter_out1,$1))
unixpath = $(subst \,/,$1)
unixcygpath = /$(subst :,,$(call unixpath,$1))
+PROFILE ?= 0
+
# system platform
ifeq ($(platform),)
platform = unix
@@ -329,9 +331,23 @@ else ifeq ($(platform), miyoo)
CC = /opt/miyoo/usr/bin/arm-linux-gcc
CXX = /opt/miyoo/usr/bin/arm-linux-g++
AR = /opt/miyoo/usr/bin/arm-linux-ar
- fpic := -fPIC
+ LIBC ?= $(shell $(CC) -print-file-name=libc.so | grep -q musl && echo "musl" || echo "glibc")
+ifeq ($(LIBC),musl)
+ fpic := -fPIC # brakes otherwise shared object core when profiling with gcc
+else
+ fpic := -fno-PIC
+endif
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
- FLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s
+ FLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s \
+ -fdata-sections -ffunction-sections -Wl,--gc-sections \
+ -fno-stack-protector -fno-ident -fomit-frame-pointer \
+ -fno-unroll-loops
+ifeq ($(PROFILE), YES)
+ FLAGS += -fprofile-generate=/mnt/profile # rm path if you want dir structure intact at runtime
+ LDFLAGS += -lgcov
+else ifeq ($(PROFILE), APPLY)
+ FLAGS += -fprofile-use -fbranch-probabilities -Wno-error=coverage-mismatch
+endif
# Windows MSVC 2017 all architectures
else ifneq (,$(findstring windows_msvc2017,$(platform)))
@@ -566,7 +582,7 @@ all: $(TARGET)
ifeq ($(DEBUG),1)
FLAGS += -O0 -g
else
- FLAGS += -O2 -DNDEBUG $(EXTRA_GCC_FLAGS)
+ FLAGS += -Ofast -DNDEBUG $(EXTRA_GCC_FLAGS)
endif
ifneq (,$(findstring msvc,$(platform)))
--
2.45.2.windows.1