This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch][GCC] Document and fix -r (partial linking)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Allan Sandfeld Jensen <linux at carewolf dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 1 Aug 2018 16:32:30 +0000
- Subject: Re: [Patch][GCC] Document and fix -r (partial linking)
- References: <5835862.YDeY9hZc7r@twilight>
On Wed, 1 Aug 2018, Allan Sandfeld Jensen wrote:
> gcc/
> * gcc.c: Correct default specs for -r
I don't follow why your changes (which would need describing for each
individual spec changed) are corrections.
> /* config.h can define LIB_SPEC to override the default libraries. */
> #ifndef LIB_SPEC
> -#define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
> +#define LIB_SPEC "%{!shared|!r:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
> #endif
'!' binds more closely than '|' in specs. That is, !shared|!r means the
following specs are used unless both -shared and -r are specified, which
seems nonsensical to me. I'd expect something more like "shared|r:;" to
expand to nothing if either -shared or -r is passed and to what follows if
neither is passed.
And that ignores that this LIB_SPEC value in gcc.c is largely irrelevant,
as it's generally overridden by targets - and normally for targets using
ELF shared libraries, for example, -lc *does* have to be used when linking
with -shared.
I think you're changing the wrong place for this. If you want -r to be
usable with GCC without using -nostdlib (which is an interesting
question), you actually need to change LINK_COMMAND_SPEC (also sometimes
overridden for targets) to handle -r more like -nostdlib -nostartfiles.
> -#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
> +#define LINK_PIE_SPEC "%{static|shared|r|ar:;" PIE_SPEC ":" LD_PIE_SPEC "} "
What's this "-ar" option you're handling here?
--
Joseph S. Myers
joseph@codesourcery.com