[cfe-dev] clangd/libclang: how to emulate other compilers?
Manuel Klimek via cfe-dev
cfe-dev at lists.llvm.org
Thu Apr 19 10:49:51 PDT 2018
On Thu, Apr 19, 2018 at 12:57 PM Milian Wolff <mail at milianw.de> wrote:
> On Donnerstag, 19. April 2018 14:12:21 CEST Manuel Klimek wrote:
> > Ah, sorry, I missed the neon part. So this works if we add
> > -mcpu=cortex-a15. The problem is that the gcc cross compiler apparently
> > that configured at build time, and I'm not sure what the best way is to
> > figure out the full settings for cpu / fpu and float-abi, but I think
> > need to find some way to gather them from the underlying cross compiler.
> OK, thanks. This brings us one more step closer towards emulation and
> be sufficient for the example I have given. So, we now end up with these
> #1: query the target compiler
> $ ./gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-
> gnueabihf-gcc -xc++ -E -v -dM - < /dev/null
> #2: parse the output for the target:
> Target: arm-linux-gnueabihf
> #3: parse the default march GCC argument from:
> COLLECT_GCC_OPTIONS='-E' '-v' '-dM' '-march=armv7-a' '-mtune=cortex-a9' '-
> mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu'
> #4: parse the include paths:
> #include <...> search starts here:
> #5: exclude the GCC builtin include path, i.e.:
> For now, this can be done by some heuristics, like checking whether the
> contains a "varargs.h" file.
> #6: parse the defines and write all into a file that starts with `#pragma
> clang system_header`
This might still break if you define things that the compiler wants to
define on its own, so you might need a filter, but overall this looks
reasonable now :)
> #7 parse the file with clang:
> clang -Xclang -ast-dump -fsyntax-only -xc++ \
> -target arm-linux-gnueabihf \ (from #2)
> -march=armv7-a \ (from #3)
> -isystem... \ (from #4, 5)
> -imacros... \ (from #6)
> This seems to work! Thanks for the help Manuel!
> Milian Wolff
> mail at milianw.de
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev