Skip to content

Conversation

@BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented Sep 18, 2023

This commit tweaks the as.exe tool to handle passing of file paths containing non ascii characters. This is done in the following steps:

  • on windows, we don't use the argc and argv from main, since they only support ascii (unlike on linux where they contain utf8 directly). We use instead the windows api CommandLineToArgvW to get the arguments in utf16 and then convert it to utf8.
  • when parsing the arguments and creating std::filesystem::path, we cast the optarg char* to the C++20 type char8_t* so the path constructor knows the string is in utf8 encoding.
  • when creating the process, we convert the args from u8 to utf16 and use the wide char version of CreateProcess

This commit coupled with some mono aot fixes enables the compilation of a maui sample with special characters in project name. (dotnet/runtime#83203)

This commit tweaks the `as.exe` tool to handle passing of file paths containing non ascii characters. This is done in the following steps:
- on windows, we don't use the `argc` and `argv` from main, since they only support ascii (unlike on linux where they contain utf8 directly). We use instead the windows api `CommandLineToArgvW` to get the arguments in utf16 and then convert it to utf8.
- when parsing the arguments and creating `std::filesystem::path`, we cast the `optarg` char* to the C++20 type char8_t* so the path constructor knows the string is in utf8 encoding.
- when creating the process, we convert the args from u8 to utf16 and use the wide char version of `CreateProcess`
@grendello grendello merged commit 83a894f into dotnet:main Sep 19, 2023
jonpryor pushed a commit to dotnet/android that referenced this pull request Sep 20, 2023
Context: https://releases.llvm.org/17.0.1/docs/ReleaseNotes.html
Context: https://releases.llvm.org/17.0.1/tools/lld/docs/ReleaseNotes.html
Context: dotnet/android-native-tools@83a894f

Changes: dotnet/android-native-tools@L_16.0.6-6.0.0...L_17.0.1-7.0.0

  * dotnet/android-native-tools@bd42814: Bump LLVM version to 17.0.1
  * dotnet/android-native-tools@83a894f: Fix handling of unicode arguments on windows (dotnet/android-native-tools#5)

Changes: llvm/llvm-project@7cbf1a2...e19b7dc

	% git diff --shortstat 7cbf1a25...e19b7dc3
	 36477 files changed, 4026655 insertions(+), 2300714 deletions(-)

LLVM 17.0.1 has just been released.  For full set of changes in this
release please see the links above.  This is the same version of LLVM
that is used in just-released [Android NDK r26][0].

The changes that are relevant to .NET Android are:

  * Typed pointers are no longer supported and the `-opaque-pointers`
    option has been removed.  See the opaque pointers documentation
    for migration instructions.
  * The `nofpclass` attribute was introduced.  This allows more
    optimizations around special floating point value comparisons.

Additionally, Vlad Braeze fixed Unicode process argument handling in
our `gas` wrapper on Windows: dotnet/android-native-tools@83a894fc.

[0]: https://github.com/android/ndk/wiki/Changelog-r26
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 this pull request may close these issues.

2 participants