public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Shiqi Zhang <shiqi@isrc.iscas.ac.cn>
To: gcc@gcc.gnu.org
Cc: rui314@gmail.com, marxin@gcc.gnu.org, jpalus+gcc@fastmail.com,
	CoelacanthusHex@gmail.com, i@rvalue.moe, xctan@cirno.icu,
	mooodyhunter@outlook.com, Shiqi Zhang <shiqi@isrc.iscas.ac.cn>
Subject: [RFC PATCH] driver: unfilter default library path [PR 104707]
Date: Thu,  6 Apr 2023 02:32:05 +0800	[thread overview]
Message-ID: <20230405183204.17915-1-shiqi@isrc.iscas.ac.cn> (raw)

Currently, gcc delibrately filters out default library paths "/lib/" and
"/usr/lib/", causing some linkers like mold fails to find libraries.

This behavior was introduced at least 31 years ago in the initial
revision of the git repo, personally I think it's obsolete because:
 1. The less than 20 bytes of saving is negligible compares to the command
    line argument space of most hosts today.
 2. The driver program should provide adequate information for workers

There might be some hosts with such a small argv space that the 20-byte
saving really matters. If so, we can make this filter compiles conditionally in
these targets.

Related issue:
https://github.com/rui314/mold/issues/358

---
 gcc/gcc.cc | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 16bb07f2cdc..1beb23ba279 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -7904,17 +7904,6 @@ is_directory (const char *path1, bool linker)
   *cp++ = '.';
   *cp = '\0';
 
-  /* Exclude directories that the linker is known to search.  */
-  if (linker
-      && IS_DIR_SEPARATOR (path[0])
-      && ((cp - path == 6
-	   && filename_ncmp (path + 1, "lib", 3) == 0)
-	  || (cp - path == 10
-	      && filename_ncmp (path + 1, "usr", 3) == 0
-	      && IS_DIR_SEPARATOR (path[4])
-	      && filename_ncmp (path + 5, "lib", 3) == 0)))
-    return 0;
-
   return (stat (path, &st) >= 0 && S_ISDIR (st.st_mode));
 }
 
-- 
2.40.0


             reply	other threads:[~2023-04-05 18:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-05 18:32 Shiqi Zhang [this message]
2023-04-06 15:58 ` Michael Matz

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=20230405183204.17915-1-shiqi@isrc.iscas.ac.cn \
    --to=shiqi@isrc.iscas.ac.cn \
    --cc=CoelacanthusHex@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=i@rvalue.moe \
    --cc=jpalus+gcc@fastmail.com \
    --cc=marxin@gcc.gnu.org \
    --cc=mooodyhunter@outlook.com \
    --cc=rui314@gmail.com \
    --cc=xctan@cirno.icu \
    /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).