Help building llvm on freebsd 8.4

I am trying to build LLVM from source in FreeBSD 8.4. Here are the steps i carried out

  1. Downloaded the source from http://llvm.org/releases/3.8.0/llvm-3.8.0.src.tar.xz
  2. Extracted the source into a folder.
  3. Created a build directory and inside it ran $ cmake …/llvm-3.8.0.src
  4. Started the build using $cmake --build .

It throws the following error

/home/spangeni/llvm/llvm-3.8.0.src/lib/TableGen/TGLexer.cpp: In member function ‘llvm::tgtok::TokKind llvm::TGLexer::LexNumber()’:
/home/spangeni/llvm/llvm-3.8.0.src/lib/TableGen/TGLexer.cpp:393:48: error: ‘strtoll’ was not declared in this scope
CurIntVal = strtoll(NumStart, nullptr, 16);
^
/home/spangeni/llvm/llvm-3.8.0.src/lib/TableGen/TGLexer.cpp:398:60: error: ‘strtoull’ was not declared in this scope
CurIntVal = (int64_t)strtoull(NumStart, nullptr, 16);
^
/home/spangeni/llvm/llvm-3.8.0.src/lib/TableGen/TGLexer.cpp:414:47: error: ‘strtoll’ was not declared in this scope
CurIntVal = strtoll(NumStart, nullptr, 2);
^
/home/spangeni/llvm/llvm-3.8.0.src/lib/TableGen/TGLexer.cpp:429:44: error: ‘strtoll’ was not declared in this scope
CurIntVal = strtoll(TokStart, nullptr, 10);
GCC Version = 4.9.2 CMAKE version = 3.2.3

I also tried to include stdlib.h in the file llvm-3.8.0.src/lib/TableGen/TGLexer.cpp. This din’t help.

Is there any configuration I am missing ?

You cannot build any llvm or clang releases after 3.4 on FreeBSD 8.x natively, as it is not C++11 capable. You need to use at least FreeBSD 10.x, which comes with clang 3.4.1 and libc++, providing C++11 support.

Also, please note that FreeBSD 8.x is officially EOLed as of August 1, 2015.

That said, you might have some success if you install a recent gcc port. You will most likely have to manually apply https://svnweb.freebsd.org/base?view=revision&revision=297212 though, as I have not merged that back to FreeBSD 8.

-Dimitry

Should be able to build llvm 3.5, as it implements c++11, but does not require it. And then use that to build current llvm.

Hi,

Thanks for the information.

Is it possible to compile LLVM 3.8 in FreeBSD 10.x and eventually use/run it on 8.4.
Our production environment is running 8.4 and we cannot update it.

Thanks,
Sushil Pangeni

Hi,

Thanks for the information.

Is it possible to compile LLVM 3.8 in FreeBSD 10.x and eventually use/run it on 8.4.
Our production environment is running 8.4 and we cannot update it.

Thanks,
Sushil Pangeni

You can run FreeBSD 8 executables on FreeBSD 10, but not the other way around.

If you absolutely must use FreeBSD 8, I think your best shot is to install a gcc port (at least version 4.8, since that is the first with reasonable C++11 support), and use that to compile llvm. E.g. if you install the gcc48 port, use:

cmake -DCMAKE_C_COMPILER=/usr/local/bin/gcc48 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++48 $LLVM_SOURCE_DIR

Before attempting to do so, patch up your /usr/include/stdlib.h like this:

--- include/stdlib.h 2016/03/23 18:21:26 297211
+++ include/stdlib.h 2016/03/23 19:17:12 297212
@@ -125,7 +125,7 @@

No, llvm 3.5 is the first version that requires C++11 to build. This is still one of the major upgrade hurdles for FreeBSD, as versions before 10.x did not come with C++11 support.

Also, getting clang 3.4.x and a corresponding version of libc++ to build and install on FreeBSD 8 is not completely trivial. On such older versions of FreeBSD, it is much easier to install a prepackaged version of a modern gcc, which comes with its own C++11 compatible version of libstdc++.

-Dimitry

But what about a statically linked clang-3.x where x >= 5, and running that on
FreeBSD 8?

It's possible that a clang compiled on 10 only uses system call
interfaces that exist in 8, but I'd be a bit surprised if that was the
case. If it is the case, then a static clang could work. That's
definitly not a supported scenerio.

-- Brooks