Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang] Implement MSVC predefined macros for Windows #67675

Closed
pbo-linaro opened this issue Sep 28, 2023 · 6 comments · Fixed by #73250
Closed

[flang] Implement MSVC predefined macros for Windows #67675

pbo-linaro opened this issue Sep 28, 2023 · 6 comments · Fixed by #73250

Comments

@pbo-linaro
Copy link
Contributor

Linaro has been working on flang support, for Windows on Arm. It is included in official release for this platform.
The version included targets MSVC ABI, and not GNU one (available with msys2).

We have been trying to build OpenBLAS and ran into issues with CMake support.
Currently, we are working with CMake community to support flang (MSVC), see this pull request.

As part of the feedback from CMake maintainer, it is currently difficult to identify which ABI and architecture flang is targeting. One solution, as suggested here, would be to implement a set of MSVC predefined macros, like clang already does.
At least having _MSC_VER and _M_{X64,ARM64,IX86}, would be a good start. It would allow CMake, or any other tool, to identify easily flang configuration, without having to parse any output result.

@github-actions github-actions bot added the flang Flang issues not falling into any other category label Sep 28, 2023
@bradking
Copy link
Contributor

Cc: @DavidTruby

@EugeneZelenko EugeneZelenko added flang:driver and removed flang Flang issues not falling into any other category labels Nov 17, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 17, 2023

@llvm/issue-subscribers-flang-driver

Author: Pierrick Bouvier (pbo-linaro)

Linaro has been working on flang support, for Windows on Arm. It is included in [official release](https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.1/LLVM-17.0.1-woa64.exe) for this platform. The version included targets MSVC ABI, and not GNU one (available with msys2).

We have been trying to build OpenBLAS and ran into issues with CMake support.
Currently, we are working with CMake community to support flang (MSVC), see this pull request.

As part of the feedback from CMake maintainer, it is currently difficult to identify which ABI and architecture flang is targeting. One solution, as suggested here, would be to implement a set of MSVC predefined macros, like clang already does.
At least having _MSC_VER and _M_{X64,ARM64,IX86}, would be a good start. It would allow CMake, or any other tool, to identify easily flang configuration, without having to parse any output result.

@DavidTruby
Copy link
Member

I think adding these macros makes sense, I’m happy to post a patch to add them. #72519 also contains the macros used to check the msvc crt being used, I’ll put MSC_VER and the target macros in a separate patch

@DavidTruby
Copy link
Member

Having had another look, I'm not sure MSC_VER really means much for flang; I'm happy that we can define it to whatever the default is but we aren't passing C or C++ stdlib types across any sort of ABI boundary so I'm not sure it matters which ABI version you're building for? Correct me if I'm wrong here and there's something I've missed.

If I'm correct about the above, we can define it to whatever clang uses as a default so you can check if you are targeting the MSVC ABI or not but I don't want to add support for the -fms-compatibility-version flag because I don't think we should suggest that it does anything when it doesn't.

@bradking
Copy link
Contributor

I think defining _MSC_VER to clang's default is fine. If anyone later has a use case that needs a more accurate value, -fms-compatibility-version can be reconsidered later.

@bradking
Copy link
Contributor

Actually while testing #73250 I found that you're actually defining a precise _MSC_VER value. It can even be controlled by flang-new -target x86_64-pc-windows-msvc19.35.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants