-
Notifications
You must be signed in to change notification settings - Fork 448
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
Expose get_archiver and get_ranlib #763
Conversation
This PR exposes cc's inferred archiver through a similar mechanism as `get_compiler`: with `get_archiver`/`try_get_archiver`. As part of this, I also realized that cc wouldn't pick up `ARFLAGS`, so I added support for that. Through that, I also realized that there was currently one place where we didn't respect `Build::ar_flags` when ar was called, so I fixed that too. Since ranlib is exposed more or less exactly like ar, I also added a `get_ranlib`/`try_get_ranlib` combination. This is, in part, to enable `openssl-src` to move to re-use `cc`'s AR (and now RANLIB) detection rather than rolling its own. See alexcrichton/openssl-src-rs#164. Note that I didn't re-use `Tool` for the return value for these getter functions, and instead just exposed `Command` directly. `Tool` has a number of relatively compiler-specific things, so it felt wrong to use. One important caveat to this is that `Command::get_program` was only added in Rust 1.57.0, so users on older versions of Rust won't have a way to recover the inferred `ar` program path, but that feels like it's probably okay given that we didn't even expose `get_archive` until now.
With this, I think we're also further along on #82 ? |
Ah, because I now use |
Note that `Command::get_program` and `Command::get_args` both stabilized in Rust 1.57.0, and so implicitly bump this crate's MSRV. Depends on rust-lang/cc-rs#763. Replaces alexcrichton#164.
Nudge on this @thomcc |
Sorry, thanks for the ping. Will get to it tomorrow. |
A problem here is we already pass our own flags to it, so I think if the user provides ARFLAGS, it will collide with these. Usually I see these used in cases like (That said I am in favor of supporting |
Hmm, I'm not sure what to do about that. Are you thinking we'd specifically check if |
Presumably if they set ARFLAGS we don't want to pass anything? |
Ohh, I see what you mean. Sure, I can make us not set flags if |
Should that also apply if they've called |
Thinking some more about it, I'm also not sure you'd actually want to skip I'm also a bit worried about the debuggability of "when I set |
There are also cases like Lines 2108 to 2120 in 621ba2c
where it feels like the arguments aren't something that'd generally be included in |
nudge @thomcc |
Ah, sorry, thanks for the ping. Looking online for other uses of ARFLAGS (in makefiles and such) it generally looks like they include stuff like That said, I guess we already support |
But presumably they don't replace all the flags. For example, input and output files still need to be specified. I guess the question here is what behavior is less surprising and less difficult to work around. I worry about the case where suddenly things stop working because your Basically: do we want to introduce hard-to-debug (but maybe rare?) errors, or make it impossible to always pass |
@danakj in chromium/chromium@8f52776 you seem to be griping that we don't support ARFLAGS. Can you weigh in on the semantics you'd like them to have? At the moment we're at a bit of an impasse. |
Hi, yes! (phone typing but I’ll do my best) In the end we changed our archive tool to one which supported -nologo on Windows (i think it was lld-llvm). However with the situation we had:
I was not looking for a way to override the mode flag of the ar tool but to (remove and) replace other flags, specifically -nologo. tldr I think I would treat the mode flags like input files and always set them, but if ARFLAGS is set i would use that in place of any extra flags (even platform specific ones like -nologo). |
That seems reasonable to me. @jonhoo do you mind changing this PR to do that? |
Yep, I'll make that change on Monday! Just to confirm, that would mean we should set |
Yep |
Oh, and, should the same apply if any arguments have been added using |
I think so, for consistency. But I suppose there is a compatibility argument... Edit: On Monday I'll look and see what the usage of |
Perhaps there is another way to remove flags with Build::ar_flag as the interface is more rich than an environment variable? |
Done in 7a0c2af 👍 |
The CI failures are because of the MSRV bump as a result of using |
How difficult is that to avoid? I don't know that we have a strong MSRV policy for this crate, but I'd weakly like to keep this to what works on debian stable, at least until the This is mostly to reduce false bug reports and nagging more than anything else, though, so if it's impossible to avoid it's not the end of the world. |
Worked around it (I think) in de69fc7. It's not entirely clear what the second argument to |
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.
Looks great. Thanks for putting up with all the back and forth.
I'll try to get a release out this weekend or so. |
Not at all — it's important to weigh the trade-offs here!
Thank you! Next up, alexcrichton/openssl-src-rs#173 😅 |
Note that `Command::get_program` and `Command::get_args` both stabilized in Rust 1.57.0, and so implicitly bump this crate's MSRV. Depends on rust-lang/cc-rs#763. Replaces alexcrichton#164.
Note that `Command::get_program` and `Command::get_args` both stabilized in Rust 1.57.0, and so implicitly bump this crate's MSRV. Depends on rust-lang/cc-rs#763. Replaces #164.
Note that `Command::get_program` and `Command::get_args` both stabilized in Rust 1.57.0, and so implicitly bump this crate's MSRV. Depends on rust-lang/cc-rs#763. Backport of alexcrichton#173.
Note that `Command::get_program` and `Command::get_args` both stabilized in Rust 1.57.0, and so implicitly bump this crate's MSRV. Depends on rust-lang/cc-rs#763. Backport of #173.
This PR exposes cc's inferred archiver through a similar mechanism as
get_compiler
: withget_archiver
/try_get_archiver
.As part of this, I also realized that cc wouldn't pick up
ARFLAGS
, so I added support for that. Through that, I also realized that there was currently one place where we didn't respectBuild::ar_flags
when ar was called, so I fixed that too.Since ranlib is exposed more or less exactly like ar, I also added a
get_ranlib
/try_get_ranlib
combination. This is, in part, to enableopenssl-src
to move to re-usecc
's AR (and now RANLIB) detection rather than rolling its own. See alexcrichton/openssl-src-rs#164.Note that I didn't re-use
Tool
for the return value for these getter functions, and instead just exposedCommand
directly.Tool
has a number of relatively compiler-specific things, so it felt wrong to use. One important caveat to this is thatCommand::get_program
was only added in Rust 1.57.0, so users on older versions of Rust won't have a way to recover the inferredar
program path, but that feels like it's probably okay given that we didn't even exposeget_archive
until now.