Skip to content

Conversation

@kLabz
Copy link
Contributor

@kLabz kLabz commented Sep 16, 2025

Some changes had an impact on hxb writing/reading (latest being #12351) without changing hxb version number, meaning using hxb-lib with haxe versions from before and after that PR led to compiler failures or HxbFailure errors.

  • hxb file created with preview1 / nightlies before #12351, and read with this PR ✅
  • hxb file created with nightlies between #12351 and this PR, and read with this PR ❌ (hxb failure like when reading with preview1.. not sure this can be avoided easily but the commit range should be small enough)
  • hxb file created with this PR and read with previous nightlies/preview1: ❌ ("proper" hxb version mismatch error)
  • hxb file created with this PR and read with a minor set to a higher value (to simulate future haxe compiler) ✅

The hxbWriterConfig.ml situation is a bit weird.. and possibly not even needed. I have no idea what external tool might be using hxbVersion from it in any way atm; maybe @PXshadow ? Two alternatives there:

  • drop hxbVersion field from there entirely, and only deal with hxbMajor / hxbMinor
  • use hxbVersion (for major) and hxbMinor, which is a weird combo but doesn't duplicate stuff

- all minor checks in hxb reader become obsolete and can be dropped too
*)
let hxb_major = 2
let hxb_minor = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this start at 0?

Copy link
Contributor Author

@kLabz kLabz Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hack for retro compatibility with preview1 is to consider preview1 to be 2.0 (instead of 1.0) so that we're back to comparing minor versions

So here we'd start with 2.1 for the 12351 change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why do we check the minor version in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but then why not check hxb_major >= 2 for this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would work (well it wouldn't with current impl) too, but for the next changes we'll always want to check minor versions, never major (if the major version didn't match we wouldn't be in hxb reader in the first place).
I figured I'd use that same behavior from the beginning

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of get what you're saying, but this is completely internal and invisible. I'd find it more natural to go from version 1.0 (implied) to 2.0 instead of 2.1, and that's actually visible.

@PXshadow
Copy link
Contributor

I have no idea what external tool might be using hxbVersion from it in any way atm

I am not using hxbVersion or the hxbWriterConfig + JSON for that matter. I appreciate bringing me into the discussion, it makes me less hesitant to continue building with HXB.

The hxbWriterConfig.ml situation is a bit weird.. and possibly not even needed.

I'd like for HXB creation centered around HXMLs only, the JSON format although quite light, is still an extra format + file to think about, and the special config options could be brought into HXML via flags.

For the HXB versions, hxbMajor and hxbMinor makes more sense, but are there any explored cases to use the HXB version?

Right now my current understanding as an end user, is the best path is to generate an HXB per target I support, for a given library I want to HXBify. It must be built with Haxe 5, and after this PR in order to allow future Haxe version compiler usage. Would be interested if this is correct in your guys' view?

If I update the Haxe compiler version to a major HXB version change after this PR, will the PR version still work with the newly generated HXB?

@kLabz
Copy link
Contributor Author

kLabz commented Sep 16, 2025

I'd like for HXB creation centered around HXMLs only, the JSON format although quite light, is still an extra format + file to think about, and the special config options could be brought into HXML via flags.

I haven't really worked on the configuration part, but it seems too complex for flags with support for exclue/include arrays. It has probably not been used at all, but still..

I'm actually thinking of removing the version part of the config, as targeting a version different than current version would very likely just lead to issues.

Right now my current understanding as an end user, is the best path is to generate an HXB per target I support, for a given library I want to HXBify. It must be built with Haxe 5, and after this PR in order to allow future Haxe version compiler usage. Would be interested if this is correct in your guys' view?

I think so. Technically the zip files could even be merged I think, as iirc each target has its own directory inside the archive. Not sure if that would cause other issues, though.

If I update the Haxe compiler version to a major HXB version change after this PR, will the PR version still work with the newly generated HXB?

An hxb file written with a major version won't be compatible with any other major version. But a major version bump shouldn't happen often, if at all. Maybe we could even have a directory per version inside the hxb file, so that a single hxb file could be compatible with multiple haxe versions 🤔

@PXshadow
Copy link
Contributor

I haven't really worked on the configuration part, but it seems too complex for flags with support for exclue/include arrays. It has probably not been used at all, but still..

That's a fair point, at least for the exclude list, for include lists, I think it's pretty straightforward.

I think so. Technically the zip files could even be merged I think, as iirc each target has its own directory inside the archive. Not sure if that would cause other issues, though.

It's nice aesthetically but wouldn't change the file sizes or portability as long as hxb.$target.zip is used. If there is energy for a merge I think it should wait until code that is the same across targets could be shared in HXBs.

Maybe we could even have a directory per version inside the hxb file, so that a single hxb file could be compatible with multiple haxe versions

That would be ideal, the more HXB can feel like a first class citizen when it comes to compatibility like Haxe source code, the better on my end. Larger file sizes also wouldn't be that much of an issue,

given that in my case HXB's are substantially smaller then the source code.

42.2 MB soure code vs 26.4 hxb.hl.zip MB

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.

4 participants