[cfe-dev] Clang Configuration Manager

Cornel Punga via cfe-dev cfe-dev at lists.llvm.org
Thu Oct 15 18:40:36 PDT 2015


Hi,

I started implementing the first step. I decided to implement a distinct
tool(from what Clang does) that gathers system information. This is because
I didn't find the Clang code that does this(searched for a pointer in
docs), also I think it is easier to write such a tool in Python instead of
modifying the Clang code to output that info. Anyway, my decision is
debatable, what do you think about it?

I will keep the source code in this repo:
https://github.com/ner0x652/llvm-prohemium

Please, keep in mind that I am not a Python expert so, may be, the skeleton
I wrote is not as good as you hope(want). Any support and advice is
welcomed.

Thank you!

În Mar, 13 oct. 2015 la 18:29, Renato Golin <renato.golin at linaro.org> a
scris:

> On 13 October 2015 at 22:45, Cornel Punga <cornel.punga at gmail.com> wrote:
> > If I understood correctly, the first thing to implement is a tool that
> > gathers information about the target, like (you mentioned):
> > - cpu, OS, etc.
> > The information gathered at this step will be used to generate the JSON
> file
> > / local database. Did I understood correctly?
>
> Yes, when target == host. A simple Python script that knows how to
> gather that information (Clang knows how to, you can either use a
> similar logic or expose that as an API).
>
>
> > On the step when target != host, I need to think and research more,
> because
> > I do not have a clear image.
>
> That's the hard part. :)
>
> A simpler way to do this is to keep the database in git.
>
> Let's say you wrote a script that gathers all needed config for Linux
> on x86, ARM, MIPS and PPC. They should all be *very* similar.
>
>    Step #1: Generate CFLAGS from that info
>
> You can use it like llvm-config, ex:
>
> $ clang++ -c foo.c `target-info --target=host`
>
> This would get the host's config and output CFLAGS, which will be used
> by the Clang command line.
>
>    Step #2: Try remote execution (optional)
>
> Assuming you have ssh access to an "arm-board":
>
> $ clang++ -c foo.cpp `target-info --target=foo at arm-board.localdomain`
>
> That would supposedly connect to the target running Linux and run the
> same script, producing CFLAGS.
>
>    Step #3: Generate a JSON file
>
> x86$ target-info --name="i7" --target=host >> targets.json
> panda$ target-info --name=pandaboard" --target=host >> targets.json
> mips64$ target-info --name="mymips" --target=host >> targets.json
>
> Concatenating all results into a JSON file, and then using that file,
> say, in your home dir, default to something like ".llvm-targets.json"
>
> $ cp targets.json .llvm-targets.json
>
> $ clang++ -c foo.cpp `target-info --target=pandaboard`
>
> This would look for the JSON file, find the "pandaboard" entry, and
> then output the CFLAGS.
>
>    Step #4: Clang integration
>
> Once the JSON location is stabilised, make Clang read the file and set
> internally the flags (no CFLAGS)
>
> $ clang++ -target=pandaboard -c foo.cpp
>
> Target will not be recognised by the front-end, then your module kicks
> in and finds the .llvm-targets.json, finds the "pandaboard", applies
> the flags.
>
>
> You'll have to keep the JSON file pretty simple to be able to make
> both CFLAGS and Internal Clang flags from the same source. Keeping
> only standard names like "fpu": "vfpv3" is the best, then the script
> and the Clang module know what to do by themselves.
>
> hope this helps.
>
> cheers,
> --renato
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151016/754c0400/attachment.html>


More information about the cfe-dev mailing list