-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Workaround for .cmd
quoting bug on Windows leads to command line is too long
errors
#104
Comments
The proper fix is instead to invoke Would this also hit the |
Yeah, it would be ideal if we could reliably override the target that gets passed to clang. Is it really enough to specify the target via What about crates using the Does the
I was a little surprised by the issue being locked too, since I had also wanted to try and contribute to fixing the issue. Even now it's a little odd that the issue is locked since we can't join the dots with any follow up discussion. Considering that you looked at this issue last year, it would have been good to have got your input here! |
Taking a look at the |
Yes it is. As per linked upstream docs that is the only thing you'd fall back to the scripts for. Both
EDIT: Ah you found where this happens in the comment above.
👍 |
I think for now, I'm going to take another pass at fixing this issue based on @MarijnS95's solution in Maybe as a follow up we could reconsider the possibility of depending on |
Hmm, so an issue I hit with the above solution is that it's not compatible with We currently have a number of I'm not sure how a tool like |
We read the config in
|
urgh, reading the cargo config files sounds absolutely horrible though :( so does xbuild/ndk-build re-implement the logic for merging |
Yes, I really wish more of this could be offloaded or built into or extending
Not yet :( |
Considering that trying to pass |
I actually thought I'd make a last ditch attempt at handling parsing the cargo configs properly using the cargo crate, and yeah this is basically impossible to do outside of cargo proper because the Here's are some comments from First you have this warning:
and then there is this: // Tricky: `RUSTFLAGS` defines the set of active `cfg` flags, active
// `cfg` flags define which `.cargo/config` sections apply, and they
// in turn can affect `RUSTFLAGS`! This is a bona fide mutual
// dependency, and it can even diverge (see `cfg_paradox` test).
//
// So what we do here is running at most *two* iterations of
// fixed-point iteration, which should be enough to cover
// practically useful cases, and warn if that's not enough for
// convergence.
let reached_fixed_point = new_flags == rustflags;
if !reached_fixed_point && turn == 0 {
turn += 1;
rustflags = new_flags;
continue;
}
if !reached_fixed_point {
config.shell().warn("non-trivial mutual dependency between target-specific configuration and RUSTFLAGS")?;
} |
why not write your own wrapper in Windows C API? |
That's effectively what the current workaround in The current workaround involves creating awkward hard links or copies of |
Just for reference here, I've posted a draft PR that at least shows how I attempted to implement the approach suggested by @MarijnS95: #106 I even went as far as parsing the cargo configs but the |
@rib sorry, maybe I lost something. I'm not familiar with Windows C API and don't known the limitations of Windows, I just used my own wrapper written in POSIX C on GNU/LInux and macOS and didn't see such error. |
No worries. It it seems like it should be possible to have a native wrapper but windows also seems to have quite a few limits on command line length that can be more annoying to deal with compared to other OSs. At least the current attempt to create a native wrapper has inadvertently also created a command line length limit that's more severe than the limit without the native wrapper. |
I known gnu linker support
maybe this is usefull on Windows. |
Thanks, yeah, it's also possible to pass arguments via |
What I'm trying now, as another experiment, is similar to using cargo-ndk as a linker wrapper but making it a |
This is an alternative workaround for bbqsrc#92 that's similar to the solution used in ndk-build except that the `-Clink-arg rustflag` is injected via a RUSTC_WRAPPER instead of trying to modify CARGO_ENCODED_RUSTFLAGS. It turned out to be practically impossible to be able to reliably set CARGO_ENCODED_RUSTFLAGS without risking trampling over rustflags that might be configured via Cargo (for example `target.<cfg>.rustflags` are especially difficult to read outside of cargo itself) This approach avoids hitting the command line length limitations of the current workaround and avoids needing temporary hard links or copying the cargo-ndk binary to the target/ directory. Even though we've only seen quoting issues with the Windows `.cmd` wrappers this change to avoid using the wrapper scripts is being applied consistently for all platforms. E.g. considering the upstream recommendation to avoid the wrapper scripts if possible: https://android-review.googlesource.com/c/platform/ndk/+/2134712 Fixes: bbqsrc#92 Fixes: bbqsrc#104 Addresses: android/ndk#1856
This is an alternative workaround for bbqsrc#92 that's similar to the solution used in ndk-build except that the `-Clink-arg rustflag` is injected via a RUSTC_WRAPPER instead of trying to modify CARGO_ENCODED_RUSTFLAGS. It turned out to be practically impossible to be able to reliably set CARGO_ENCODED_RUSTFLAGS without risking trampling over rustflags that might be configured via Cargo (for example `target.<cfg>.rustflags` are especially difficult to read outside of cargo itself) This approach avoids hitting the command line length limitations of the current workaround and avoids needing temporary hard links or copying the cargo-ndk binary to the target/ directory. Even though we've only seen quoting issues with the Windows `.cmd` wrappers this change to avoid using the wrapper scripts is being applied consistently for all platforms. E.g. considering the upstream recommendation to avoid the wrapper scripts if possible: https://android-review.googlesource.com/c/platform/ndk/+/2134712 Fixes: bbqsrc#92 Fixes: bbqsrc#104 Addresses: android/ndk#1856
This is an alternative workaround for bbqsrc#92 that's similar to the solution used in ndk-build except that the `--target=<triple><api-level>` argument for Clang is injected by using cargo-ndk as a linker wrapper instead of trying to modify CARGO_ENCODED_RUSTFLAGS. It turned out to be practically impossible to be able to reliably set CARGO_ENCODED_RUSTFLAGS without risking trampling over rustflags that might be configured via Cargo (for example `target.<cfg>.rustflags` are especially difficult to read outside of cargo itself) This approach avoids hitting the command line length limitations of the current workaround and avoids needing temporary hard links or copying the cargo-ndk binary to the target/ directory. Even though we've only seen quoting issues with the Windows `.cmd` wrappers this change to avoid using the wrapper scripts is being applied consistently for all platforms. E.g. considering the upstream recommendation to avoid the wrapper scripts if possible: https://android-review.googlesource.com/c/platform/ndk/+/2134712 Fixes: bbqsrc#92 Fixes: bbqsrc#104 Addresses: android/ndk#1856
It's hopefully possible to unravel from the trail of opened / closed PRs but just for reference here; I implemented the idea above in #107 and then it occurred to me that it would be very similar (but a bit simpler) to just set So the last PR I created (#108) is a kind of combination of ideas from the ndk-build approach of trying to pass A nice benefit here is that we only need to act as a wrapper for one purpose (linking via |
This is an alternative workaround for #92 that's similar to the solution used in ndk-build except that the `--target=<triple><api-level>` argument for Clang is injected by using cargo-ndk as a linker wrapper instead of trying to modify CARGO_ENCODED_RUSTFLAGS. It turned out to be practically impossible to be able to reliably set CARGO_ENCODED_RUSTFLAGS without risking trampling over rustflags that might be configured via Cargo (for example `target.<cfg>.rustflags` are especially difficult to read outside of cargo itself) This approach avoids hitting the command line length limitations of the current workaround and avoids needing temporary hard links or copying the cargo-ndk binary to the target/ directory. Even though we've only seen quoting issues with the Windows `.cmd` wrappers this change to avoid using the wrapper scripts is being applied consistently for all platforms. E.g. considering the upstream recommendation to avoid the wrapper scripts if possible: https://android-review.googlesource.com/c/platform/ndk/+/2134712 Fixes: #92 Fixes: #104 Addresses: android/ndk#1856
With our builds at Embark we're currently blocked from being able to cross compile with cargo ndk on windows due to this recent workaround leading to a new error:
This is particularly awkward for us because the recent PR to parse
--release
arguments is currently also required for our build system so we can't revert to an older version ofcargo ndk
and patch our NDK as a workaround.I'm wondering if we could:revert Solve hardlink on different disk issue and add support for incremental compiles on windows #101revert Create an abomination #99directly patch the.cmd
filesThe change needed in the.cmd
files to workaround the original quoting bug turns out to be quite simple:We need to change theif "%1" == "-cc1"
toif "%~1" == "-cc1"
to avoid double quotes when checking for a "-cc1" argument.cargo ndk
could potentially check the.cmd
wrappers for the workaround and warn you about it, or it could apply the workaround directly (maybe with an option).This would remove the need to springboard clang invocations throughcargo ndk
and juggling hard links etc.I can look at cooking a PR for something like this if it sounds reasonable?edit: please see the discussion below for ideas for a better solution, including PR #108
The text was updated successfully, but these errors were encountered: