Patches for Solaris on x86 solaris

Hi all,

  As mentioned earlier, we've been working on getting LLVM to build on Solaris on x86/x86-64. The changes required turned out to be fairly minor, so it's perhaps a bit of a stretch to call it a "port". There were two main issues that we ran into here:

     1. The Solaris x86 ABI by default defines the x86 registers CS, DS, ES, etc in the system headers, which clashes with their use in LLVM. It is possible to exclude these defines with -D_POSIX_C_SOURCE=199506L -U_XOPEN_SOURCE, which will compile LLVM successfully, but unfortunately llvm-gcc-4.2 will not build with these flags.

     Possible solutions:
        a. Add #undefs for all register names to the relevant header files
        b. Rename all clashing variable names in LLVM (some 950-odd lines)
        c. Rename all clashing variable names in LLVM include files, and compile LLVM only with the above flags

     The patches below implement the last solution above, as it's the smallest change - if there's a preference for a different approach I'm happy to modify accordingly. The global rename is perhaps the better solution long-term, but it would require changes to the current naming scheme. (eg CallSite CS, FileStream FS)

     2. The output from Solaris nm is just sufficiently different from GNU nm to break GenLibDeps.pl - modified the latter to be slightly more permissive. An alternative fix would be to ensure that a GNU nm is located by configure, but this seems to be the simpler fix for now.

  Outstanding issues:
     1. make check fails to run on default *-*-solaris* installations, primarily due to dependencies on GNU tools (grep, sh, etc).
     2. llvm-gcc-4.2 fails to generate valid object code on Solaris (but does generate perfectly normal LLVM output with --emit-llvm). It also requires quite a complex configure line[0], but this looks to be an upstream (GCC 4.2) issue.

  Attached patches against svn trunk:
      llvm-solaris-1.patch - Add macro definitions to CXX.Flags for SunOS only
      llvm-solaris-2.patch - Lowercase all instances of CS/DS/ES/FS in llvm include files
      llvm-solaris-3.patch - Modify GenLibDeps.pl to accept Solaris nm output
      llvm-gcc-4.2-solaris.patch - Lowercase all instances of CS/DS/ES/FS in llvm-gcc-4.2 source

  Built successfully on i386-pc-solaris2.10 (32- & 64-bit), i386-pc-solaris2.11 (32- & 64-bit), sparc-sun-solaris2.10[1], and i686-apple-darwin9.

Cheers,
Nathan

llvm-solaris-1.patch (547 Bytes)

llvm-solaris-2.patch (13.3 KB)

llvm-solaris-3.patch (479 Bytes)

llvm-gcc-4.2-solaris.patch (949 Bytes)

Looks good. I'll commit the patches for you.

Thanks!

Evan