OpenBSD port in progress

While building an OpenBSD port for LLVM 2.3 I encountered a few issues.

The first one is that the system compiler

$ gcc -v
Reading specs from /usr/lib/gcc-lib/amd64-unknown-openbsd4.3/3.3.5/specs
Configured with:
Thread model: single
gcc version 3.3.5 (propolice)

Fails to build TableGen correctly which then crashes while processing
the tables for ARM. I fixed this by using gcc 4.2.0

The second one is that there are 8 tests failing, but none of them
seems to fail for reason linked to LLVM itself but rather
peculiarities like grep not working the same way.

simple.patch is for the 3 simple cases where plain grep is used but
regexp patterns are expected to be matched. This only works on GNU
grep. I fixed this by using grep -E.

maybe.patch is for the 2 cases where \< and \> are used. On linux
these match the end and the start of a word. To get equivalent
behavior on OpenBSD you have to use [[:<:]] and [[:>:]] and this
doesn't work on linux (or mac). Seeing how they are used, they could
be either removed (which is what maybe.patch does) or replaced by
simple non-word character matching.

The other three failures are more involved.

The first one is Feature/load_module.ll. It fails because the library
is called rather than I have a local
patch that renames the lib in the test that I doubt should be applied
to the tree.

The second one is Transforms/SimplifyLibCalls/floor.ll. nearbyint is
not replaced by nearbyintf since neither function is defined in the
OpenBSD libm. The other two are replaced fine though. My crude
solution was to remove checking for nearbyintf.

The third one is Assembler/2004-02-01-NegativeZero.ll. This fails
because the constants are printed as positive zeros. I know there is
a bug in libc on OpenBSD 4.3 that makes it print negative zeros as
positive. It will be fixed in the next release and if this is linked
then there is no concern.


simple.patch (1.68 KB)

maybe.patch (787 Bytes)

Replacing them would be better than removing them. In these two
tests, the patterns should be preceded and followed by tab



Since the initial mail, I found out that gcc doesn't like
amd64/X86_64. I made a table of versions and the problems encountered

3.3.5 (any optimization): it does to "llvm[3]: Building
instruction selector implementation with tblgen", then tblgen crashes

4.2.0 (-O0): 2 failures in tests
4.2.0 (-O1): it goes to "llvm[3]: Building instruction selector
implementation with tblgen", then tblgen crashes[1]
4.2.0 (-O2): random parts of the tests fail
4.2.0 (-O3): 2 failures in tests (the same as with -O1)

[1] the crash log for tblgen
assertion "getOperator()->isSubClassOf("SDNodeXForm") && "Unknown node
type!"" failed: file "CodeGenDAGPatterns.cpp", line 932, function
gmake[3]: *** [/usr/ports/mystuff/devel/llvm/w-llvm-2.3/llvm-2.3/lib/Target/ARM/Release/]
Abort trap (core dumped)

If anybody has an idea of how to fix this (other than using another
version of gcc because I am sick of compiling), I would appreciate. I
can offer backtraces or shell access if anybody is interested, just
ask me what you need.