[cfe-dev] Fwd: clang patches for OpenBSD
amitkulz at gmail.com
Fri Feb 18 13:08:24 PST 2011
I am forwarding on behalf of Matthew Dempsky.
---------- Forwarded message ----------
From: Matthew Dempsky <matthew at dempsky.org>
Date: Fri, Feb 18, 2011 at 2:02 PM
Subject: Re: [cfe-dev] clang patches for OpenBSD
To: Chris Lattner <clattner at apple.com>
Cc: Amit Kulkarni <amitkulz at gmail.com>, cfe-dev at cs.uiuc.edu
On Fri, Feb 18, 2011 at 09:16:30AM -0800, Chris Lattner wrote:
> > +++ lib/Driver/Tools.cpp (working copy)
> > @@ -3080,9 +3080,9 @@
> > if (Args.hasArg(options::OPT_pthread))
> > CmdArgs.push_back("-pthread");
> > + //CmdArgs.push_back("-lpthread");
> > if (!Args.hasArg(options::OPT_shared))
> > CmdArgs.push_back("-lc");
> > - CmdArgs.push_back("-lgcc");
> > }
> > if (!Args.hasArg(options::OPT_nostdlib) &&
> > There's a extra include of -lgcc and a deliberately commented out
> > -lpthread in llvm/tools/clang/lib/Driver/Tools.cpp.
> > I am unsure about -pthread or -lpthread but Matthew referred to this
> > particular diff in a email here
> > http://marc.info/?l=openbsd-ports&m=129780043311893&w=2
Please note that Amit's diff here is off slightly; the actual diff
that I would suggest for inclusion in LLVM/clang is attached below.
> I don't understand the issue here, but this has the same problem.
> We need this conditionalized to only apply to OpenBSD. I'm not
> familiar with the driver, so I don't know what the best way to go for
> that is.
The issue is that when the "clang" driver is invoked using the
-pthread option, it needs to pass -lpthread to ld. E.g., the freebsd
link job construction code already correctly does this, but the
openbsd implementation erroneously passes -pthread instead, which
causes a link error because ld doesn't understand this option.
(I don't have anything useful to add about the -lgcc arguments though;
they do seem redundant, but it's consistent with gcc's behavior so I'd
suggest leaving it.)
--- tools/clang/lib/Driver/Tools.cpp.orig Thu Sep 2 16:59:25 2010
+++ tools/clang/lib/Driver/Tools.cpp Tue Feb 15 10:25:35 2011
@@ -2787,7 +2787,7 @@ void openbsd::Link::ConstructJob(Compilation &C, const
More information about the cfe-dev