[LLVMdev] LLVM/clang 3.2 build error on Linux

Michael Young mikado_282 at hotmail.com
Tue Feb 26 07:18:11 PST 2013


I'm posting this here to document what I encountered and the solution
I found, in hopes that others may find it useful.

When building clang 3.2 on Linux (Ubuntu 12.04, 32-bit, x86 PC), I
received the following errors (messages from the make output):

   ...
   make[4]: Entering directory `/home/youngmj/DevTools/LLVM/Version_3.2/build/tools/clang/runtime/compiler-rt'
   /bin/sh: 1: sw_vers: not found
   ...
  COMPILE:   clang_linux/full-i386/i386: /home/youngmj/DevTools/LLVM/Version_3.2/source/llvm-3.2.src/projects/compiler-rt/lib/enable_execute_stack.c
   In file included from /home/youngmj/DevTools/LLVM/Version_3.2/source/llvm-3.2.src/projects/compiler-rt/lib/enable_execute_stack.c:13:
   /usr/include/i386-linux-gnu/sys/mman.h:23:10: fatal error: 'features.h' file not found
   #include <features.h>
            ^
   1 error generated.
   ...

Searching the web, I found the following discussion:
"http://clang-developers.42468.n3.nabble.com/sw-vers-on-Linux-td4030044.html".
That would explain my sw_vers error - it appears that the problem was
introduced in r166114 and fixed in r173465. The final release 3.2
appears to tagged to r170558. Therefore, I'm reasoning that it's not
possible to build clang/compiler-rt from the unmodified 3.2 source
distributions on Linux.  So I extracted the pertinent difference and
backported it to the 3.2 source, creating a diff / patch file as
follows:

$ cat clang_darwin.mk.patch
82a83
> ifneq ($(shell which sw_vers),)
87a89
> endif
$

I then applied it to
<LLVM_SRC_DIR>/projects/compiler-rt/make/platform/clang_darwin.mk via:

  patch -b <LLVM_SRC_DIR>/projects/compiler-rt/make/platform/clang_darwin.mk < <DIR_CONTAINING_PATCH_FILE>/clang_darwin.mk.patch

and recompiled.  

Please note that the patch also fixes/avoids another problem (which
was introduced in r173465 when fixing the original problem) - that
fix is from r173977, which reverts to the original logic of filtering
out ARM architecture stuff on Darwin 10.6 (the bug introduced
effectively did the opposite, filtering out the stuff on all versions
other than 10.6).

[Side issue: why is a native PC Linux build using a file suggestively
named "*darwin*"(?) - that platform is not the host or target!]

My build now progresses, but I run smack into the
second error (features.h include file not found).  That
issue is explained in this thread:

http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-February/059748.html

Hope this helpful to others!

Thanks,
    Mike
 		 	   		  



More information about the llvm-dev mailing list