RFR: 7903731: Jextract should support macOS frameworks [v4]

Jorn Vernee jvernee at openjdk.org
Wed Mar 5 10:45:12 UTC 2025


On Tue, 4 Mar 2025 15:09:23 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

>> Read the JBS issue for more detail.
>> 
>> This patch adds two new mac specific options, to make it easier to use frameworks and remove the need of a `compile_flags.txt` file. An exception is thrown if those options are used from an other platform, the error message is inspired from `jpackage`
>
> Nizar Benalla has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains six commits:
> 
>  - Respond to feedback, Update Guide
>  - Merge branch 'refs/heads/master' into jextract-mac-os
>    
>    # Conflicts:
>    #	src/main/resources/org/openjdk/jextract/impl/resources/Messages.properties
>  - Merge remote-tracking branch 'upstream/master' into jextract-mac-os
>  - use consistent spacing
>  - Fix typos, rename some methods and bump copyright year to 2025
>  - add mac os support

doc/GUIDE.md line 991:

> 989: | `--version`                                                  | print version information and exit |
> 990: | `--macos-framework <dir>` (macOs only)           | specify the framework directory include files <br/>defaults to the current Mac OS X SDK dir<br/> This removes the need of having a compile_flags.txt with the required `-framework XYZ` options in the folder where jextract is ran |
> 991: | `-f <framework>` (macOs only)                    | specify the name of the library, path will be expanded to that of the framework folder                                                                                                                                                 |

I don't think we should mention the workaround using `compile_flags.txt` here. This won't make sense to users who are not familiar with it, and after this change, there's no need for the workaround.

src/main/java/org/openjdk/jextract/JextractTool.java line 364:

> 362:         parser.accepts("--version", "help.version", false);
> 363:         parser.accepts("--macos-framework", "help.mac.framework", true);
> 364:         parser.accepts("-f", "help.framework.library.path", true);

In clang these are named `-F` and `-framework` [1] (there's no `-f`). I think we should just match that. We did the same for `-D`, `-I` and `-l` to an extent.

[1]: https://clang.llvm.org/docs/ClangCommandLineReference.html

src/main/java/org/openjdk/jextract/JextractTool.java line 605:

> 603:     private String formatFrameworkPath(String optionString) {
> 604:         String publicPath = String.format("/System/Library/Frameworks/%1$s.framework/", optionString);
> 605:         String privatePath = String.format("/System/Library/PrivateFrameworks/%1$s.framework/", optionString);

I think Maurizios comment still applies. AFAIU we need to pass the exact framework path to `dlopen`, so we need to manually search for the frameworks in this system location, and also in the locations specified through `-F`, and then load it from one of those locations.

-------------

PR Review Comment: https://git.openjdk.org/jextract/pull/268#discussion_r1981113429
PR Review Comment: https://git.openjdk.org/jextract/pull/268#discussion_r1981125001
PR Review Comment: https://git.openjdk.org/jextract/pull/268#discussion_r1981134871


More information about the jextract-dev mailing list