[cfe-dev] clang patches for OpenBSD

Chris Lattner clattner at apple.com
Fri Feb 18 09:16:30 PST 2011


On Feb 18, 2011, at 8:07 AM, Amit Kulkarni wrote:
> These patches are adapted from
> http://www.openbsd.org/cgi-bin/cvsweb/ports/devel/llvm/patches/
> 
> Please review them and give some feedback as I hope they make it to
> llvm/clang 2.9 before your lock in a few weeks.
> Matthew Dempsky helped me to compile C++ using clang++, so that's
> resolved and clang & clang++ work fine on OpenBSD amd64 -current with
> a couple of patches for its gcc 4.2.1.

Hi Amit,

Sounds great, I'd love to get good OpenBSD support for LLVM 2.9 (which branches on March 6th).  I applied the Path.inc, SemaDeclAttr.cpp, and AttributeList.cpp hunks of this to mainline, leaving the three hunks below unresolved.

> +++ Makefile.rules	(working copy)
> @@ -971,7 +971,6 @@
> 	$(Verb) echo "{" > $@
> 	$(Verb) grep -q "\<" $< && echo "  global:" >> $@ || :
> 	$(Verb) sed -e 's/$$/;/' -e 's/^/    /' < $< >> $@
> -	$(Verb) echo "  local: *;" >> $@
> 	$(Verb) echo "};" >> $@
> clean-local::
> 	-$(Verb) $(RM) -f $(NativeExportsFile)

> IMHO, the absolute deal breaker to compiling on OpenBSD amd64 platform
> is the llvm/Makefile.rules. The "local: *;" string when generated in
> the four exports.map files breaks compilation with gcc 4.2.1 (refer to
> http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-November/011899.html).

Ok, but this is not an acceptable patch, because it will break other targets.  If you look at the makefile, it is already set up for several different export map configurations.  You could try undefining HAVE_LINK_VERSION_SCRIPT for example (see line 401 as an example of a host-specific makefile chunk that does this) or add an ifndef openbsd if none of the existing options work.


> +++ 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

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.

> 
> +++ lib/Lex/Lexer.cpp	(working copy)
> @@ -1516,6 +1516,7 @@
>   return true;
> }
> 
> +#undef __SSE2__
> #ifdef __SSE2__
> #include <emmintrin.h>
> #elif __ALTIVEC__

What is the issue with this hunk?   You're just turning off the vectorization of the lexer, but you don't indicate why.  Like the other patches above, we can't take this into mainline as-is.

-Chris





More information about the cfe-dev mailing list