Commit f37866e8 by Olivier Hainque Committed by Olivier Hainque

Add support for -nolibc

2018-06-07  Olivier Hainque  <hainque@adacore.com>

	* common.opt (nolibc): New option.
	* doc/invoke.texi (Link Options): Document it.
	* gcc.c (LINK_GCC_C_SEQUENCE_SPEC): Honor nolibc.
	* config/alpha/linux.h: Likewise.
	* config/arc/elf.h: Likewise.
	* config/arm/uclinux-elf.h: Likewise.
	* config/arm/unknown-elf.h: Likewise.
	* config/avr/avrlibc.h: Likewise.
	* config/bfin/bfin.h: Likewise.
	* config/bfin/linux.h: Likewise.
	* config/bfin/uclinux.h: Likewise.
	* config/darwin.h: Likewise.
	* config/darwin10.h: Likewise.
	* config/darwin12.h: Likewise.
	* config/gnu-user.h: Likewise.
	* config/lm32/uclinux-elf.h: Likewise.
	* config/pa/pa-hpux11.h: Likewise.
	* config/pa/pa64-hpux.h: Likewise.
	* config/sparc/sparc.h: Likewise.

From-SVN: r263083
parent 1d4a51cf
2018-07-31 Olivier Hainque <hainque@adacore.com>
* common.opt (nolibc): New option.
* doc/invoke.texi (Link Options): Document it.
* gcc.c (LINK_GCC_C_SEQUENCE_SPEC): Honor nolibc.
* config/alpha/linux.h: Likewise.
* config/arc/elf.h: Likewise.
* config/arm/uclinux-elf.h: Likewise.
* config/arm/unknown-elf.h: Likewise.
* config/avr/avrlibc.h: Likewise.
* config/bfin/bfin.h: Likewise.
* config/bfin/linux.h: Likewise.
* config/bfin/uclinux.h: Likewise.
* config/darwin.h: Likewise.
* config/darwin10.h: Likewise.
* config/darwin12.h: Likewise.
* config/gnu-user.h: Likewise.
* config/lm32/uclinux-elf.h: Likewise.
* config/pa/pa-hpux11.h: Likewise.
* config/pa/pa64-hpux.h: Likewise.
* config/sparc/sparc.h: Likewise.
2018-07-31 Olivier Hainque <hainque@adacore.com>
* gcc.c (getenv_spec_function): Prepend '/' to value for allowed
undefined variables.
......
......@@ -3040,6 +3040,9 @@ Driver
nostartfiles
Driver
nolibc
Driver
nostdlib
Driver
......
......@@ -105,7 +105,7 @@ along with GCC; see the file COPYING3. If not see
%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
#define LINK_GCC_C_SEQUENCE_SPEC \
"%{static|static-pie:--start-group} %G %L \
"%{static|static-pie:--start-group} %G %{!nolibc:%L} \
%{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}"
/* Use --as-needed -lgcc_s for eh support. */
......
......@@ -77,4 +77,4 @@ along with GCC; see the file COPYING3. If not see
/* If no specs file is enforced, default to nosys libarary. */
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC \
"--start-group %G %{!specs=*:-lc -lnosys} --end-group"
"--start-group %G %{!specs=*:%{!nolibc:-lc -lnosys}} --end-group"
......@@ -67,8 +67,8 @@
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC \
"%{static|static-pie:--start-group} %G %L \
%{static|static-pie:--end-group}%{!static:%{!static-pie:%G %L}}"
"%{static|static-pie:--start-group} %G %{!nolibc:%L} \
%{static|static-pie:--end-group}%{!static:%{!static-pie:%G %{!nolibc:%L}}}"
/* Use --as-needed -lgcc_s for eh support. */
#ifdef HAVE_LD_AS_NEEDED
......
......@@ -93,4 +93,4 @@
udivmoddi4, which will depend on the exception unwind routines,
which will depend on abort, which is defined in libc. */
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC "--start-group %G %L --end-group"
#define LINK_GCC_C_SEQUENCE_SPEC "--start-group %G %{!nolibc:%L} --end-group"
......@@ -37,4 +37,4 @@ along with GCC; see the file COPYING3. If not see
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC \
"--start-group %G %L --end-group"
"--start-group %G %{!nolibc:%L} --end-group"
......@@ -204,7 +204,7 @@
#endif
#define LINK_GCC_C_SEQUENCE_SPEC "\
%{mfast-fp:-lbffastfp} %G %L %{mfast-fp:-lbffastfp} %G \
%{mfast-fp:-lbffastfp} %G %{!nolibc:%L} %{mfast-fp:-lbffastfp} %G \
"
#undef ASM_SPEC
......
......@@ -35,7 +35,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC \
"%{static|static-pie:--start-group} %{mfast-fp:-lbffastfp} %G %L \
"%{static|static-pie:--start-group} %{mfast-fp:-lbffastfp} %G %{!nolibc:%L} \
%{static|static-pie:--end-group} \
%{!static:%{!static-pie:%{mfast-fp:-lbffastfp} %G}}"
......
......@@ -29,7 +29,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC "\
%{mfast-fp:-lbffastfp} %G %L %{mfast-fp:-lbffastfp} %G \
%{mfast-fp:-lbffastfp} %G %{!nolibc:%L} %{mfast-fp:-lbffastfp} %G \
"
#undef TARGET_SUPPORTS_SYNC_CALLS
......
......@@ -210,7 +210,7 @@ extern GTY(()) int darwin_ms_struct;
/* We only want one instance of %G, since libSystem (Darwin's -lc) does not depend
on libgcc. */
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC "%G %L"
#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L}"
/* ld64 supports a sysroot, it just has a different name and there's no easy
way to check for it at config time. */
......
......@@ -28,7 +28,7 @@ along with GCC; see the file COPYING3. If not see
%{!static:%{!static-libgcc: \
%:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \
%{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \
%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %L"
%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %{!nolibc:%L}"
#undef DEF_MIN_OSX_VERSION
#define DEF_MIN_OSX_VERSION "10.6"
......
......@@ -24,7 +24,7 @@ along with GCC; see the file COPYING3. If not see
%{!static:%{!static-libgcc: \
%:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \
%{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \
%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %L"
%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %{!nolibc:%L}"
#undef DEF_MIN_OSX_VERSION
#define DEF_MIN_OSX_VERSION "10.8"
......
......@@ -135,7 +135,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC \
"%{static|static-pie:--start-group} %G %L \
"%{static|static-pie:--start-group} %G %{!nolibc:%L} \
%{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}"
/* Use --as-needed -lgcc_s for eh support. */
......
......@@ -68,7 +68,7 @@
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
#define LINK_GCC_C_SEQUENCE_SPEC \
"%{static|static-pie:--start-group} %G %L \
"%{static|static-pie:--start-group} %G %{!nolibc:%L} \
%{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}"
#undef CC1_SPEC
......
......@@ -157,7 +157,7 @@ along with GCC; see the file COPYING3. If not see
/* The libgcc_stub.a library needs to come last. */
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC \
"%G %L %G %{!nostdlib:%{!nodefaultlibs:%{!shared:-lgcc_stub}}}"
"%G %{!nolibc:%L} %G %{!nostdlib:%{!nodefaultlibs:%{!shared:-lgcc_stub}}}"
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
......
......@@ -106,7 +106,7 @@ along with GCC; see the file COPYING3. If not see
/* The libgcc_stub.a and milli.a libraries need to come last. */
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC "\
%G %L %G %{!nostdlib:%{!nodefaultlibs:%{!shared:-lgcc_stub}\
%G %{!nolibc:%L} %G %{!nostdlib:%{!nodefaultlibs:%{!shared:-lgcc_stub}\
milli.a%s}}"
/* Under hpux11, the normal location of the `ld' and `as' programs is the
......
......@@ -420,7 +420,7 @@ extern enum cmodel sparc_cmodel;
/* Because libgcc can generate references back to libc (via .umul etc.) we have
to list libc again after the second libgcc. */
#define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G %L"
#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L} %G %{!nolibc:%L}"
#define PTRDIFF_TYPE (TARGET_ARCH64 ? "long int" : "int")
......
......@@ -517,7 +517,8 @@ Objective-C and Objective-C++ Dialects}.
@item Linker Options
@xref{Link Options,,Options for Linking}.
@gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol
-nostartfiles -nodefaultlibs -nostdlib -pie -pthread -rdynamic @gol
-nostartfiles -nodefaultlibs -nolibc -nostdlib @gol
-pie -pthread -rdynamic @gol
-s -static -static-pie -static-libgcc -static-libstdc++ @gol
-static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
-shared -shared-libgcc -symbolic @gol
......@@ -12350,8 +12351,8 @@ link an Objective-C or Objective-C++ program.
@item -nostartfiles
@opindex nostartfiles
Do not use the standard system startup files when linking.
The standard system libraries are used normally, unless @option{-nostdlib}
or @option{-nodefaultlibs} is used.
The standard system libraries are used normally, unless @option{-nostdlib},
@option{-nolibc}, or @option{-nodefaultlibs} is used.
@item -nodefaultlibs
@opindex nodefaultlibs
......@@ -12368,6 +12369,18 @@ These entries are usually resolved by entries in
libc. These entry points should be supplied through some other
mechanism when this option is specified.
@item -nolibc
@opindex nolibc
Do not use the C library or system libraries tightly coupled with it when
linking. Still link with the startup files, @file{libgcc} or toolchain
provided language support libraries such as @file{libgnat}, @file{libgfortran}
or @file{libstdc++} unless options preventing their inclusion are used as
well. This typically removes @option{-lc} from the link command line, as well
as system libraries that normally go with it and become meaningless when
absence of a C library is assumed, for example @option{-lpthread} or
@option{-lm} in some configurations. This is intended for bare-board
targets when there is indeed no C library available.
@item -nostdlib
@opindex nostdlib
Do not use the standard system startup files or libraries when linking.
......@@ -872,7 +872,7 @@ proper position among the other output files. */
-lgcc and -lc order specially, yet not require them to override all
of LINK_COMMAND_SPEC. */
#ifndef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G"
#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
#endif
#ifndef LINK_SSP_SPEC
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment