From 94b32c39127967ea58adac3d737a1e5d6116fb77 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 24 Sep 2012 17:31:36 -0700 Subject: Use static link by default for --disable-shared --- Makeconfig | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'Makeconfig') diff --git a/Makeconfig b/Makeconfig index 42b836ee18..e96ebc7e96 100644 --- a/Makeconfig +++ b/Makeconfig @@ -411,22 +411,6 @@ LDFLAGS.so += $(hashstyle-LDFLAGS) LDFLAGS-rtld += $(hashstyle-LDFLAGS) endif -# Commands for linking programs with the C library. -ifndef +link -+link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \ - $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ - $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ - $(addprefix $(csu-objpfx),$(start-installed-name)) \ - $(+preinit) $(+prector) \ - $(filter-out $(addprefix $(csu-objpfx),start.o \ - $(start-installed-name))\ - $(+preinit) $(link-extra-libs) \ - $(common-objpfx)libc% $(+postinit),$^) \ - $(link-extra-libs) -+link-after-libc = $(+postctor) $(+postinit) -+link = $(+link-before-libc) $(link-libc) $(+link-after-libc) -+link-tests = $(+link-before-libc) $(link-libc-tests) $(+link-after-libc) -endif # Command for linking PIE programs with the C library. ifndef +link-pie +link-pie = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \ @@ -457,6 +441,27 @@ ifndef +link-static +link-static-tests = $(+link-static-before-libc) $(link-libc-static-tests) \ $(+link-static-after-libc) endif +# Commands for linking programs with the C library. +ifndef +link +ifeq (yes,$(build-shared)) ++link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \ + $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ + $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ + $(addprefix $(csu-objpfx),$(start-installed-name)) \ + $(+preinit) $(+prector) \ + $(filter-out $(addprefix $(csu-objpfx),start.o \ + $(start-installed-name))\ + $(+preinit) $(link-extra-libs) \ + $(common-objpfx)libc% $(+postinit),$^) \ + $(link-extra-libs) ++link-after-libc = $(+postctor) $(+postinit) ++link = $(+link-before-libc) $(link-libc) $(+link-after-libc) ++link-tests = $(+link-before-libc) $(link-libc-tests) $(+link-after-libc) +else ++link = $(+link-static) ++link-tests = $(+link-static-tests) +endif +endif # Command for statically linking bounded-pointer programs with the C library. ifndef +link-bounded +link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \ @@ -568,7 +573,14 @@ gnulib-arch = gnulib = -lgcc $(gnulib-arch) gnulib-tests := -lgcc $(libgcc_eh) static-gnulib-arch = +# By default, elf/static-stubs.o, instead of -lgcc_eh, is used to +# statically link programs. When --disable-shared is used, we use +# -lgcc_eh since elf/static-stubs.o isn't sufficient. +ifeq (yes,$(build-shared)) static-gnulib = -lgcc $(static-gnulib-arch) +else +static-gnulib = -lgcc -lgcc_eh $(static-gnulib-arch) +endif static-gnulib-tests := -lgcc -lgcc_eh $(libunwind) libc.so-gnulib := -lgcc endif -- cgit 1.4.1