This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: gold work on mingw/mingw64 support
- From: Ian Lance Taylor <iant at google dot com>
- To: Vladimir Simonov <sv at sw dot ru>
- Cc: binutils at sourceware dot org
- Date: Fri, 22 Apr 2011 16:20:40 -0700
- Subject: Re: gold work on mingw/mingw64 support
- References: <4D1CC5CB.5030700@sw.ru> <mcrd3oj12so.fsf@google.com> <4D234F4B.2010600@sw.ru> <mcr7hekr2q8.fsf@google.com> <4D24613E.1050807@sw.ru> <mcripuj5opn.fsf@google.com> <4DA56C18.5010001@sw.ru> <4DAC588F.2030308@sw.ru>
Vladimir Simonov <sv@sw.ru> writes:
> It is still having the problems I've mentioned earlier(in my patches):
> build/binutils-2.21.51/gold/descriptors.cc:136: error: 'F_SETFD' was
> not declared in this scope
> build/binutils-2.21.51/gold/descriptors.cc:136: error: 'fcntl' was not declared in this scope
> build/binutils-2.21.51/gold/output.cc:4552: error: 'S_ISLNK' was not declared in this scope
>
> Chunks fixing the issues are attached.
Committed in slightly different form as follows.
Thanks.
Ian
2011-04-22 Vladimir Simonov <sv@sw.ru>
* descriptors.cc (set_close_on_exec): New function.
(Descriptors::open): Use set_close_on_exec.
* output.cc (S_ISLNK): Define if not defined.
Index: descriptors.cc
===================================================================
RCS file: /cvs/src/src/gold/descriptors.cc,v
retrieving revision 1.9
diff -u -p -r1.9 descriptors.cc
--- descriptors.cc 14 Jul 2010 10:38:59 -0000 1.9
+++ descriptors.cc 22 Apr 2011 23:19:51 -0000
@@ -1,6 +1,6 @@
// descriptors.cc -- manage file descriptors for gold
-// Copyright 2008, 2009 Free Software Foundation, Inc.
+// Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@ -34,15 +34,24 @@
#include "descriptors.h"
#include "binary-io.h"
+// O_CLOEXEC is only available on newer systems.
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+
// Very old systems may not define FD_CLOEXEC.
#ifndef FD_CLOEXEC
#define FD_CLOEXEC 1
#endif
-// O_CLOEXEC is only available on newer systems.
-#ifndef O_CLOEXEC
-#define O_CLOEXEC 0
+static inline void
+set_close_on_exec(int fd)
+{
+// Mingw does not define F_SETFD.
+#ifdef F_SETFD
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
#endif
+}
namespace gold
{
@@ -133,7 +142,7 @@ Descriptors::open(int descriptor, const
if (O_CLOEXEC == 0
&& parameters->options_valid()
&& parameters->options().has_plugins())
- fcntl(new_descriptor, F_SETFD, FD_CLOEXEC);
+ set_close_on_exec(new_descriptor);
{
Hold_optional_lock hl(this->lock_);
Index: output.cc
===================================================================
RCS file: /cvs/src/src/gold/output.cc,v
retrieving revision 1.142
diff -u -p -r1.142 output.cc
--- output.cc 12 Apr 2011 18:06:16 -0000 1.142
+++ output.cc 22 Apr 2011 23:19:52 -0000
@@ -121,6 +121,11 @@ posix_fallocate(int o, off_t offset, off
}
#endif // !defined(HAVE_POSIX_FALLOCATE)
+// Mingw does not have S_ISLNK.
+#ifndef S_ISLNK
+# define S_ISLNK(mode) 0
+#endif
+
namespace gold
{