[cfe-users] Unexpected include directories when cross-compiling

Andreas Messer via cfe-users cfe-users at lists.llvm.org
Tue Sep 22 08:38:41 PDT 2015


Hello everybody,

I'm currently planning to use clang to compile my ARM projects. One bug I 
found in clang 3.5 - it tried to link the elf using the host's instead of the 
target's linker - is fixed in trunk source. Unfortunately I found an issue with 
the include files which - in my oppinion - is wrong. When cross compiling for 
the arm target clang adds the hosts include folders to the include search 
paths by default:

/tmp/test_clang $ clang -v --target=arm-none-eabi -c main.c -o main.o
clang version 3.8.0 (http://llvm.org/git/clang.git 
21b3f468fc871980e422404f35fcac7de83cfa9c) (llvm/trunk 248266)
Target: arm-none--eabi
Thread model: posix
InstalledDir: /usr/local/bin
 "/usr/local/stow/llvm_r248266-clang_r248254/bin/clang-3.8" -cc1 -triple 
armv4t-none--eabi -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -
main-file-name main.c -mrelocation-model static -mthread-model posix -mdisable-
fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu arm7tdmi 
-target-feature +soft-float-abi -target-feature +strict-align -target-abi aapcs 
-mfloat-abi soft -v -dwarf-column-info -coverage-file /tmp/test_clang/main.o -
resource-dir /usr/local/stow/llvm_r248266-clang_r248254/bin/../lib/clang/3.8.0 
-fdebug-compilation-dir /tmp/test_clang -ferror-limit 19 -fmessage-length 126 
-fallow-half-arguments-and-returns -fno-signed-char -fobjc-runtime=gcc -
fdiagnostics-show-option -fcolor-diagnostics -o main.o -x c main.c
clang -cc1 version 3.8.0 based upon LLVM 3.8.0svn default target x86_64-
unknown-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/stow/llvm_r248266-clang_r248254/bin/../lib/clang/3.8.0/include
 /usr/include
End of search list.
main.c:5:11: warning: self-comparison always evaluates to true [-
Wtautological-compare]
  while(i == i)
          ^
1 warning generated.
/tmp/test_clang $ 

This is not what I would expect, since this is wrong for cross compilation in 
almost any case. This can be somehow bypassed using -nostdinc option but then 
I have to manually add the .../lib/clang/3.8.0/include. What would be the best 
way to solve this?

Another thing I noticed occurs when using the -sysroot option. clang then 
tries to use $sysroot/usr/include. In my oppinion it should use 
$sysroot/include instead.

Kind regards,
Andreas


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20150922/9058db1d/attachment.sig>


More information about the cfe-users mailing list