[PATCH] D30991: [Driver] Fix cross compiling with Visual Studio 2017

Zachary Turner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 15 11:41:06 PDT 2017


zturner requested changes to this revision.
zturner added inline comments.
This revision now requires changes to proceed.


================
Comment at: lib/Driver/ToolChains/MSVC.cpp:48-50
+  // Undefine this macro so we can call the ANSI version of the function.
+  #undef GetEnvironmentStrings
+  #define GetEnvironmentStringsA GetEnvironmentStrings
----------------
I think you will need to delete this part (see comment below).


================
Comment at: lib/Driver/ToolChains/MSVC.cpp:474
+
+      char *EnvBlock = GetEnvironmentStringsA();
+      if (EnvBlock == nullptr) goto SkipSettingEnvironment;
----------------
This is all wrong.  In the implementation of `ExecuteAndWait`, we construct a wide environment by calling `UTF8toUTF16` on each string.  `GetEnvironmentStringsA` not only doesn't return UTF8, it doesn't even return ANSI characters.

I think you need to do the work to call `GetEnvironmentStringsW`, then do the reverse of the operation performed in `llvm/lib/Support/Windows/Program.inc` in the `static bool Execute` function.  It's unfortunate that there's not a version that already takes a wide character array, though.


https://reviews.llvm.org/D30991





More information about the cfe-commits mailing list