public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: R jd <3246251196ryan@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Fine granularity of control over libgcc* search paths
Date: Wed, 8 Nov 2023 00:20:47 +0000	[thread overview]
Message-ID: <CAPB2dxmGTeQZVP6WW2nh4HcgVH6YUcvBj50FtEZT31ceW4-Nuw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2529 bytes --]

I have tried for some hours to figure out how to get full control over the
paths that are implicitly searched for *libgcc.a*.

As an example, here is the command that is passed to *collect2*:

/usr/lib/gcc/x86_64-linux-gnu/11/collect2 -plugin
/usr/lib/gcc/x86_64-linux-gnu/11/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccwIgXt9.res -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s
--build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o main
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/11/crtbeginS.o
-L/usr/lib/gcc/x86_64-linux-gnu/11
-L/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib -L/lib/x86_64-linux-gnu
-L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-linux-gnu/11/../../.. --verbose /tmp/ccR9vB4k.o -lgcc
--push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state
--as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/11/crtendS.o
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crtn.o

This boils down to something like:

[LINK_SPEC] [STARTFILE_SPEC] [The Evasive Library Paths] --verbose
/tmp/ccR9vB4k.o [REAL_LIBGCC_SPEC] [LIB_SPEC] .....

Where, [The Evasive Library Paths] = -L/usr/lib/gcc/x86_64-linux-gnu/11
-L/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib -L/lib/x86_64-linux-gnu
-L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-linux-gnu/11/../../..

It is [The Evasive Library Paths] that I am trying to get fine control
over. It seems that these are just automatically inserted because we are
linking with -lgcc which makes total sense - but I need to have full
control over it and may want to change it. The rest of the command line for
*collect2* is understandable and modifiable since I can match it up with
the relevant SPEC file. Only these evasive library paths are causing me a
lot of wasted hours.

I was looking at *LINK_COMMAND_SPEC* (
https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gccint/Driver.html) as a potential
work around, but I thought that, since it is already late, I would just ask
on here.

Regards,

             reply	other threads:[~2023-11-08  0:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08  0:20 R jd [this message]
2023-11-08 16:33 ` Stefan Ring
2023-11-12 19:29 ` Kai Ruottu
2023-11-12 19:37   ` Kai Ruottu
2023-11-12 21:37   ` Jonathan Wakely
2023-11-23 22:26     ` R jd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPB2dxmGTeQZVP6WW2nh4HcgVH6YUcvBj50FtEZT31ceW4-Nuw@mail.gmail.com \
    --to=3246251196ryan@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).