This is an archive of the discontinued LLVM Phabricator instance.

[libc][windows] fix small build issues.
ClosedPublic

Authored by michaelrj on Sep 26 2022, 2:31 PM.

Details

Summary

The windows build has fallen behind a little, this patch fixes some
issues that were preventing it from building.
Specifically: Some subfolders weren't being included, leading to missing
targets in the cmake.

Diff Detail

Event Timeline

michaelrj created this revision.Sep 26 2022, 2:31 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 26 2022, 2:31 PM
michaelrj requested review of this revision.Sep 26 2022, 2:31 PM
lntue added inline comments.Sep 26 2022, 3:44 PM
libc/src/__support/FPUtil/x86_64/FEnvImpl.h
57

Can you also change other exception flags to the same format too?

sivachandra added inline comments.Sep 26 2022, 4:03 PM
libc/src/__support/FPUtil/x86_64/FEnvImpl.h
57

Where is the macro named OVERFLOW coming from?

sivachandra added inline comments.Sep 26 2022, 4:06 PM
libc/src/CMakeLists.txt
12 ↗(On Diff #463022)

I think this is a case of inappropriate design somewhere - adding these directories for Windows incorrectly implies that they are available for Windows as well.

michaelrj updated this revision to Diff 463048.Sep 26 2022, 4:35 PM
michaelrj marked an inline comment as done.

address comments

libc/src/CMakeLists.txt
12 ↗(On Diff #463022)

as far as I can tell, the issue is coming from remove_test which is in test/src/stdio. It includes libc.src.unistd.access which doesn't exist unless the unistd folder is included. Putting that inside an "if target is linux" condition also works, but I feel like that is prone to mistakes for future targets that also need linux only pieces.

libc/src/__support/FPUtil/x86_64/FEnvImpl.h
57

here's the error:

In file included from C:/src/llvm-project/libc\src/__support/FPUtil/FEnvImpl.h:21:
C:/src/llvm-project/libc\src/__support/FPUtil/x86_64/FEnvImpl.h(271,44): error: expected unqualified-id
    raise_helper(internal::ExceptionFlags::OVERFLOW);
                                           ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(965,25): note: expanded from macro 'OVERFLOW'
    #define OVERFLOW    _OVERFLOW
                        ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_math.h(68,21): note: expanded from macro '_OVERFLOW'
#define _OVERFLOW   3   // overflow range error

If I had to guess it's coming in through #include <fenv.h>

lntue added inline comments.Sep 26 2022, 4:47 PM
libc/src/__support/FPUtil/x86_64/FEnvImpl.h
51

This one also?

57

Look like that definition is guarded by _CRT_INTERNAL_NONSTDC_NAMES (https://github.com/tpn/winsdk-10/blob/master/Include/10.0.16299.0/ucrt/corecrt_math.h#L962) internally to Windows C runtimes? Either #undef this or adding some Windows specific build flag might be another solution?

michaelrj updated this revision to Diff 463051.Sep 26 2022, 4:53 PM

fix missed flag

michaelrj added inline comments.Sep 26 2022, 4:54 PM
libc/src/__support/FPUtil/x86_64/FEnvImpl.h
57

#undef OVERFLOW does work, but that feels like a dangerous solution

lntue added inline comments.Sep 26 2022, 5:38 PM
libc/src/__support/FPUtil/x86_64/FEnvImpl.h
57

What I meant is to detect if _CRT_INTERNAL_NONSTDC_NAMES is defined then #undef _CRT_INTERNAL_NONSTDC_NAMES before including <fenv.h> and maybe redefine it after for Windows.

sivachandra added inline comments.Sep 26 2022, 9:57 PM
libc/src/__support/FPUtil/x86_64/FEnvImpl.h
57

I thought these macros stay undefined when compiling with clang-cl. Does something from here help: https://clang.llvm.org/docs/MSVCCompatibility.html

split fenv changes to separate patch

michaelrj edited the summary of this revision. (Show Details)Sep 27 2022, 11:45 AM
sivachandra accepted this revision.Sep 27 2022, 3:43 PM
This revision is now accepted and ready to land.Sep 27 2022, 3:43 PM
This revision was automatically updated to reflect the committed changes.