cargo-ndk: Workaround for `.cmd` quoting bug on Windows leads to `command line is too long` errors

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:

The following warnings were emitted during compilation:                                                                                                                                                        
warning: The command line is too long.
warning: Error: Errored with code 1
warning: The command line is too long.
warning: Error: Errored with code 1
error: failed to run custom build command for `physx-sys v0.11.1`

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 of cargo ndk and patch our NDK as a workaround.

I’m wondering if we could:

  1. ~~revert https://github.com/bbqsrc/cargo-ndk/pull/101~~
  2. ~~revert https://github.com/bbqsrc/cargo-ndk/pull/99~~
  3. directly patch the .cmd files

The change needed in the .cmd files to workaround the original quoting bug turns out to be quite simple:

We need to change the if "%1" == "-cc1" to if "%~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 through cargo 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

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 20 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Considering that trying to pass --target to clang without the wrappers ends up opening a really big can of worms once we realize we need to start parsing all of Cargo’s config files I think for now that the approach of patching the NDK would be my preferred solution in the short term, as in: https://github.com/bbqsrc/cargo-ndk/pull/105