Issue #8009 has been updated by tmm1 (Aman Gupta).


Thanks. Could you backport this to 1.9.3 as well?
----------------------------------------
Backport #8009: `make MAINLIBS=-ltcmalloc` does not work with new versions of gcc
https://bugs.ruby-lang.org/issues/8009#change-37909

Author: tmm1 (Aman Gupta)
Status: Closed
Priority: Normal
Assignee: nagachika (Tomoyuki Chikanaga)
Category: 
Target version: 


With newer versions of gcc, linker arguments must appear after object files.


diff --git a/Makefile.in b/Makefile.in
index 45eb7c6..a93a1e6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -194,12 +194,12 @@ all:
 miniruby$(EXEEXT):
                @-if test -f $@; then $(MV) -f $@ $@.old; $(RM) $@.old; fi
                $(ECHO) linking $@
-               $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(DTRACE_OBJ) $(LIBS) $(OUTFLAG)$@
+               $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(DTRACE_OBJ) $(MAINLIBS) $(LIBS) $(OUTFLAG)$@
 
 $(PROGRAM):
                @$(RM) $@
                $(ECHO) linking $@
-               $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@
+               $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@
                $(Q) $(POSTLINK)
 
 # We must `rm' the library each time this rule is invoked because "updating" a



-- 
http://bugs.ruby-lang.org/