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 | Index: gcc-4.9-20140316/gcc/c-family/c.opt |
| 28 | =================================================================== |
| 29 | --- gcc-4.9-20140316.orig/gcc/c-family/c.opt |
| 30 | +++ gcc-4.9-20140316/gcc/c-family/c.opt |
| 31 | @@ -1323,6 +1323,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 | Index: gcc-4.9-20140316/gcc/cp/g++spec.c |
| 43 | =================================================================== |
| 44 | --- gcc-4.9-20140316.orig/gcc/cp/g++spec.c |
| 45 | +++ gcc-4.9-20140316/gcc/cp/g++spec.c |
| 46 | @@ -138,6 +138,7 @@ lang_specific_driver (struct cl_decoded_ |
| 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 | Index: gcc-4.9-20140316/gcc/doc/invoke.texi |
| 55 | =================================================================== |
| 56 | --- gcc-4.9-20140316.orig/gcc/doc/invoke.texi |
| 57 | +++ gcc-4.9-20140316/gcc/doc/invoke.texi |
| 58 | @@ -193,6 +193,7 @@ in the following sections. |
| 59 | -fvisibility-inlines-hidden @gol |
| 60 | -fvtable-verify=@var{std|preinit|none} @gol |
| 61 | -fvtv-counts -fvtv-debug @gol |
| 62 | +-nostdlib++ @gol |
| 63 | -fvisibility-ms-compat @gol |
| 64 | -fext-numeric-literals @gol |
| 65 | -Wabi -Wconversion-null -Wctor-dtor-privacy @gol |
| 66 | @@ -457,7 +458,7 @@ Objective-C and Objective-C++ Dialects}. |
| 67 | -nostartfiles -nodefaultlibs -nostdlib -pie -rdynamic @gol |
| 68 | -s -static -static-libgcc -static-libstdc++ @gol |
| 69 | -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol |
| 70 | --shared -shared-libgcc -symbolic @gol |
| 71 | +-shared -shared-libgcc -symbolic -nostdlib++ @gol |
| 72 | -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol |
| 73 | -u @var{symbol}} |
| 74 | |
| 75 | @@ -10285,6 +10286,11 @@ These entries are usually resolved by en |
| 76 | libc. These entry points should be supplied through some other |
| 77 | mechanism when this option is specified. |
| 78 | |
| 79 | +@item -nostdlib++ |
| 80 | +@opindex nostdlib++ |
| 81 | +Do not use the standard system C++ runtime libraries when linking. |
| 82 | +Only the libraries you specify will be passed to the linker. |
| 83 | + |
| 84 | @cindex @option{-lgcc}, use with @option{-nostdlib} |
| 85 | @cindex @option{-nostdlib} and unresolved references |
| 86 | @cindex unresolved references and @option{-nostdlib} |
| 87 | Index: gcc-4.9-20140316/gcc/gcc.c |
| 88 | =================================================================== |
| 89 | --- gcc-4.9-20140316.orig/gcc/gcc.c |
| 90 | +++ gcc-4.9-20140316/gcc/gcc.c |
| 91 | @@ -772,6 +772,7 @@ proper position among the other output f |
| 92 | %(mflib) " STACK_SPLIT_SPEC "\ |
| 93 | %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \ |
| 94 | %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ |
| 95 | + %{!nostdlib++:}\ |
| 96 | %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}" |
| 97 | #endif |
| 98 | |