-ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
-MAIN_LDFLAGS += -Wl,--no-undefined
+ifeq ($(NO_UNDEF_CHECK)$(shell $(LD) -v 2> /dev/null | awk '{print $$1}'),GNU)
+ ifeq (,$(findstring $(platform),win32))
+ MAIN_LDFLAGS += -Wl,-version-script=frontend/link.T
+ endif
+ ifneq ($(STATIC_LINKING), 1)
+ CFLAGS += -ffunction-sections -fdata-sections
+ endif
+MAIN_LDFLAGS += -Wl,--gc-sections -Wl,--no-undefined