From bda868ef3602abcdd32a9af105a2458cb460f553 Mon Sep 17 00:00:00 2001 From: n30f0x <87524177+n30f0x@users.noreply.github.com> Date: Fri, 1 Nov 2024 03:26:34 +0400 Subject: [PATCH] Makefile: macos fixup: generate proper symbols on debug with LTO, separate options from serenity --- Makefile | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 530e57d7..4eaf6dd8 100644 --- a/Makefile +++ b/Makefile @@ -178,9 +178,6 @@ else override BIN_EXT := ifeq ($(OS),darwin) override LIB_EXT := .dylib -ifdef USE_EXPERIMENTAL_SHIT -override LDFLAGS := -lobjc -framework Cocoa -endif else override LIB_EXT := .so endif @@ -211,8 +208,23 @@ ifneq (,$(findstring linux,$(OS))$(findstring bsd,$(OS))$(findstring sunos,$(OS) USE_X11 ?= 1 endif -ifneq (,$(findstring darwin,$(OS))$(findstring serenity,$(OS))) -# Enable SDL2 on Darwin, Serenity by default +ifneq (,$(findstring darwin,$(OS))) +# Enable SDL2 on Darwin by default +USE_SDL ?= 2 +ifeq ($(USE_ISOLATION),1) +# Foundation/Cocoa runtime +override LDFLAGS += -lobjc -framework Cocoa +endif +ifneq (,1 $(filter$(LTO_SUPPORTED,$(filter 1,$(USE_DEBUG)$(USE_DEBUG_FULL))))) +# Generate symbols with lto on debug on darwin>=15.x +override LDFLAGS += -Wl,-object_path_lto,$(BUILDDIR)/obj/lto +# Generate dSYM symbol bundle explicitly on debug on darwin>=15.x +override CFLAGS += -dsym-dir $(BUILDDIR)/$(BINARY).dSYM +endif +endif + +ifneq (,$(findstring serenity,$(OS))) +# Enable SDL2 on Serenity by default USE_SDL ?= 2 endif @@ -561,7 +573,10 @@ endif # Sign binaries on MacOS host ifneq (,$(if $(findstring darwin,$(OS)),$(shell which codesign $(NULL_STDERR)))) ENTITLEMENTS = $(SRCDIR)/bindings/macos_codesign/rvvm.entitlements -override CODESIGN = plutil $(ENTITLEMENTS) && codesign -s - -o library,runtime --timestamp --verbose=4 --verify --strict --entitlements $(ENTITLEMENTS) $@ && spctl --assess --verbose=4 --type execute $@ +override ENT = $(info $(WHITE)[$(GREEN)ENT$(WHITE)] $(shell plutil $(ENTITLEMENTS))$(RESET)) +# override CODESIGN = $(info $(WHITE)[$(GREEN)CODESIGN$(WHITE)] $(shell codesign -s - -o runtime,library --timestamp --preserve-metadata=entitlements,requirements,flags,runtime --entitlements $(ENTITLEMENTS) $@)$(RESET)) +override CODESIGN = codesign -s - -o runtime,library --timestamp --preserve-metadata=entitlements,requirements,flags,runtime --entitlements $(ENTITLEMENTS) $@ +override VERIFY = $(info $(WHITE)[$(GREEN)VERIFY$(WHITE)] $(shell spctl --assess --verbose=4 --type execute $@) $(RESET)) endif # @@ -592,13 +607,17 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp Makefile $(BINARY): $(OBJS) $(info $(WHITE)[$(GREEN)LD$(WHITE)] $@ $(RESET)) @$(CC_LD) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $@ -# @$(CODESIGN) + @$(ENT) + @$(CODESIGN) + @$(VERIFY) # Shared library $(SHARED): $(LIB_OBJS) $(info $(WHITE)[$(GREEN)LD$(WHITE)] $@ $(RESET)) @$(CC_LD) $(CFLAGS) $(LIB_OBJS) $(LDFLAGS) -shared -o $@ -# @$(CODESIGN) + @$(ENT) + @$(CODESIGN) + @$(VERIFY) # Static library $(STATIC): $(LIB_OBJS)