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.6.0/gcc/cp/g++spec.c =================================================================== --- gcc-4.6.0.orig/gcc/cp/g++spec.c +++ gcc-4.6.0/gcc/cp/g++spec.c @@ -127,6 +127,7 @@ lang_specific_driver (struct cl_decoded_ switch (decoded_options[i].opt_index) { case OPT_nostdlib: + case OPT_nostdlib__: case OPT_nodefaultlibs: library = -1; break; Index: gcc-4.6.0/gcc/doc/invoke.texi =================================================================== --- gcc-4.6.0.orig/gcc/doc/invoke.texi +++ gcc-4.6.0/gcc/doc/invoke.texi @@ -193,7 +193,7 @@ in the following sections. -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 -Wnoexcept -Wnon-virtual-dtor -Wreorder @gol @@ -431,7 +431,7 @@ Objective-C and Objective-C++ Dialects}. @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}} @@ -9069,6 +9069,11 @@ These entries are usually resolved by en 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.6.0/gcc/c-family/c.opt =================================================================== --- gcc-4.6.0.orig/gcc/c-family/c.opt +++ gcc-4.6.0/gcc/c-family/c.opt @@ -1111,6 +1111,10 @@ nostdinc++ 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.6.0/gcc/gcc.c =================================================================== --- gcc-4.6.0.orig/gcc/gcc.c +++ gcc-4.6.0/gcc/gcc.c @@ -666,6 +666,7 @@ proper position among the other output f %(mflib) " STACK_SPLIT_SPEC "\ %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\ %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ + %{!nostdlib++:}\ %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}" #endif