Skip to content

ohttp: build: use proper target OS for bindgen - #98

Merged
martinthomson merged 1 commit into
martinthomson:mainfrom
schopin-mozilla:cross-compiling-bindings
Aug 6, 2026
Merged

martinthomson merged 1 commit into
martinthomson:mainfrom
schopin-mozilla:cross-compiling-bindings

Conversation

@schopin-mozilla

Copy link
Copy Markdown
Contributor

When running bindgen, we can't use std::env::consts::OS as it will be the host OS in the build script, rather than the target one. It doesn't matter much for Linux and Windows as the defined constants don't appear to be used anywhere (at least in the Firefox build), the code relying instead on other values such as __linux__ (compiler-defined) or XP_WIN.

@martinthomson martinthomson left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Quite right. Cross compilation support has never been a high priority here; if this is all it takes, then I'm surprised, but pleased.

@schopin-mozilla

Copy link
Copy Markdown
Contributor Author

There are other uses of consts::OS in the build script, but I'm not entirely sure whether they're right or not. I know that at least this patch applied to the vendored version in the firefox tree gets the crate to build on my windows-on-mac scenario (which then fails later because of course, that'd be too easy 😉 ).

When running bindgen, we can't use std::env::consts::OS as it will be
the host OS in the build script, rather than the target one. It doesn't
matter much for Linux and Windows as the defined constants don't appear
to be used anywhere (at least in the Firefox build), the code relying
instead on other values such as `__linux__` (compiler-defined) or
`XP_WIN`.
@schopin-mozilla
schopin-mozilla force-pushed the cross-compiling-bindings branch from 49bd48e to 32bc9cf Compare August 6, 2026 07:58
@schopin-mozilla

Copy link
Copy Markdown
Contributor Author

That last push is just to fix the author info, I had a mishap with my git config.

@martinthomson
martinthomson merged commit 5f5b640 into martinthomson:main Aug 6, 2026
@martinthomson

Copy link
Copy Markdown
Owner

I took a quick look at the other uses of OS and I think those all relate to local constraints. I could be wrong about some of those, but I'm willing to say that any progress is some progress.

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.

2 participants