Upstream-Status: Inappropriate [embedded specific] gcc-runtime builds libstdc++ separately from gcc-cross-*. Its configure tests using g++ will not run correctly since by default the linker will try to link against libstdc++ which shouldn't exist yet. We need an option to disable -lstdc++ option whilst leaving -lc, -lgcc and other automatic library dependencies added by gcc driver. This patch adds such an option which only disables the -lstdc++. A "standard" gcc build uses xgcc and hence avoids this. We should ask upstream how to do this officially, the likely answer is don't build libstdc++ separately. RP 29/6/10 Index: gcc-4_7-branch/gcc/cp/g++spec.c =================================================================== --- gcc-4_7-branch.orig/gcc/cp/g++spec.c 2012-04-10 10:17:24.647330074 -0700 +++ gcc-4_7-branch/gcc/cp/g++spec.c 2012-04-10 10:37:49.479389235 -0700 @@ -127,6 +127,7 @@ switch (decoded_options[i].opt_index) { case OPT_nostdlib: + case OPT_nostdlib__: case OPT_nodefaultlibs: library = -1; break; Index: gcc-4_7-branch/gcc/doc/invoke.texi =================================================================== --- gcc-4_7-branch.orig/gcc/doc/invoke.texi 2012-04-10 10:37:09.343387385 -0700 +++ gcc-4_7-branch/gcc/doc/invoke.texi 2012-04-10 10:37:49.483389340 -0700 @@ -194,7 +194,7 @@ -fno-pretty-templates @gol -frepo -fno-rtti -fstats -ftemplate-depth=@var{n} @gol -fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++ @gol --fno-default-inline -fvisibility-inlines-hidden @gol +-nostdlib++ -fno-default-inline -fvisibility-inlines-hidden @gol -fvisibility-ms-compat @gol -Wabi -Wconversion-null -Wctor-dtor-privacy @gol -Wdelete-non-virtual-dtor -Wnarrowing -Wnoexcept @gol @@ -445,7 +445,7 @@ @gccoptlist{@var{object-file-name} -l@var{library} @gol -nostartfiles -nodefaultlibs -nostdlib -pie -rdynamic @gol -s -static -static-libgcc -static-libstdc++ -shared @gol --shared-libgcc -symbolic @gol +-shared-libgcc -symbolic -nostdlib++ @gol -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol -u @var{symbol}} @@ -9438,6 +9438,11 @@ libc. These entry points should be supplied through some other mechanism when this option is specified. +@item -nostdlib++ +@opindex nostdlib++ +Do not use the standard system C++ runtime libraries when linking. +Only the libraries you specify will be passed to the linker. + @cindex @option{-lgcc}, use with @option{-nostdlib} @cindex @option{-nostdlib} and unresolved references @cindex unresolved references and @option{-nostdlib} Index: gcc-4_7-branch/gcc/c-family/c.opt =================================================================== --- gcc-4_7-branch.orig/gcc/c-family/c.opt 2012-04-10 10:17:24.667330076 -0700 +++ gcc-4_7-branch/gcc/c-family/c.opt 2012-04-10 10:37:49.483389340 -0700 @@ -1171,6 +1171,10 @@ C++ ObjC++ Do not search standard system include directories for C++ +nostdlib++ +Driver +Do not link standard C++ runtime library + o C ObjC C++ ObjC++ Joined Separate ; Documented in common.opt Index: gcc-4_7-branch/gcc/gcc.c =================================================================== --- gcc-4_7-branch.orig/gcc/gcc.c 2012-04-10 10:37:09.343387385 -0700 +++ gcc-4_7-branch/gcc/gcc.c 2012-04-10 10:37:49.487389409 -0700 @@ -681,6 +681,7 @@ %(mflib) " STACK_SPLIT_SPEC "\ %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\ %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ + %{!nostdlib++:}\ %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}" #endif