I am trying to build llvm along with clang and compiler-rt. When I run make, I am getting the following compilation error (I tried compiling llvm-3.2, which is what I need for my project, but also tried llvm-3.3 and the current llvm source from the git repository).
…
COMPILE: clang_linux/full-x86_64/x86_64: /home/pranav/smack-project/llvm/src/projects/compiler-rt/lib/enable_execute_stack.c
/home/pranav/smack-project/llvm/src/projects/compiler-rt/lib/enable_execute_stack.c:53:29: error: cast to 'unsigned char ’ from smaller integer type ‘unsigned int’
[-Werror,-Wint-to-pointer-cast]
unsigned char startPage = (unsigned char*)(p & pageAlignMask);
^
/home/pranav/smack-project/llvm/src/projects/compiler-rt/lib/enable_execute_stack.c:54:27: error: cast to 'unsigned char ’ from smaller integer type ‘unsigned int’
[-Werror,-Wint-to-pointer-cast]
unsigned char endPage = (unsigned char*)((p+TRAMPOLINE_SIZE+pageSize) & pageAlignMask);
^
2 errors generated.
…
On gcc --version I get the following output:
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
My operating system is a Ubuntu 12.04.1 LTS. On typing uname -a I get:
Linux pranav 3.2.0-33-generic-pae #52-Ubuntu SMP Thu Oct 18 16:39:21 UTC 2012 i686 i686 i386 GNU/Linux
Any ideas as to how to resolve this compilation error?
You can disable -Werror by adding the cmake flag -DLLVM_ENABLE_WERROR=OFF, which should let it just ignore that (that's also the default, so you must have turned it on somewhere)
I see that ENABLE_WERROR is being set to off (the default value) in the config.log in the llvm build. However on grepping for WERROR in the compiler-rt folder I get the following output:
Yes I am sure that the llvm, clang and compiler-rt are synced to the same
version. I downloaded them all from git http://llvm.org/docs/GettingStarted.html#git-mirror
I think I need compiler-rt for my project but I'll verify it again to see
if I can proceed without it.
You are correct that compiler-rt is compiled with the just built clang.
The complete command that gives an error while compiler-rt compilation is:
/home/pranav/smack-project/llvm/src/projects/compiler-rt/lib/enable_execute_stack.c:53:29:
error: cast to 'unsigned char *' from smaller integer type 'unsigned int'
[-Werror,-Wint-to-pointer-cast]
unsigned char* startPage = (unsigned char*)(p & pageAlignMask);
Hm... Is it true that somewhy on your system (32-bit host, I presume),
sizeof(uintptr_t) != sizeof(unsigned char *) when you build code in 64-bit
mode (with -m64)?
yes I think that is correct. I wrote a simple program to print if sizeof(uintptr_t) != sizeof(unsigned char *) and when I compile with gcc -m64 and execute it on a 64-bit host (that is different from the 32-bit laptop on which I originally compiled the program), it says the sizes are not equal.
Btw I just checked, my project does not require compiler-rt (though its installation instructions had asked me to install compiler-rt). However, I would be glad to answer any questions related to my specific system to debug this compilation error.
yes I think that is correct. I wrote a simple program to print if
sizeof(uintptr_t) != sizeof(unsigned char *) and when I compile with gcc
-m64 and execute it on a 64-bit host (that is different from the 32-bit
laptop on which I originally compiled the program), it says the sizes are
not equal.
I'm not a language lawyer, but looks like your system has broken headers -
uintptr_t shouldn't resolve to "unsigned int" in 64-bit mode.