diff options
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch')
-rw-r--r-- | meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch | 120 |
1 files changed, 58 insertions, 62 deletions
diff --git a/meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch b/meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch index c921ac3340..b856c5dea3 100644 --- a/meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch +++ b/meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch | |||
@@ -1,34 +1,54 @@ | |||
1 | From 57e2c5e35732988c0b287289eb0997b4e9769371 Mon Sep 17 00:00:00 2001 | 1 | From: Richard Purdie <richard.purdie@linuxfoundation.org> |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | Subject: [PATCH 3/5] gcc: Add --nostdlib++ option |
3 | Date: Fri, 29 Mar 2013 09:12:56 +0400 | ||
4 | Subject: [PATCH] optional libstdc | ||
5 | 3 | ||
6 | gcc-runtime builds libstdc++ separately from gcc-cross-*. Its configure tests using g++ | 4 | [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++ | 5 | 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++ | 6 | 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 | 7 | 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++. | 8 | driver. This patch adds such an option which only disables the -lstdc++.] |
11 | 9 | ||
12 | A "standard" gcc build uses xgcc and hence avoids this. We should ask upstream how to | 10 | [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. | 11 | do this officially, the likely answer is don't build libstdc++ separately.] |
14 | 12 | ||
15 | RP 29/6/10 | 13 | OpenEmbedded/Yocto Project builds libgcc and the other gcc runtime libraries |
14 | separately from the compiler and slightly differently to the standard gcc build. | ||
16 | 15 | ||
17 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | 16 | In general this works well but in trying to build them separately we run into |
17 | an issue since we're using our gcc, not xgcc and there is no way to tell configure | ||
18 | to use libgcc but not look for libstdc++. | ||
18 | 19 | ||
19 | Upstream-Status: Inappropriate [embedded specific] | 20 | This adds such an option allowing such configurations to work. |
21 | |||
22 | 2021-10-26 Richard Purdie <richard.purdie@linuxfoundation.org> | ||
23 | |||
24 | gcc/c-family/ChangeLog: | ||
25 | |||
26 | * c.opt: Add --nostdlib++ option | ||
27 | |||
28 | gcc/cp/ChangeLog: | ||
29 | |||
30 | * g++spec.c (lang_specific_driver): Add --nostdlib++ option | ||
31 | |||
32 | gcc/ChangeLog: | ||
33 | |||
34 | * doc/invoke.texi: Document --nostdlib++ option | ||
35 | * gcc.c: Add --nostdlib++ option | ||
36 | |||
37 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> | ||
38 | |||
39 | Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582724.html] | ||
20 | --- | 40 | --- |
21 | gcc/c-family/c.opt | 4 ++++ | 41 | gcc/c-family/c.opt | 4 ++++ |
22 | gcc/cp/g++spec.c | 1 + | 42 | gcc/cp/g++spec.c | 1 + |
23 | gcc/doc/invoke.texi | 32 +++++++++++++++++++++++++++++++- | 43 | gcc/doc/invoke.texi | 8 +++++++- |
24 | gcc/gcc.c | 1 + | 44 | gcc/gcc.c | 1 + |
25 | 4 files changed, 37 insertions(+), 1 deletion(-) | 45 | 4 files changed, 13 insertions(+), 1 deletion(-) |
26 | 46 | ||
27 | diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt | 47 | Index: gcc-11.2.0/gcc/c-family/c.opt |
28 | index 64e46e7573e..1824380f27a 100644 | 48 | =================================================================== |
29 | --- a/gcc/c-family/c.opt | 49 | --- gcc-11.2.0.orig/gcc/c-family/c.opt |
30 | +++ b/gcc/c-family/c.opt | 50 | +++ gcc-11.2.0/gcc/c-family/c.opt |
31 | @@ -2166,6 +2166,10 @@ nostdinc++ | 51 | @@ -2153,6 +2153,10 @@ nostdinc++ |
32 | C++ ObjC++ | 52 | C++ ObjC++ |
33 | Do not search standard system include directories for C++. | 53 | Do not search standard system include directories for C++. |
34 | 54 | ||
@@ -39,11 +59,11 @@ index 64e46e7573e..1824380f27a 100644 | |||
39 | o | 59 | o |
40 | C ObjC C++ ObjC++ Joined Separate | 60 | C ObjC C++ ObjC++ Joined Separate |
41 | ; Documented in common.opt | 61 | ; Documented in common.opt |
42 | diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c | 62 | Index: gcc-11.2.0/gcc/cp/g++spec.c |
43 | index 3c9bd1490b4..818beb61cee 100644 | 63 | =================================================================== |
44 | --- a/gcc/cp/g++spec.c | 64 | --- gcc-11.2.0.orig/gcc/cp/g++spec.c |
45 | +++ b/gcc/cp/g++spec.c | 65 | +++ gcc-11.2.0/gcc/cp/g++spec.c |
46 | @@ -159,6 +159,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, | 66 | @@ -159,6 +159,7 @@ lang_specific_driver (struct cl_decoded_ |
47 | switch (decoded_options[i].opt_index) | 67 | switch (decoded_options[i].opt_index) |
48 | { | 68 | { |
49 | case OPT_nostdlib: | 69 | case OPT_nostdlib: |
@@ -51,21 +71,19 @@ index 3c9bd1490b4..818beb61cee 100644 | |||
51 | case OPT_nodefaultlibs: | 71 | case OPT_nodefaultlibs: |
52 | library = -1; | 72 | library = -1; |
53 | break; | 73 | break; |
54 | diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi | 74 | Index: gcc-11.2.0/gcc/doc/invoke.texi |
55 | index 6659a903bf0..9ee63dbe52f 100644 | 75 | =================================================================== |
56 | --- a/gcc/doc/invoke.texi | 76 | --- gcc-11.2.0.orig/gcc/doc/invoke.texi |
57 | +++ b/gcc/doc/invoke.texi | 77 | +++ gcc-11.2.0/gcc/doc/invoke.texi |
58 | @@ -239,6 +239,9 @@ in the following sections. | 78 | @@ -239,6 +239,7 @@ in the following sections. |
59 | -fno-weak -nostdinc++ @gol | 79 | -fno-weak -nostdinc++ @gol |
60 | -fvisibility-inlines-hidden @gol | 80 | -fvisibility-inlines-hidden @gol |
61 | -fvisibility-ms-compat @gol | 81 | -fvisibility-ms-compat @gol |
62 | +-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol | ||
63 | +-fvtv-counts -fvtv-debug @gol | ||
64 | +-nostdlib++ @gol | 82 | +-nostdlib++ @gol |
65 | -fext-numeric-literals @gol | 83 | -fext-numeric-literals @gol |
66 | -flang-info-include-translate@r{[}=@var{header}@r{]} @gol | 84 | -flang-info-include-translate@r{[}=@var{header}@r{]} @gol |
67 | -flang-info-include-translate-not @gol | 85 | -flang-info-include-translate-not @gol |
68 | @@ -632,7 +635,7 @@ Objective-C and Objective-C++ Dialects}. | 86 | @@ -632,7 +633,7 @@ Objective-C and Objective-C++ Dialects}. |
69 | -pie -pthread -r -rdynamic @gol | 87 | -pie -pthread -r -rdynamic @gol |
70 | -s -static -static-pie -static-libgcc -static-libstdc++ @gol | 88 | -s -static -static-pie -static-libgcc -static-libstdc++ @gol |
71 | -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol | 89 | -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol |
@@ -74,7 +92,7 @@ index 6659a903bf0..9ee63dbe52f 100644 | |||
74 | -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol | 92 | -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol |
75 | -u @var{symbol} -z @var{keyword}} | 93 | -u @var{symbol} -z @var{keyword}} |
76 | 94 | ||
77 | @@ -15708,6 +15711,33 @@ Specify that the program entry point is @var{entry}. The argument is | 95 | @@ -15721,6 +15722,11 @@ Specify that the program entry point is |
78 | interpreted by the linker; the GNU linker accepts either a symbol name | 96 | interpreted by the linker; the GNU linker accepts either a symbol name |
79 | or an address. | 97 | or an address. |
80 | 98 | ||
@@ -83,36 +101,14 @@ index 6659a903bf0..9ee63dbe52f 100644 | |||
83 | +Do not use the standard system C++ runtime libraries when linking. | 101 | +Do not use the standard system C++ runtime libraries when linking. |
84 | +Only the libraries you specify will be passed to the linker. | 102 | +Only the libraries you specify will be passed to the linker. |
85 | + | 103 | + |
86 | +@cindex @option{-lgcc}, use with @option{-nostdlib} | ||
87 | +@cindex @option{-nostdlib} and unresolved references | ||
88 | +@cindex unresolved references and @option{-nostdlib} | ||
89 | +@cindex @option{-lgcc}, use with @option{-nodefaultlibs} | ||
90 | +@cindex @option{-nodefaultlibs} and unresolved references | ||
91 | +@cindex unresolved references and @option{-nodefaultlibs} | ||
92 | +One of the standard libraries bypassed by @option{-nostdlib} and | ||
93 | +@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | ||
94 | +which GCC uses to overcome shortcomings of particular machines, or special | ||
95 | +needs for some languages. | ||
96 | +(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler | ||
97 | +Collection (GCC) Internals}, | ||
98 | +for more discussion of @file{libgcc.a}.) | ||
99 | +In most cases, you need @file{libgcc.a} even when you want to avoid | ||
100 | +other standard libraries. In other words, when you specify @option{-nostdlib} | ||
101 | +or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well. | ||
102 | +This ensures that you have no unresolved references to internal GCC | ||
103 | +library subroutines. | ||
104 | +(An example of such an internal subroutine is @code{__main}, used to ensure C++ | ||
105 | +constructors are called; @pxref{Collect2,,@code{collect2}, gccint, | ||
106 | +GNU Compiler Collection (GCC) Internals}.) | ||
107 | + | ||
108 | @item -pie | 104 | @item -pie |
109 | @opindex pie | 105 | @opindex pie |
110 | Produce a dynamically linked position independent executable on targets | 106 | Produce a dynamically linked position independent executable on targets |
111 | diff --git a/gcc/gcc.c b/gcc/gcc.c | 107 | Index: gcc-11.2.0/gcc/gcc.c |
112 | index 19c75b6e20d..be7630ffd8c 100644 | 108 | =================================================================== |
113 | --- a/gcc/gcc.c | 109 | --- gcc-11.2.0.orig/gcc/gcc.c |
114 | +++ b/gcc/gcc.c | 110 | +++ gcc-11.2.0/gcc/gcc.c |
115 | @@ -1162,6 +1162,7 @@ proper position among the other output files. */ | 111 | @@ -1162,6 +1162,7 @@ proper position among the other output f |
116 | %(mflib) " STACK_SPLIT_SPEC "\ | 112 | %(mflib) " STACK_SPLIT_SPEC "\ |
117 | %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \ | 113 | %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \ |
118 | %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}}\ | 114 | %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}}\ |