[foreign] RFR 8220544: Jextract; library dependent header filtering
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Mar 15 17:57:56 UTC 2019
On 15/03/2019 17:48, Jorn Vernee wrote:
> I've implemented this, and now doing a clean build based on the latest
> jdk/jdk merge before submitting the next webrev.
>
> It's working nicely, with one caveat; Some headers rely on
> pre-processor code defined in a parent header. For instance, Python.h
> defines some pre-processor code used in pythonrun.h . The example we
> have only uses functions defined in pythonrun.h, but if we just pass
> that header to jextract Clang throws an error because of the missing
> pre-processor code from Python.h
>
> In this case we have to pass Python.h first, and then pythonrun.h to
> get everything to work. This also relies on the existence of header
> include guards in the pythonrun.h header (since we're basically
> including it twice). A similar caveat exists with the Windows API.
I think that is expected - as a user I wold first start from python.h
then add the required dependencies (same for OpenGL and friends).
>
> So, the guide-line is: Pass the main header first, then internal
> headers. e.g. If we have a main header A.h which includes a_impl.h,
> and another main header B.h which includes b_impl.h, headers should be
> passed to jextract in the order: A.h a_impl.h B.h b_impl.h
>
> I think the behavior being dependent on the ordering of the headers
> could be fixed by sorting the headers in topological order. But,
> there's still the requirement to pass all of them, or things break.
Ouch - seems like I've misread in part. The problem is not that you have
to pass two headers - but that they have to be passed _in a precise
order_ !
My first reaction was - ugh, this is bad. But, after few minutes of
shock, I'm not sure this is _so_ bad. After all, it is pretty clear what
happens when you pass multiple headers to jextract: jextract creates an
header which includes all the headers from the command line. So, in
extreme cases, yes, order is going to be important.
I believe there are also cases in C where the order of include paths
affects #include_next, or the order of libraries affects the linker
output (e.g. -l foo -l bar is not the same as -l bar -l foo).
So, I would try the dead simple thing first and see how that works.
Maurizio
>
> Any thoughs about that?
>
> Thanks,
> Jorn
>
>
> Jorn Vernee schreef op 2019-03-15 14:40:
>> I've already been using shell scripts mostly when running jextract
>> (except for simple examples). I find it very useful to be able to
>> split the command over multiple lines, especially long file paths
>> become much more readable.
>>
>> I'll start working on this then.
>>
>> Jorn
>>
>> Maurizio Cimadamore schreef op 2019-03-15 14:21:
>>> On 15/03/2019 13:15, Jorn Vernee wrote:
>>>> I still like this approach, and I think adding support for wildcard
>>>> patterns and/or header filters would make it better.
>>>>
>>>> Like you said: It's dead simple. What you pass to jextract is what
>>>> you get. Though, we could still apply dependency analysis, which
>>>> would make sure nothing that's needed gets dropped.
>>>
>>> Why don't we try this then?
>>>
>>> Note that in javac we often use this trick:
>>>
>>> javac `find <path> -name *.java`
>>>
>>> which works
>>>
>>> also, note that jextract also accepts a file with the @ syntax, etc.
>>>
>>> jextract @args.txt
>>>
>>> where args.txt is the command line (which could list all the headers
>>> you want!).
>>>
>>> Maybe this is indeed the simpler approach.
>>>
>>> Maurizio
More information about the panama-dev
mailing list