Hi Alexandre,

Alexandre Oliva via Gcc-patches <gcc-patches@gcc.gnu.org> writes:

> Hello, Gerald,
>
> On Feb 11, 2023, Gerald Pfeifer <ger...@pfeifer.com> wrote:
>
>> On Thu, 23 Jun 2022, Alexandre Oliva via Gcc-patches wrote:
>>> Introduce -nostdlib++ option
>>> 
>>> Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C,
>>> is error prone, because there's no way to tell g++ to drop libstdc++
>>> without also dropping libc and any other libraries that the target
>>> implicitly links in.
>
>> % grep -r nostdlib $WWWDOCS
>> %
>
>> Should this be documented in gcc-13/changes.html? Would you mind proposing 
>> a snippet (or going ahead and pushing it)?
>
> I can't make my mind up about this.
>
> At first, the goal of adding the option was just to aid this specific
> test.  But then, it transpired that other compilers offered a similar
> option, with the spelling that we ended up using, so perhaps it would
> make sense to document it, after all.

IMO, yes - in fact, the libstdc++ manual even has a use-case for this
(freestanding when the compiler is *not* built with libstdc++ in
freestanding mode) and documents using the gcc driver rather than the
g++ one.  See libstdc++-v3/doc/xml/manual/using.xml:

  If you're using a libstdc++ configured for hosted environments, and
  would like to not involve the libraries libstdc++ would depend on in
  your programs, you will need to use <command>gcc</command> to link your
  application with only <filename class="libraryfile">libsupc++.a</filename>,
  like so:

If you think the flag you added fits here, would you mind also including
this file in your patch?

Note that this flag is only applicable here if MATH_LIBRARY is omitted
but libsupc++.a is kept on the linker command line (apologies for
not checking ahead of writing this email - I'm not currently in a
convenient spot to do so).

Thanks in advance, have a lovely day.

> How about this, does this seem useful?
>
> diff --git a/htdocs/gcc-13/changes.html b/htdocs/gcc-13/changes.html
> index ff70d2eefecec..c1bbbfa28e18e 100644
> --- a/htdocs/gcc-13/changes.html
> +++ b/htdocs/gcc-13/changes.html
> @@ -333,6 +333,9 @@ a work-in-progress.</p>
>    <li>The <a 
> href="https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-Wpessimizing-move";><code>-Wpessimizing-move</code></a>
>      and <a 
> href="https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-Wredundant-move";><code>-Wredundant-move</code></a>
>      warnings have been extended to warn in more contexts.</li>
> +  <li>The <a 
> href="https://gcc.gnu.org/onlinedocs/gcc/Link_Options.html#index-nostdlib_002b_002b";><code>-nostdlib++</code></a>
> +    option has been added, to enable linking with <code>g++</code>
> +    without implicitly linking in the C++ standard library.</li>
>  </ul>
>  
>  <h4 id="libstdcxx">Runtime Library (libstdc++)</h4>


-- 
Arsen Arsenović

Attachment: signature.asc
Description: PGP signature

Reply via email to