[Win] Update ClangCl for OpenMP
Tool information
- Tool name: ClangCl with omp.dll
- Add: omp.dll
- Desired version: same as Clang from LLVM
- Approximate size: ~1MB?
- If this is an add request:
- Brief description of tool: OpenMP support in LLVM for Clang on Windows
- URL for tool's homepage: https://openmp.llvm.org/
- Provide a basic test case to validate the tool's functionality: https://computing.llnl.gov/tutorials/openMP/exercise.html or https://github.com/conda-forge/openmp-feedstock/blob/master/recipe/omp_hello.c
Rationale: MSVC only supports OpenMP 2.0, which is very ancient (2002 standard). LLVM/Clang + LLVM/OpenMP is a great toolchain for modern OpenMP support on Windows.
Area for Triage: Windows Compiler Support (Clang) - Support libraries
Question, Bug, or Feature?: Feature request
Virtual environments affected
- [ ] Ubuntu 16.04
- [ ] Ubuntu 18.04
- [ ] Ubuntu 20.04
- [ ] macOS 10.15
- [ ] macOS 11.0
- [x] Windows Server 2016 R2
- [x] Windows Server 2019
Can this tool be installed during the build? Yes
Tool installation time in runtime Should not add overly much on top of an LLVM/Clang build.
Example from conda-forge: https://github.com/conda-forge/openmp-feedstock/blob/master/recipe/bld-llvm-openmp.bat
Are you willing to submit a PR? I can try with guidance, but my Windows skills are very rusty.
@ax3l Just to clarify the requirements. The official site says:
With the release of Clang 3.8.0, OpenMP 3.1 support is enabled in Clang by default, and the OpenMP runtime is therefore built as a normal part of the Clang build
Does it relate to your statement "MSVC only supports OpenMP 2.0, which is very ancient (2002 standard)." and thus we should upgrade openmp only?
@dsame thank you for the hint!
Can you tell me what else I need in the virtual environment besides -T "ClangCl" to find this OpenMP install with CMake?
I am trying this, but cannot pick up the libs with find_package(OpenMP REQUIRED): https://github.com/ECP-WarpX/WarpX/pull/1541
-- The C compiler identification is Clang 10.0.0 with MSVC-like command-line
-- The CXX compiler identification is Clang 10.0.0 with MSVC-like command-line
...
CMake Error at C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
I think I found a way by using the Ninja generator :tada:
build_win_clang:
name: Clang w/ OMP
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Build & Install
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\vc\Auxiliary\build\vcvarsall.bat" x64
cmake -S . -B build ^
-G "Ninja" ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_C_COMPILER=clang-cl ^
-DCMAKE_CXX_COMPILER=clang-cl
cmake --build build --config Release --parallel 2
@dsame Is there a recommended shortcut/environment variable for the location of vcvarsall.bat?
@ax3l actually now. The path to these bats is documented in VS site
The closest variable you can use are:
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
@dsame is there also a way to use ClangCl with OpenMP using powershell?
A simple test does not find it OpenMP_CXX again, using Windows Server 2022 https://github.com/BLAST-ImpactX/impactx/pull/989
Hi @ax3l - I have put together a workflow that intends to use clang-cl with openmp in powershell.
Please let me know if this was what you were looking for.
Thanks.
Hope this workflow helps you to unblock. Closing this issue now. Thanks.