about summary refs log tree commit diff
path: root/Makeconfig
diff options
context:
space:
mode:
Diffstat (limited to 'Makeconfig')
-rw-r--r--Makeconfig11
1 files changed, 9 insertions, 2 deletions
diff --git a/Makeconfig b/Makeconfig
index 0ebe04392b..23db67ff33 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -267,11 +267,18 @@ endif
 
 # Command for linking programs with the C library.
 ifndef +link
-+link = $(CC) -nostdlib $(LDFLAGS) -o $@ \
++link = $(CC) -nostdlib -nostartfiles $(LDFLAGS) -o $@ \
 	$(addprefix $(csu-objpfx),start.o $(+preinit)) \
-	$(^:lib=$(common-objpfx)libc.a) $(gnulib) $(common-objpfx)libc.a \
+	$(^:$(common-objpfx)libc.a=$(link-libc)) \
 	$(addprefix $(csu-objpfx),$(+postinit))
 endif
+ifndef link-libc
+ifeq (yes,$(build-shared))
+link-libc = -L$(common-objdir) -lc $(gnulib)
+else
+link-libc = $(common-objpfx)libc.a $(gnulib) $(common-objpfx)libc.a
+endif
+endif
 ifndef gnulib
 gnulib := -lgcc
 endif