This is an archive of the discontinued LLVM Phabricator instance.

[flang][MSVC] Fix building with `/permissive-` flag
ClosedPublic

Authored by MehdiChinoune on May 9 2022, 12:31 PM.

Details

Reviewers
Meinersbur
Group Reviewers
Restricted Project
Commits
rG360411957b6f: [flang][MSVC] Fix building with `/permissive-` flag
Summary

CLOCK_REALTIME is POSIX defined and never available with MSVC, even without /permissive-.
The difference is that the template is never instantiated and the compiler ignores the undefined identifier.

Diff Detail

Event Timeline

MehdiChinoune created this revision.May 9 2022, 12:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2022, 12:31 PM
Herald added a subscriber: jdoerfert. · View Herald Transcript
MehdiChinoune requested review of this revision.May 9 2022, 12:31 PM

Patch summary missing. What is failing with /permissive-?

Patch summary missing. What is failing with /permissive-?

CLOCKID is not defined

This is the error message:

[6795/8382] Building CXX object tools\flang\runtime\CMakeFiles\obj.FortranRuntime.dir\time-intrinsic.cpp.obj
FAILED: tools/flang/runtime/CMakeFiles/obj.FortranRuntime.dir/time-intrinsic.cpp.obj
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DBUILD_EXAMPLES -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\runtime -IC:\ws\w3\llvm-project\premerge-checks\flang\runtime -IC:\ws\w3\llvm-project\premerge-checks\flang\include -Itools\flang\include -Iinclude -IC:\ws\w3\llvm-project\premerge-checks\llvm\include -IC:\ws\w3\llvm-project\premerge-checks\llvm\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\w3\llvm-project\premerge-checks\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:__cplusplus /Zc:strictStrings /Oi /Zc:rvalueCast /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /Gw /MD /O2 /Ob2 -UNDEBUG -std:c++17  /EHs-c- /GR- /showIncludes /Fotools\flang\runtime\CMakeFiles\obj.FortranRuntime.dir\time-intrinsic.cpp.obj /Fdtools\flang\runtime\CMakeFiles\obj.FortranRuntime.dir\ /FS -c C:\ws\w3\llvm-project\premerge-checks\flang\runtime\time-intrinsic.cpp
C:\ws\w3\llvm-project\premerge-checks\flang\runtime\time-intrinsic.cpp(77): error C2065: 'CLOCK_REALTIME': undeclared identifier
C:\ws\w3\llvm-project\premerge-checks\flang\runtime\time-intrinsic.cpp(77): error C3861: 'CLOCK_REALTIME': identifier not found
C:\ws\w3\llvm-project\premerge-checks\flang\runtime\time-intrinsic.cpp(146): error C2065: 'CLOCK_REALTIME': undeclared identifier
C:\ws\w3\llvm-project\premerge-checks\flang\runtime\time-intrinsic.cpp(146): error C3861: 'CLOCK_REALTIME': identifier not found

https://buildkite.com/llvm-project/premerge-checks/builds/92047#ae63959e-de4c-4cf0-a663-eeab39a06ce8/410-7338

Please add a summary where you mention that CLOCK_REALTIME is POSIX defined and never available with msvc, even without /permissive-. The difference is that the template is never instantiated and the compiler ignores the undefined identifier. Also add a comment that without CLOCKID defined (e.g. Windows), it will fallback to the other implementation.

Interestingly, the same problem was solved differently for GetDateAndTime without the template stuff.

MehdiChinoune edited the summary of this revision. (Show Details)May 13 2022, 8:50 PM

Please add a summary where you mention that CLOCK_REALTIME is POSIX defined and never available with msvc, even without /permissive-. The difference is that the template is never instantiated and the compiler ignores the undefined identifier.

done, I have copied your phrases.

Also add a comment that without CLOCKID defined (e.g. Windows), it will fallback to the other implementation.

It is already mentioned in the source file (line-65 and line-95)

This revision is now accepted and ready to land.May 19 2022, 8:06 AM

LGTM

Could you push it for me, Please.

This revision was automatically updated to reflect the committed changes.