summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-12-03 23:34:57 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-05 12:26:35 +0000
commit2d940dd5bf68aecc5d2b95ee2e23fd3e01e980f1 (patch)
tree06f2daf02618adf36d24e83fb5f946b6f7a35c4b /meta
parent472a99447fe0f89bbdb959c1d9b7f67f8a122935 (diff)
downloadpoky-2d940dd5bf68aecc5d2b95ee2e23fd3e01e980f1.tar.gz
gcc: Drop stdlib++ option patch
The patch to gcc to disable use of libstdc++ when configuring the library during gcc-runtime is old and there are perhaps better ways to do this now. If removed, most builds still "work" but incorrect values for things like atomic ops are found during configure. mips64 and ppc fail with on target simple tests of g++ in testimage. Instead we can create a dummy libstdc++ which allows the correct configure test results to be obtained. Discussed with upstream about the patch are ongoing, if accepted, we can switch back to the commandline option if it is added in future. (From OE-Core rev: 34b0edb0d3120c32063ff7e3dd52be20d60401d5) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/gcc/gcc-11.2.inc1
-rw-r--r--meta/recipes-devtools/gcc/gcc-runtime.inc8
-rw-r--r--meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch118
3 files changed, 6 insertions, 121 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-11.2.inc b/meta/recipes-devtools/gcc/gcc-11.2.inc
index f07a5be507..a62f272d3c 100644
--- a/meta/recipes-devtools/gcc/gcc-11.2.inc
+++ b/meta/recipes-devtools/gcc/gcc-11.2.inc
@@ -33,7 +33,6 @@ SRC_URI = "\
33 file://0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch \ 33 file://0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch \
34 file://0002-gcc-poison-system-directories.patch \ 34 file://0002-gcc-poison-system-directories.patch \
35 file://0004-64-bit-multilib-hack.patch \ 35 file://0004-64-bit-multilib-hack.patch \
36 file://0005-optional-libstdc.patch \
37 file://0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \ 36 file://0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \
38 file://0009-cpp-honor-sysroot.patch \ 37 file://0009-cpp-honor-sysroot.patch \
39 file://0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \ 38 file://0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \
diff --git a/meta/recipes-devtools/gcc/gcc-runtime.inc b/meta/recipes-devtools/gcc/gcc-runtime.inc
index 4839a6687a..c39a0caf8a 100644
--- a/meta/recipes-devtools/gcc/gcc-runtime.inc
+++ b/meta/recipes-devtools/gcc/gcc-runtime.inc
@@ -64,7 +64,11 @@ DEBUG_PREFIX_MAP:class-target = " \
64 " 64 "
65 65
66do_configure () { 66do_configure () {
67 export CXX="${CXX} -nostdinc++ -nostdlib++" 67 export CXX="${CXX} -nostdinc++ -L${WORKDIR}/dummylib"
68 # libstdc++ isn't built yet so CXX would error not able to find it which breaks stdc++'s configure
69 # tests. Create a dummy empty lib for the purposes of configure.
70 mkdir -p ${WORKDIR}/dummylib
71 touch ${WORKDIR}/dummylib/libstdc++.so
68 for d in libgcc ${RUNTIMETARGET}; do 72 for d in libgcc ${RUNTIMETARGET}; do
69 echo "Configuring $d" 73 echo "Configuring $d"
70 rm -rf ${B}/${TARGET_SYS}/$d/ 74 rm -rf ${B}/${TARGET_SYS}/$d/
@@ -302,7 +306,7 @@ do_check() {
302 export DEJAGNU="${WORKDIR}/dejagnu/site.exp" 306 export DEJAGNU="${WORKDIR}/dejagnu/site.exp"
303 307
304 # HACK: this works around the configure setting CXX with -nostd* args 308 # HACK: this works around the configure setting CXX with -nostd* args
305 sed -i 's/-nostdinc++ -nostdlib++//g' $(find ${B} -name testsuite_flags | head -1) 309 sed -i 's#-nostdinc++ -L${WORKDIR}/dummylib##g' $(find ${B} -name testsuite_flags | head -1)
306 310
307 if [ "${TOOLCHAIN_TEST_TARGET}" = "user" ]; then 311 if [ "${TOOLCHAIN_TEST_TARGET}" = "user" ]; then
308 # qemu user has issues allocating large amounts of memory 312 # qemu user has issues allocating large amounts of memory
diff --git a/meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch b/meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch
deleted file mode 100644
index b856c5dea3..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch
+++ /dev/null
@@ -1,118 +0,0 @@
1From: Richard Purdie <richard.purdie@linuxfoundation.org>
2Subject: [PATCH 3/5] gcc: Add --nostdlib++ option
3
4[gcc-runtime builds libstdc++ separately from gcc-cross-*. Its configure tests using g++
5will not run correctly since by default the linker will try to link against libstdc++
6which shouldn't exist yet. We need an option to disable -lstdc++
7option whilst leaving -lc, -lgcc and other automatic library dependencies added by gcc
8driver. This patch adds such an option which only disables the -lstdc++.]
9
10[A "standard" gcc build uses xgcc and hence avoids this. We should ask upstream how to
11do this officially, the likely answer is don't build libstdc++ separately.]
12
13OpenEmbedded/Yocto Project builds libgcc and the other gcc runtime libraries
14separately from the compiler and slightly differently to the standard gcc build.
15
16In general this works well but in trying to build them separately we run into
17an issue since we're using our gcc, not xgcc and there is no way to tell configure
18to use libgcc but not look for libstdc++.
19
20This adds such an option allowing such configurations to work.
21
222021-10-26 Richard Purdie <richard.purdie@linuxfoundation.org>
23
24gcc/c-family/ChangeLog:
25
26 * c.opt: Add --nostdlib++ option
27
28gcc/cp/ChangeLog:
29
30 * g++spec.c (lang_specific_driver): Add --nostdlib++ option
31
32gcc/ChangeLog:
33
34 * doc/invoke.texi: Document --nostdlib++ option
35 * gcc.c: Add --nostdlib++ option
36
37Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
38
39Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582724.html]
40---
41 gcc/c-family/c.opt | 4 ++++
42 gcc/cp/g++spec.c | 1 +
43 gcc/doc/invoke.texi | 8 +++++++-
44 gcc/gcc.c | 1 +
45 4 files changed, 13 insertions(+), 1 deletion(-)
46
47Index: gcc-11.2.0/gcc/c-family/c.opt
48===================================================================
49--- gcc-11.2.0.orig/gcc/c-family/c.opt
50+++ gcc-11.2.0/gcc/c-family/c.opt
51@@ -2153,6 +2153,10 @@ nostdinc++
52 C++ ObjC++
53 Do not search standard system include directories for C++.
54
55+nostdlib++
56+Driver
57+Do not link standard C++ runtime library
58+
59 o
60 C ObjC C++ ObjC++ Joined Separate
61 ; Documented in common.opt
62Index: gcc-11.2.0/gcc/cp/g++spec.c
63===================================================================
64--- gcc-11.2.0.orig/gcc/cp/g++spec.c
65+++ gcc-11.2.0/gcc/cp/g++spec.c
66@@ -159,6 +159,7 @@ lang_specific_driver (struct cl_decoded_
67 switch (decoded_options[i].opt_index)
68 {
69 case OPT_nostdlib:
70+ case OPT_nostdlib__:
71 case OPT_nodefaultlibs:
72 library = -1;
73 break;
74Index: gcc-11.2.0/gcc/doc/invoke.texi
75===================================================================
76--- gcc-11.2.0.orig/gcc/doc/invoke.texi
77+++ gcc-11.2.0/gcc/doc/invoke.texi
78@@ -239,6 +239,7 @@ in the following sections.
79 -fno-weak -nostdinc++ @gol
80 -fvisibility-inlines-hidden @gol
81 -fvisibility-ms-compat @gol
82+-nostdlib++ @gol
83 -fext-numeric-literals @gol
84 -flang-info-include-translate@r{[}=@var{header}@r{]} @gol
85 -flang-info-include-translate-not @gol
86@@ -632,7 +633,7 @@ Objective-C and Objective-C++ Dialects}.
87 -pie -pthread -r -rdynamic @gol
88 -s -static -static-pie -static-libgcc -static-libstdc++ @gol
89 -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
90--shared -shared-libgcc -symbolic @gol
91+-shared -shared-libgcc -symbolic -nostdlib++ @gol
92 -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol
93 -u @var{symbol} -z @var{keyword}}
94
95@@ -15721,6 +15722,11 @@ Specify that the program entry point is
96 interpreted by the linker; the GNU linker accepts either a symbol name
97 or an address.
98
99+@item -nostdlib++
100+@opindex nostdlib++
101+Do not use the standard system C++ runtime libraries when linking.
102+Only the libraries you specify will be passed to the linker.
103+
104 @item -pie
105 @opindex pie
106 Produce a dynamically linked position independent executable on targets
107Index: gcc-11.2.0/gcc/gcc.c
108===================================================================
109--- gcc-11.2.0.orig/gcc/gcc.c
110+++ gcc-11.2.0/gcc/gcc.c
111@@ -1162,6 +1162,7 @@ proper position among the other output f
112 %(mflib) " STACK_SPLIT_SPEC "\
113 %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \
114 %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}}\
115+ %{!nostdlib++:}\
116 %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} \n%(post_link) }}}}}}"
117 #endif
118