Skip to content

Conversation

@LostAquilae
Copy link
Contributor

When I tried to use this lib in a project where I was cross compiling from Linux to Freebsd, I ended up getting linking error because the cfg present in the build.rs doesn't allow the file to be run when compiling on Linux, preventing the Unix ffi from being built. I suggest to remove this cfg, as it allows cross compiling without breaking any other use case, as you check the actual target at runtime inside the build.rs

…argets. This allows to cross compile from another host to these targets
@LeoBorai LeoBorai changed the title fix: remove the cgf to run the build.rs only when compiling on unix, to allow running the build.rs while cross compiling from a non-unix target, targetting unix target fix: remove the cgf to run the build.rs only when compiling on unix Mar 23, 2025
@LeoBorai
Copy link
Owner

Hi @LostAquilae! Thatk you so much for openning this PR.

I have shortened the PR title as then it will go as commit message.

Copy link
Owner

@LeoBorai LeoBorai left a comment

Choose a reason for hiding this comment

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

I think we should consider using target_family (https://doc.rust-lang.org/reference/conditional-compilation.html#target_family) so we dont introduce unused dependencies nor build steps on non-unix systems.

@@ -1,12 +1,4 @@
fn main() {
#[cfg(any(
Copy link
Owner

Choose a reason for hiding this comment

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

By doing this the build script will also run for Windows.

Perhaps we could constraint this to run on OS Family Unix only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you are right, target_family seems a good way to allow build.rs to be run on linux while preventing it to be run on Windows. I don't think the use case of cross compiling from Windows to Freebsd will happen any time soon (I don't even know if that's actually possible). I fixed it in 7d45bff

Cargo.toml Outdated
Comment on lines 19 to 21
[build-dependencies]
cc = "1.0.73"

Copy link
Owner

Choose a reason for hiding this comment

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

cc is not used on Windows, so perhaps its better to scope this dependency to Unix based OS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used the same codegen option, 'target_family', to restrain cc dependency to unix targets only

@LostAquilae
Copy link
Contributor Author

Thank you for your feedback ! I implemented what you suggested, it works perfectly for my use case. Let me know if everything is ok for you.

@LeoBorai
Copy link
Owner

Thank you for your feedback ! I implemented what you suggested, it works perfectly for my use case. Let me know if everything is ok for you.

Glad to hear @LostAquilae!

@LeoBorai
Copy link
Owner

@LostAquilae I just updated workflow action versions here: #59

Could you please pull these changes into your branch so tests runs?

Thank you so much!

* chore: updates actions

* fix: remove lifetimes that could be elided
@LostAquilae
Copy link
Contributor Author

@LostAquilae I just updated workflow action versions here: #59

Could you please pull these changes into your branch so tests runs?

Thank you so much!

I merge your last commit in the current branch, it should be ok. Thank you !

@LostAquilae
Copy link
Contributor Author

@LeoBorai I fixed clippy warnings with last commit

Copy link
Owner

@LeoBorai LeoBorai left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@LeoBorai LeoBorai merged commit fd34175 into LeoBorai:main Mar 26, 2025
12 checks passed
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