<div dir="ltr"><div><div><div><div>Hi,<br><br></div>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?<br><br></div>I will keep the source code in this repo: <a href="https://github.com/ner0x652/llvm-prohemium">https://github.com/ner0x652/llvm-prohemium</a><br><br></div>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.<br><br></div>Thank you!<br></div><br><div class="gmail_quote"><div dir="ltr">În Mar, 13 oct. 2015 la 18:29, Renato Golin <<a href="mailto:renato.golin@linaro.org">renato.golin@linaro.org</a>> a scris:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 13 October 2015 at 22:45, Cornel Punga <<a href="mailto:cornel.punga@gmail.com" target="_blank">cornel.punga@gmail.com</a>> wrote:<br>
> If I understood correctly, the first thing to implement is a tool that<br>
> gathers information about the target, like (you mentioned):<br>
> - cpu, OS, etc.<br>
> The information gathered at this step will be used to generate the JSON file<br>
> / local database. Did I understood correctly?<br>
<br>
Yes, when target == host. A simple Python script that knows how to<br>
gather that information (Clang knows how to, you can either use a<br>
similar logic or expose that as an API).<br>
<br>
<br>
> On the step when target != host, I need to think and research more, because<br>
> I do not have a clear image.<br>
<br>
That's the hard part. :)<br>
<br>
A simpler way to do this is to keep the database in git.<br>
<br>
Let's say you wrote a script that gathers all needed config for Linux<br>
on x86, ARM, MIPS and PPC. They should all be *very* similar.<br>
<br>
   Step #1: Generate CFLAGS from that info<br>
<br>
You can use it like llvm-config, ex:<br>
<br>
$ clang++ -c foo.c `target-info --target=host`<br>
<br>
This would get the host's config and output CFLAGS, which will be used<br>
by the Clang command line.<br>
<br>
   Step #2: Try remote execution (optional)<br>
<br>
Assuming you have ssh access to an "arm-board":<br>
<br>
$ clang++ -c foo.cpp `target-info --target=foo@arm-board.localdomain`<br>
<br>
That would supposedly connect to the target running Linux and run the<br>
same script, producing CFLAGS.<br>
<br>
   Step #3: Generate a JSON file<br>
<br>
x86$ target-info --name="i7" --target=host >> targets.json<br>
panda$ target-info --name=pandaboard" --target=host >> targets.json<br>
mips64$ target-info --name="mymips" --target=host >> targets.json<br>
<br>
Concatenating all results into a JSON file, and then using that file,<br>
say, in your home dir, default to something like ".llvm-targets.json"<br>
<br>
$ cp targets.json .llvm-targets.json<br>
<br>
$ clang++ -c foo.cpp `target-info --target=pandaboard`<br>
<br>
This would look for the JSON file, find the "pandaboard" entry, and<br>
then output the CFLAGS.<br>
<br>
   Step #4: Clang integration<br>
<br>
Once the JSON location is stabilised, make Clang read the file and set<br>
internally the flags (no CFLAGS)<br>
<br>
$ clang++ -target=pandaboard -c foo.cpp<br>
<br>
Target will not be recognised by the front-end, then your module kicks<br>
in and finds the .llvm-targets.json, finds the "pandaboard", applies<br>
the flags.<br>
<br>
<br>
You'll have to keep the JSON file pretty simple to be able to make<br>
both CFLAGS and Internal Clang flags from the same source. Keeping<br>
only standard names like "fpu": "vfpv3" is the best, then the script<br>
and the Clang module know what to do by themselves.<br>
<br>
hope this helps.<br>
<br>
cheers,<br>
--renato<br>
</blockquote></div>