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

Using #[cfg(target_os = ...] doesn't work in build scripts #53

Closed
stormshield-kg opened this issue Mar 5, 2024 · 2 comments · Fixed by #54
Closed

Using #[cfg(target_os = ...] doesn't work in build scripts #53

stormshield-kg opened this issue Mar 5, 2024 · 2 comments · Fixed by #54

Comments

@stormshield-kg
Copy link
Contributor

stormshield-kg commented Mar 5, 2024

Cross-compiling pq-src from a Linux host to a Windows target doesn't work because of these lines :

pq-sys/pq-src/build.rs

Lines 181 to 182 in 5454b4f

#[cfg(not(target_os = "windows"))]
let openssl = std::env::var("DEP_OPENSSL_INCLUDE").unwrap();

The target os is the host target in build.rs when cross-compiling, see cargo issue : rust-lang/cargo#4932 (comment).

@stormshield-kg stormshield-kg changed the title Use of #[cfg(target_os = ...] doesn't work in build scripts Using #[cfg(target_os = ...] doesn't work in build scripts Mar 5, 2024
@weiznich
Copy link
Collaborator

weiznich commented Mar 5, 2024

Thanks for opening this bug report. You are right that will not work for cross compiling. Also the file list is likely broken:

#[cfg(any(target_os = "linux", target_os = "windows"))]
(see also the other #[cfg] a bit below).

Would you mind submitting a PR fixing these locations to use the the target provided by the environment variables set by cargo instead?

@stormshield-kg
Copy link
Contributor Author

Yes, see #54.

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 a pull request may close this issue.

2 participants