blob: 73741f83cc443efa6a269d04ffa5b61b4298e850 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001From a13763f8a1d413a432e7b40835a062f86208f29a Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:12:56 +0400
4Subject: [PATCH 14/46] optional libstdc
5
6gcc-runtime builds libstdc++ separately from gcc-cross-*. Its configure tests using g++
7will not run correctly since by default the linker will try to link against libstdc++
8which shouldn't exist yet. We need an option to disable -lstdc++
9option whilst leaving -lc, -lgcc and other automatic library dependencies added by gcc
10driver. This patch adds such an option which only disables the -lstdc++.
11
12A "standard" gcc build uses xgcc and hence avoids this. We should ask upstream how to
13do this officially, the likely answer is don't build libstdc++ separately.
14
15RP 29/6/10
16
17Signed-off-by: Khem Raj <raj.khem@gmail.com>
18
19Upstream-Status: Inappropriate [embedded specific]
20---
21 gcc/c-family/c.opt | 4 ++++
22 gcc/cp/g++spec.c | 1 +
23 gcc/doc/invoke.texi | 8 +++++++-
24 gcc/gcc.c | 1 +
25 4 files changed, 13 insertions(+), 1 deletion(-)
26
27diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
28index 4162566..453ec8e 100644
29--- a/gcc/c-family/c.opt
30+++ b/gcc/c-family/c.opt
31@@ -1543,6 +1543,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
42diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c
43index 6536d7e..f57a5d4 100644
44--- a/gcc/cp/g++spec.c
45+++ b/gcc/cp/g++spec.c
46@@ -138,6 +138,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;
54diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
55index c81b55b..6d3f68c 100644
56--- a/gcc/doc/invoke.texi
57+++ b/gcc/doc/invoke.texi
58@@ -195,6 +195,7 @@ in the following sections.
59 -fvisibility-inlines-hidden @gol
60 -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol
61 -fvtv-counts -fvtv-debug @gol
62+-nostdlib++ @gol
63 -fvisibility-ms-compat @gol
64 -fext-numeric-literals @gol
65 -Wabi=@var{n} -Wabi-tag -Wconversion-null -Wctor-dtor-privacy @gol
66@@ -488,7 +489,7 @@ Objective-C and Objective-C++ Dialects}.
67 -s -static -static-libgcc -static-libstdc++ @gol
68 -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
69 -static-libmpx -static-libmpxwrappers @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} -z @var{keyword}}
74
75@@ -11187,6 +11188,11 @@ These entries are usually resolved by entries in
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}
87diff --git a/gcc/gcc.c b/gcc/gcc.c
88index 675bcc1..a37ec8b 100644
89--- a/gcc/gcc.c
90+++ b/gcc/gcc.c
91@@ -845,6 +845,7 @@ proper position among the other output files. */
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
99--
1002.6.3
101