Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when cross-compiling it never uses pre-build (static) library and zlib_installed does not use the correct flags #132

Closed
BlackDex opened this issue May 29, 2023 · 6 comments

Comments

@BlackDex
Copy link
Contributor

BlackDex commented May 29, 2023

Hello there,

I build a custom musl toolchain image with several libraries, to in the end build static Rust binaries.
I just recently found out that this crate doesn't use my pre-build static zlib package.

I noticed that it in the end will never use my pre-build binary, since I'm cross-compiling and the code shows it will always build no matter what. Bypassing this didn't resulted in a working version either, since the zlib_installed function does not use all the correct compiler flags.

To fix the flags was very easy by converting

let mut cmd = Command::new(compiler.path());

to

let mut cmd = compiler.to_command();

That solved that issue, and is probably what you want in the end.
I have created a PR for this #131 .

But, the part that it will never run that function on my custom build images, is a bit more difficult i think.

Now, I can move the zlib_installed check in front of the build unconditionally check, but that is probably not what you intended.
What would be a good way to still have pre-build libraries, and make sure the checks done for the unconditionally builds are being run when really needed?

@BlackDex BlackDex changed the title fn zlib_installed does not use the correct flags, and cross-compile never uses pre-build (static) library zlib_installed does not use the correct flags, and cross-compile never uses pre-build (static) library May 29, 2023
@BlackDex BlackDex changed the title zlib_installed does not use the correct flags, and cross-compile never uses pre-build (static) library cross-compile never uses pre-build (static) library and zlib_installed does not use the correct flags May 29, 2023
@BlackDex BlackDex changed the title cross-compile never uses pre-build (static) library and zlib_installed does not use the correct flags when cross-compiling it never uses pre-build (static) library and zlib_installed does not use the correct flags May 29, 2023
@BlackDex
Copy link
Contributor Author

I also just noticed, that it also will not mark it static, even when the correct environment variables are set.

@Byron Byron linked a pull request May 30, 2023 that will close this issue
@Byron
Copy link
Member

Byron commented May 30, 2023

I am too much out of my element here to chime in, but hope that the other maintainers can help figure out which path(s) to take here.

Generally I think it would be great to have a failing test that reproduces the particular issue(s) described here, so that a fix is protected from future regressions.

@BlackDex
Copy link
Contributor Author

Anyone else who can provide some pointers?

@inferiorhumanorgans
Copy link

Well I'm attempting to cross compile for a target (dragonfly) that comes with zlib by default. The main issue for me (and why I went looking for this issue in the first place) is that the bundled zlib doesn't compile (seemingly because it doesn't pull in stdio.h).

So for me, I'd prefer to see the cross compile case default to using the available libz with the option to override.

@wezm
Copy link
Member

wezm commented Sep 20, 2023

Can this issue be closed now that #131 is merged?

@Byron
Copy link
Member

Byron commented Sep 20, 2023

Thanks for the hint! Both seem so closely related that closing this issue pre-emptively seems acceptable. However, I invite those invested to validate the issue is actually fixed, and let us know here to reopen. Thank you.

@Byron Byron closed this as completed Sep 20, 2023
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

No branches or pull requests

4 participants