From 2e49e4330d329c58e256ce9c2b865428f3f02307 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 12 Aug 2021 12:33:37 +0900 Subject: [PATCH] Disable debug flag for executable files when LTO [ci skip] Get rid of tons of linker warnings that it could not find object file symbol for every symbols, when targeting darwin. --- defs/gmake.mk | 8 ++++++-- template/Makefile.in | 7 ++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/defs/gmake.mk b/defs/gmake.mk index 557e43b59b..11e677a2d1 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -106,12 +106,16 @@ yes-test-bundler-parallel: PARALLELRSPECOPTS += $(if $(nproc),-n$(shell expr $(n # Cross reference needs to parse all files at once love install reinstall: RDOCFLAGS = --force-update +ifneq ($(if $(filter -flto%,$(CFLAGS)),$(subst darwin,,$(arch)),$(arch)),$(arch)) +override EXE_LDFLAGS = $(filter-out -g%,$(LDFLAGS)) +endif + $(srcdir)/missing/des_tables.c: $(srcdir)/missing/crypt.c ifeq ($(if $(filter yes,$(CROSS_COMPILING)),,$(CC)),) touch $@ else @$(ECHO) building make_des_table - $(CC) $(INCFLAGS) $(CPPFLAGS) -DDUMP $(LDFLAGS) $(XLDFLAGS) $(LIBS) -omake_des_table $(srcdir)/missing/crypt.c + $(CC) $(INCFLAGS) $(CPPFLAGS) -DDUMP $(EXE_LDFLAGS) $(XLDFLAGS) $(LIBS) -omake_des_table $(srcdir)/missing/crypt.c @[ -x ./make_des_table ] @$(ECHO) generating $@ $(Q) $(MAKEDIRS) $(@D) @@ -140,7 +144,7 @@ $(STUBPROGRAM): rubystub.$(OBJEXT) $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SE rubystub$(EXEEXT): @rm -f $@ $(ECHO) linking $@ - $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) rubystub.$(OBJEXT) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@ + $(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) rubystub.$(OBJEXT) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@ $(Q) $(POSTLINK) $(if $(STRIP),$(Q) $(STRIP) $@) diff --git a/template/Makefile.in b/template/Makefile.in index 866fff192f..c382159da5 100644 --- a/template/Makefile.in +++ b/template/Makefile.in @@ -107,6 +107,7 @@ MJIT_MIN_HEADER = $(MJIT_HEADER_BUILD_DIR)/$(MJIT_MIN_HEADER_NAME) MJIT_HEADER_BUILD_DIR = $(EXTOUT)/include/$(arch) MJIT_TABS=@MJIT_TABS@ LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@ +EXE_LDFLAGS = $(LDFLAGS) EXTLDFLAGS = @EXTLDFLAGS@ XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS) EXTLIBS = @@ -274,13 +275,13 @@ all: miniruby$(EXEEXT): @-if test -f $@; then $(MV) -f $@ $@.old; $(RM) $@.old; fi $(ECHO) linking $@ - $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(MAINLIBS) $(LIBS) $(OUTFLAG)$@ + $(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(MAINLIBS) $(LIBS) $(OUTFLAG)$@ $(Q) $(POSTLINK) $(PROGRAM): @$(RM) $@ $(ECHO) linking $@ - $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@ + $(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@ $(Q) $(POSTLINK) PRE_LIBRUBY_UPDATE = [ -n "$(LIBRUBY_SO_UPDATE)" ] || $(gnumake:yes=exec) $(RM) $(LIBRUBY_EXTS) @@ -297,7 +298,7 @@ $(LIBRUBY_A): verify-static-library: $(LIBRUBY_A) $(ECHO) verifying static-library $@ - @$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(LIBRUBY_A) $(MAINLIBS) $(EXTLIBS) $(LIBS) $(OUTFLAG)conftest$(EXEEXT) + @$(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(LIBRUBY_A) $(MAINLIBS) $(EXTLIBS) $(LIBS) $(OUTFLAG)conftest$(EXEEXT) @$(RMALL) conftest$(EXEEXT) conftest.c conftest.dSYM $(LIBRUBY_SO):