[cfe-dev] Automatic target selection for Clang tools

Reid Kleckner via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 18 08:06:35 PDT 2015


Moving more argv processing logic to lib/Driver sounds like a great idea.

On Thu, Sep 17, 2015 at 3:54 PM, Luke Zarko via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> The Clang gcc-compatible driver (clang/tools/driver/driver.cpp) has some
> logic to select an alternate target based on the executable it was called
> as. For instance, if you symlink i686-linux-android-gcc to clang and invoke
> it, the driver will act as though it were called with another argument
> ("-target i686-linux-android"). This leads to visible effects even in
> syntax-only compilations (like the __ANDROID__ preprocessor symbol being
> defined).
>
> This behavior is not replicated for tool invocations--for
> instance, clang::createInvocationFromCommandLine will not choose an
> alternate target based on ArgList[0]. This means that configurations stored
> in compilation databases aren't accurately replayed.
>
> One possible solution is to move the target-extracting logic from
> driver/driver.cpp to a library (Frontend/Utils.h) and to be sure to call it
> in any situation where an argv-equivalent array is used to initialize the
> compiler. Is this appropriate, or does it violate some layering principle
> that I don't understand?
>
> Thanks
>   Luke
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150918/5e50cb5d/attachment.html>


More information about the cfe-dev mailing list