[cfe-dev] clang patches for OpenBSD

Amit Kulkarni amitkulz at gmail.com
Fri Feb 18 08:07:34 PST 2011


Hello,

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.

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).

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

Thanks for your time

---------------------------llvm.diff---------------------------------------------------------

Index: lib/Support/Unix/Path.inc
===================================================================
--- lib/Support/Unix/Path.inc	(revision 125833)
+++ lib/Support/Unix/Path.inc	(working copy)
@@ -260,7 +260,7 @@
   return Path(pathname);
 }

-#if defined(__FreeBSD__) || defined (__NetBSD__) || defined(__minix)
+#if defined(__FreeBSD__) || defined (__OpenBSD__) || defined
(__NetBSD__) || defined(__minix)
 static int
 test_dir(char buf[PATH_MAX], char ret[PATH_MAX],
     const char *dir, const char *bin)
@@ -328,7 +328,7 @@
     if (realpath(exe_path, link_path))
       return Path(link_path);
   }
-#elif defined(__FreeBSD__) || defined (__NetBSD__) || defined(__minix)
+#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined
(__NetBSD__) || defined(__minix)
   char exe_path[PATH_MAX];

   if (getprogpath(exe_path, argv0) != NULL)
Index: Makefile.rules
===================================================================
--- Makefile.rules	(revision 125833)
+++ 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)


-------------------------------
clang.diff---------------------------------------------------------

Index: lib/Sema/SemaDeclAttr.cpp
===================================================================
--- lib/Sema/SemaDeclAttr.cpp	(revision 125833)
+++ lib/Sema/SemaDeclAttr.cpp	(working copy)
@@ -1603,7 +1603,7 @@
   if (Format == "scanf" || Format == "printf" || Format == "printf0" ||
       Format == "strfmon" || Format == "cmn_err" || Format == "strftime" ||
       Format == "NSString" || Format == "CFString" || Format == "vcmn_err" ||
-      Format == "zcmn_err")
+      Format == "zcmn_err" || Format == "kprintf")
     return SupportedFormat;

   if (Format == "gcc_diag" || Format == "gcc_cdiag" ||
Index: lib/Sema/AttributeList.cpp
===================================================================
--- lib/Sema/AttributeList.cpp	(revision 125833)
+++ lib/Sema/AttributeList.cpp	(working copy)
@@ -126,6 +126,7 @@
     .Case("__fastcall", AT_fastcall)
     .Case("__thiscall", AT_thiscall)
     .Case("__pascal", AT_pascal)
+    .Case("bounded", IgnoredAttribute)
     .Case("constant", AT_constant)
     .Case("device", AT_device)
     .Case("global", AT_global)
Index: lib/Lex/Lexer.cpp
===================================================================
--- lib/Lex/Lexer.cpp	(revision 125833)
+++ lib/Lex/Lexer.cpp	(working copy)
@@ -1516,6 +1516,7 @@
   return true;
 }

+#undef __SSE2__
 #ifdef __SSE2__
 #include <emmintrin.h>
 #elif __ALTIVEC__
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp	(revision 125833)
+++ 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) &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang.diff
Type: application/octet-stream
Size: 1859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110218/f79eb88b/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm.diff
Type: application/octet-stream
Size: 1283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110218/f79eb88b/attachment-0001.obj>


More information about the cfe-dev mailing list