[PATCH] D98278: [test] Add ability to get error messages from CMake for errc substitution

Markus Böck via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 18 11:01:47 PDT 2021


zero9178 added a comment.

In D98278#2635190 <https://reviews.llvm.org/D98278#2635190>, @ashi1 wrote:

> In D98278#2618936 <https://reviews.llvm.org/D98278#2618936>, @zero9178 wrote:
>
>> In D98278#2616932 <https://reviews.llvm.org/D98278#2616932>, @mstorsjo wrote:
>>
>>> In D98278#2616916 <https://reviews.llvm.org/D98278#2616916>, @zero9178 wrote:
>>>
>>>> Add GetErrcMessages.cmake, which contains a cmake function to automatically get the error messages of various posix error codes needed by lit by running a small C++ program.
>>>> Currently ENOENT, EISDIR, EINVAL and EACCES are supplied. 
>>>> These error messages are then currently supplied to clang, llvm and lld as the errc_messages config parameter.
>>>>
>>>> Regarding Cross compiling: the function uses try_run which when cross compiling may use the CMAKE_CROSSCOMPILING_EMULATOR to run the code.
>>>
>>> How does it behave if such a thing isn't hooked up? Ideally it'd fall back silently and these parts of tests would just fail, but not block things overall.
>>
>> It will fall back to using Python's strerror, potentially failing if pythons strerror would not return the same strings (only the case for MSVC I believe).
>
> Hi, this patch is causing a failure when cmake runs `try_run()` with a `CMAKE_TOOLCHAIN_FILE` defined. It seems related to having a fall back if the try_run fails.
> Here is the error, and the build uses MSVC. What do you think we could do about this? Thanks.
>
>   [06:48:06][Step 1/4] CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the following cache variables appropriately:
>   [06:48:06][Step 1/4]    errc_exit_code (advanced)
>   [06:48:06][Step 1/4]    errc_exit_code__TRYRUN_OUTPUT (advanced)
>   [06:48:06][Step 1/4] For details see <manually removed>/TryRunResults.cmake

Hello! There is actually an ongoing discussion about this here https://reviews.llvm.org/D98861. For the time being you have two options if you have a cross compiling setup that can't natively run Windows programs.

1. Set CMAKE_CROSSCOMPILING_EMULATOR to an emulator that could execute the Windows program on your host. Wine comes to my mind as an example
2. You should be able to set the variables `errc_exit_code` to the value 0 and then set `errc_exit_code__TRYRUN_OUTPUT` to the stdout of the Windows program (alternatively leave it empty, but a few tests will fail)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98278/new/

https://reviews.llvm.org/D98278



More information about the cfe-commits mailing list