Skip to content

Add support for external classes when compiling to hlc. - #12948

Open
qlambert-pro wants to merge 1 commit into
HaxeFoundation:developmentfrom
qlambert-pro:bugfix/issue10627
Open

Add support for external classes when compiling to hlc.#12948
qlambert-pro wants to merge 1 commit into
HaxeFoundation:developmentfrom
qlambert-pro:bugfix/issue10627

Conversation

@qlambert-pro

@qlambert-pro qlambert-pro commented Jun 19, 2026

Copy link
Copy Markdown

This PR aims at supporting extern classes when compiling to hlc, it doesn't cover extern class methods, as it looked to me like they had been dropped before genhl.
Here are some additional notes:

src/generators/genhl.ml:3507 looks very fragile but I couldn't figure out how to differentiate between builtin externs and user externs.

In hl2c, ftable is used for lookups during codegen, and functions to generate the function declarations and definitions.
In other words, ftable contains extern class methods but functions does not. As a result the index in ftable, which is duplicated as fe_index doesn't correspond to the index in the generated c code anymore, hence the need for conversion.

I tried to include a unit test to capture the new behaviour but was unsure how to setup external c code. I initially, developed this patch on top of 4.3.7 and was able to get a failing test there but ran into a lot of unrelated failing tests on top of development. (EDIT: as expected the test is failing)

The PR works on the small example, but I wasn't able to test the fix on a larger project yet, because I was unable to use the development version of the compiler to compile my project. I will look into that last part now.

@qlambert-pro

qlambert-pro commented Jun 23, 2026

Copy link
Copy Markdown
Author

I moved the test I had prepared from tests/unit/src/unit/issues/Issue10627.hx to tests/hlc/projects/Issue10627. I also included the external c code for the function. Ideally the test could perform the appropriate gcc call and run the executable to make sure that everything work.

I could use some pointers to set that up, if that is an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant