Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 307c8ff3ef666b7bd5ac733863f2fbb27a9d521e Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Fri, 29 Mar 2013 09:12:56 +0400 |
| 4 | Subject: [PATCH 20/35] optional libstdc |
| 5 | |
| 6 | gcc-runtime builds libstdc++ separately from gcc-cross-*. Its configure tests using g++ |
| 7 | will not run correctly since by default the linker will try to link against libstdc++ |
| 8 | which shouldn't exist yet. We need an option to disable -lstdc++ |
| 9 | option whilst leaving -lc, -lgcc and other automatic library dependencies added by gcc |
| 10 | driver. This patch adds such an option which only disables the -lstdc++. |
| 11 | |
| 12 | A "standard" gcc build uses xgcc and hence avoids this. We should ask upstream how to |
| 13 | do this officially, the likely answer is don't build libstdc++ separately. |
| 14 | |
| 15 | RP 29/6/10 |
| 16 | |
| 17 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 18 | |
| 19 | Upstream-Status: Inappropriate [embedded specific] |
| 20 | --- |
| 21 | gcc/c-family/c.opt | 4 ++++ |
| 22 | gcc/cp/g++spec.c | 1 + |
| 23 | gcc/doc/invoke.texi | 9 +++++++-- |
| 24 | gcc/gcc.c | 1 + |
| 25 | 4 files changed, 13 insertions(+), 2 deletions(-) |
| 26 | |
| 27 | diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt |
| 28 | index 10ae84d..dc3ffdf 100644 |
| 29 | --- a/gcc/c-family/c.opt |
| 30 | +++ b/gcc/c-family/c.opt |
| 31 | @@ -1299,6 +1299,10 @@ nostdinc++ |
| 32 | C++ ObjC++ |
| 33 | Do not search standard system include directories for C++ |
| 34 | |
| 35 | +nostdlib++ |
| 36 | +Driver |
| 37 | +Do not link standard C++ runtime library |
| 38 | + |
| 39 | o |
| 40 | C ObjC C++ ObjC++ Joined Separate |
| 41 | ; Documented in common.opt |
| 42 | diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c |
| 43 | index b896eea..f55216b 100644 |
| 44 | --- a/gcc/cp/g++spec.c |
| 45 | +++ b/gcc/cp/g++spec.c |
| 46 | @@ -126,6 +126,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, |
| 47 | switch (decoded_options[i].opt_index) |
| 48 | { |
| 49 | case OPT_nostdlib: |
| 50 | + case OPT_nostdlib__: |
| 51 | case OPT_nodefaultlibs: |
| 52 | library = -1; |
| 53 | break; |
| 54 | diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi |
| 55 | index a022622..f15c991 100644 |
| 56 | --- a/gcc/doc/invoke.texi |
| 57 | +++ b/gcc/doc/invoke.texi |
| 58 | @@ -190,7 +190,7 @@ in the following sections. |
| 59 | -frepo -fno-rtti -fstats -ftemplate-backtrace-limit=@var{n} @gol |
| 60 | -ftemplate-depth=@var{n} @gol |
| 61 | -fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++ @gol |
| 62 | --fno-default-inline -fvisibility-inlines-hidden @gol |
| 63 | +-nostdlib++ -fno-default-inline -fvisibility-inlines-hidden @gol |
| 64 | -fvisibility-ms-compat @gol |
| 65 | -fext-numeric-literals @gol |
| 66 | -Wabi -Wconversion-null -Wctor-dtor-privacy @gol |
| 67 | @@ -453,7 +453,7 @@ Objective-C and Objective-C++ Dialects}. |
| 68 | -nostartfiles -nodefaultlibs -nostdlib -pie -rdynamic @gol |
| 69 | -s -static -static-libgcc -static-libstdc++ @gol |
| 70 | -static-libasan -static-libtsan @gol |
| 71 | --shared -shared-libgcc -symbolic @gol |
| 72 | +-shared -shared-libgcc -symbolic -nostdlib++ @gol |
| 73 | -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol |
| 74 | -u @var{symbol}} |
| 75 | |
| 76 | @@ -9886,6 +9886,11 @@ These entries are usually resolved by entries in |
| 77 | libc. These entry points should be supplied through some other |
| 78 | mechanism when this option is specified. |
| 79 | |
| 80 | +@item -nostdlib++ |
| 81 | +@opindex nostdlib++ |
| 82 | +Do not use the standard system C++ runtime libraries when linking. |
| 83 | +Only the libraries you specify will be passed to the linker. |
| 84 | + |
| 85 | @cindex @option{-lgcc}, use with @option{-nostdlib} |
| 86 | @cindex @option{-nostdlib} and unresolved references |
| 87 | @cindex unresolved references and @option{-nostdlib} |
| 88 | diff --git a/gcc/gcc.c b/gcc/gcc.c |
| 89 | index efdb625..477752f 100644 |
| 90 | --- a/gcc/gcc.c |
| 91 | +++ b/gcc/gcc.c |
| 92 | @@ -748,6 +748,7 @@ proper position among the other output files. */ |
| 93 | %(mflib) " STACK_SPLIT_SPEC "\ |
| 94 | %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \ |
| 95 | %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ |
| 96 | + %{!nostdlib++:}\ |
| 97 | %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}" |
| 98 | #endif |
| 99 | |
| 100 | -- |
| 101 | 1.7.10.4 |
| 102 | |