This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ld.gold doesn't like if -L points to not a directory


Arkadiusz Miskiewicz <arekm@maven.pl> writes:

> [arekm@ixion-pld ~]$ more ~/test/x.c
> int main() { return 0; }
> [arekm@ixion-pld ~]$ g++ -L/bin/sh ~/test/x.c
> /usr/bin/ld: error: /bin/sh: can not read directory: Not a directory
> collect2: ld returned 1 exit status
>
> but
>
> [arekm@ixion-pld ~]$ g++ -L/notexistant ~/test/x.c
> [arekm@ixion-pld ~]$
>
> (doesn't complain)
>
> $ ld --version
> GNU gold (Linux/GNU Binutils 2.21.52.0.2.20110610) 1.11
> [...]
>
> Note that ld.bfd has no trouble with -L pointing to not a directory (it simply 
> ignores that fact).
>
> IMO gold should match ld.bfd behaviour and simply ignore not a directories.

Makes sense.  Fixed like so.  Committed to mainline.

Ian


2011-07-02  Ian Lance Taylor  <iant@google.com>

	* dirsearch.cc (Dir_cache::read_files): Ignore ENOTDIR errors.


Index: dirsearch.cc
===================================================================
RCS file: /cvs/src/src/gold/dirsearch.cc,v
retrieving revision 1.13
diff -u -p -r1.13 dirsearch.cc
--- dirsearch.cc	25 May 2011 06:15:28 -0000	1.13
+++ dirsearch.cc	3 Jul 2011 04:15:01 -0000
@@ -66,8 +66,9 @@ Dir_cache::read_files()
   DIR* d = opendir(this->dirname_);
   if (d == NULL)
     {
-      // We ignore directories which do not exist.
-      if (errno != ENOENT)
+      // We ignore directories which do not exist or are actually file
+      // names.
+      if (errno != ENOENT && errno != ENOTDIR)
 	gold::gold_error(_("%s: can not read directory: %s"),
 			 this->dirname_, strerror(errno));
       return;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]