-
Notifications
You must be signed in to change notification settings - Fork 8
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
CompileBinaries Struct #214
Conversation
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for demonstrating this alternative via code - much easier to visualise! :-)
With the reduction of binaries from 4 to 2 (after dropping the *-ld
variants), I feel like this is perhaps a bit over-complex for replacing two which
calls?
If we wanted to simplify cross_compile_env()
, then perhaps adding a single which()
function that performed the .map_err
and .into_os_string()
would be a good middle ground?
libcnb-cargo/src/cross_compile.rs
Outdated
const MAC_BINARIES: CompilerBinaries = CompilerBinaries { | ||
ld: Binary("x86_64-linux-musl-ld"), | ||
cc: Binary("x86_64-linux-musl-gcc"), | ||
}; | ||
const LINUX_BINARIES: CompilerBinaries = CompilerBinaries { | ||
ld: Binary("musl-ld"), | ||
cc: Binary("musl-gcc"), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need the *-ld
variants (whilst they are present in the cargo-make examples and #199, they are not needed and differ from the more commonly used configuration):
https://github.com/Malax/libcnb.rs/pull/199#discussion_r757620799
libcnb-cargo/src/cross_compile.rs
Outdated
), | ||
]); | ||
} else if cfg!(target_os = "linux") { | ||
// Do we want to set the env vars here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The env vars do not need to be set on Linux, since cargo/rustc correctly finds the compiler there.
Ideally in the future it will be able to do so for the OS X musl-cross too:
rust-lang/cargo#4133
As such I think we shouldn't set env vars on Linux, since I see them as more of a workaround, rather than necessary configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edmorley thoughts on just keeping the which
checks?
For me the most important thing I wanted out of the PR are 2 things:
What about just keeping the |
I also think we should only insert env vars if the env var isn't set already. |
I like using constants rather than magic strings. I also like putting the which behavior on a type. I also agree it's best done afterward as #199 is a moving target. |
yeah, I'm fine either way. None of these are blocking changes to #199. My original hope is this was going to be a quick merge in or reject. |
31ddae8
to
fb16494
Compare
@hone Can this be closed out? Comparing the implementation here with the one that landed in #199, I see many of the suggestions were incorporated, plus the module was refactored quite a bit on top: As such, I don't think there is anything else more we need from this PR? |
Yeah, let's close this out for now. I can open up a new PR if I want to bring some of these ideas forward. |
This is a change to #199. Let's leverage some Rust types to reduce some code duplication and group the cc/ld concepts together into a single struct. This moves all the defaults into
const
at the top of the file. In addition, I took @edmorley's suggestion to add some help/binary checking for themusl-tools
on linux as well.