diff options
author | Olivier Hainque <hainque@adacore.com> | 2018-07-31 09:24:41 +0000 |
---|---|---|
committer | Olivier Hainque <hainque@gcc.gnu.org> | 2018-07-31 09:24:41 +0000 |
commit | f37866e818ab839e0db68be23e5a339e5e7c19dc (patch) | |
tree | d0e676879f65f348b838125b8e4d9cf763c5e61e /gcc | |
parent | 1d4a51cf5079c11a44126bf7d5cf63fd9b202fbd (diff) | |
download | gcc-f37866e818ab839e0db68be23e5a339e5e7c19dc.zip gcc-f37866e818ab839e0db68be23e5a339e5e7c19dc.tar.gz gcc-f37866e818ab839e0db68be23e5a339e5e7c19dc.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 22 | ||||
-rw-r--r-- | gcc/common.opt | 3 | ||||
-rw-r--r-- | gcc/config/alpha/linux.h | 2 | ||||
-rw-r--r-- | gcc/config/arc/elf.h | 2 | ||||
-rw-r--r-- | gcc/config/arm/uclinux-elf.h | 4 | ||||
-rw-r--r-- | gcc/config/arm/unknown-elf.h | 2 | ||||
-rw-r--r-- | gcc/config/avr/avrlibc.h | 2 | ||||
-rw-r--r-- | gcc/config/bfin/bfin.h | 2 | ||||
-rw-r--r-- | gcc/config/bfin/linux.h | 2 | ||||
-rw-r--r-- | gcc/config/bfin/uclinux.h | 2 | ||||
-rw-r--r-- | gcc/config/darwin.h | 2 | ||||
-rw-r--r-- | gcc/config/darwin10.h | 2 | ||||
-rw-r--r-- | gcc/config/darwin12.h | 2 | ||||
-rw-r--r-- | gcc/config/gnu-user.h | 2 | ||||
-rw-r--r-- | gcc/config/lm32/uclinux-elf.h | 2 | ||||
-rw-r--r-- | gcc/config/pa/pa-hpux11.h | 2 | ||||
-rw-r--r-- | gcc/config/pa/pa64-hpux.h | 2 | ||||
-rw-r--r-- | gcc/config/sparc/sparc.h | 2 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 19 | ||||
-rw-r--r-- | gcc/gcc.c | 2 |
20 files changed, 59 insertions, 21 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e2eb1c6..cb0fb08 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,27 @@ 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. diff --git a/gcc/common.opt b/gcc/common.opt index 4bf8de9..5bb6452 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -3040,6 +3040,9 @@ Driver nostartfiles Driver +nolibc +Driver + nostdlib Driver diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h index 2bf52fe..6d12d90 100644 --- a/gcc/config/alpha/linux.h +++ b/gcc/config/alpha/linux.h @@ -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. */ diff --git a/gcc/config/arc/elf.h b/gcc/config/arc/elf.h index 66ee5b6..3472fd2 100644 --- a/gcc/config/arc/elf.h +++ b/gcc/config/arc/elf.h @@ -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" diff --git a/gcc/config/arm/uclinux-elf.h b/gcc/config/arm/uclinux-elf.h index f78f279..5733983 100644 --- a/gcc/config/arm/uclinux-elf.h +++ b/gcc/config/arm/uclinux-elf.h @@ -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 diff --git a/gcc/config/arm/unknown-elf.h b/gcc/config/arm/unknown-elf.h index 12dd093..6eeb0eb 100644 --- a/gcc/config/arm/unknown-elf.h +++ b/gcc/config/arm/unknown-elf.h @@ -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" diff --git a/gcc/config/avr/avrlibc.h b/gcc/config/avr/avrlibc.h index 95a1d7c..f4a41a1 100644 --- a/gcc/config/avr/avrlibc.h +++ b/gcc/config/avr/avrlibc.h @@ -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" diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h index 4709282..a503d57 100644 --- a/gcc/config/bfin/bfin.h +++ b/gcc/config/bfin/bfin.h @@ -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 diff --git a/gcc/config/bfin/linux.h b/gcc/config/bfin/linux.h index 9d317d1..b1592ee 100644 --- a/gcc/config/bfin/linux.h +++ b/gcc/config/bfin/linux.h @@ -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}}" diff --git a/gcc/config/bfin/uclinux.h b/gcc/config/bfin/uclinux.h index 7ef3b16..beb6d45 100644 --- a/gcc/config/bfin/uclinux.h +++ b/gcc/config/bfin/uclinux.h @@ -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 diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 591188a..980ad9b 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -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. */ diff --git a/gcc/config/darwin10.h b/gcc/config/darwin10.h index 7da3291..d61eb40 100644 --- a/gcc/config/darwin10.h +++ b/gcc/config/darwin10.h @@ -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" diff --git a/gcc/config/darwin12.h b/gcc/config/darwin12.h index f1562c5..e1e1eb0 100644 --- a/gcc/config/darwin12.h +++ b/gcc/config/darwin12.h @@ -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" diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h index b326cf0..5b48fb2 100644 --- a/gcc/config/gnu-user.h +++ b/gcc/config/gnu-user.h @@ -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. */ diff --git a/gcc/config/lm32/uclinux-elf.h b/gcc/config/lm32/uclinux-elf.h index cfaca37..ac51d97 100644 --- a/gcc/config/lm32/uclinux-elf.h +++ b/gcc/config/lm32/uclinux-elf.h @@ -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 diff --git a/gcc/config/pa/pa-hpux11.h b/gcc/config/pa/pa-hpux11.h index 8adfe18..0e960c3 100644 --- a/gcc/config/pa/pa-hpux11.h +++ b/gcc/config/pa/pa-hpux11.h @@ -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 \ diff --git a/gcc/config/pa/pa64-hpux.h b/gcc/config/pa/pa64-hpux.h index 6f70767..2c24238 100644 --- a/gcc/config/pa/pa64-hpux.h +++ b/gcc/config/pa/pa64-hpux.h @@ -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 diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index 032a91d..87358c7 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -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") diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 1dcdfb5..27097d7 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -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 |