<div>Hello everyone!</div><div> </div><div>I am writing a tool using clang's  <span style="font-family:courier new,monospace;">tooling::RefactoringTool</span>  and want to apply it to ARM targeted sources. Those rely on their own sysroot to compile, which is incomplete and basically contains only <span style="font-family:courier new,monospace;">lib</span> and <span style="font-family:courier new,monospace;">usr</span> directories with proprietary stuff. Its <span style="font-family:courier new,monospace;">/usr/include</span> headers also differ from my system ones - so when parsing my sources with clang tool I get a lot of parsing errors related to header ordering, etc. And of course, with vendor-provided gcc4.8 everything is fine, which led me to a conclusion there's something wrong with how I use clang.</div><div> </div><div>I've tried to surpass the problem by copying my <span style="font-family:courier new,monospace;">/lib/clang/5.0.1/include</span> to this sysroot (so clang builtin headers would work correctly with new <span style="font-family:courier new,monospace;">include</span><span style="font-family:arial,sans-serif;"> & </span><span style="font-family:courier new,monospace;">lib</span>) and changing my <span style="font-family:courier new,monospace;">compile_commands.json</span> to use<span style="font-family:courier new,monospace;"> -nostdinc++ -isystem /arm-hisiv300-linux/target/usr/include -isystem /arm-hisiv300-linux/gcc/include</span><span style="font-family:arial,sans-serif;"> - so clang wouldn't rely on system headers.</span></div><div> </div><div>Unforntunately it doesn't fool clang - it still tries to search for some headers in my host system:</div><div> </div><div><span style="font-family:courier new,monospace;">arm-hisiv300-linux/bin/my-tool src/grabcommon/rtp_assemblers.cpp</span></div><div><span style="font-family:courier new,monospace;">In file included from src/grabcommon/rtp_assemblers.cpp:1:</span></div><div><span style="font-family:courier new,monospace;">...</span></div><div><span style="font-family:courier new,monospace;">In file included from /arm-hisiv300-linux/target/usr/include/limits.h:125:</span> <- here #include_next is used to access compiler-specific <span style="font-family:courier new,monospace;"><limits.h></span></div><div><span style="font-family:courier new,monospace;">In file included from /arm-hisiv300-linux/bin/../lib/clang/5.0.1/include/limits.h:37:</span> <- here clang #include_next <span style="font-family:courier new,monospace;"><limits.h></span></div><div><span style="font-family:courier new,monospace;">>>> /usr/include/limits.h:145:5 <<< error: function-like macro '__GLIBC_USE' is not defined</span> <- here I'd expect /arm-hisiv300-linux/target/usr/include/limits.h, but get system one</div><div><span style="font-family:courier new,monospace;">#if __GLIBC_USE (IEC_60559_BFP_EXT)</span></div><div> </div><div>I believe I have to pass "sysroot" directory as an argument to my tool and somehow construct <span style="font-family:courier new,monospace;">RefactoringTool</span> / <span style="font-family:courier new,monospace;">CompilationDatabase</span> instance so it take advantage of needed include directory, but how? Or am I entirely wrong and this calls for drastic measures like recompiling clang/LLVM for my needs? I am aware that I can <span style="font-family:courier new,monospace;">mount --bind my/usr/include /usr/include</span> (it works!), or put everything to some arm-based distro and use qemu, so instead of cross-compiling I just compile in place. However my intention is that the tool could be used as simple as <span style="font-family:courier new,monospace;">my-tool --sysroot /dir file.cpp</span> .</div>