Skip to content

Commit

Permalink
CI: install ifort on Windows
Browse files Browse the repository at this point in the history
This enables the fortran tests for Azure.

We only test on x64, because:
- ifort isn't arm64 compatible
- x86 may in theory exist, but Meson reports it cannot compile
  executables
  • Loading branch information
eli-schwartz authored and nirbheek committed Aug 8, 2022
1 parent e10a091 commit 79db787
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 1 deletion.
66 changes: 66 additions & 0 deletions azure-pipelines.yml
@@ -1,3 +1,17 @@
# intel oneapi installation is based on the examples at
# https://github.com/oneapi-src/oneapi-ci
#
# and are copyrighted:
#
# SPDX-FileCopyrightText: 2020 Intel Corporation
# SPDX-License-Identifier: MIT
#
# The rest of this file contains the standard Meson project copyright:
#
# SPDX-License-Identifer: Apache-2.0
# Copyright 2022 The Meson development team


name: $(BuildID)

trigger:
Expand Down Expand Up @@ -35,6 +49,8 @@ pr:
variables:
CI: 1
SOURCE_VERSION: $(Build.SourceVersion)
WINDOWS_HPCKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18680/w_HPCKit_p_2022.2.0.173_offline.exe
WINDOWS_FORTRAN_COMPONENTS: intel.oneapi.win.ifort-compiler

jobs:

Expand All @@ -50,21 +66,46 @@ jobs:
compiler: msvc2017
backend: ninja
MESON_RSP_THRESHOLD: 0
# "Compiler ifort can not compile programs"
ifort: false
vc2017x64vs:
arch: x64
compiler: msvc2017
backend: vs2017
# this causes tons of C projects to error with:
# "The syntax of the command is incorrect"
ifort: false
clangclx64ninja:
arch: x64
compiler: clang-cl
backend: ninja
ifort: true

steps:
- task: Cache@2
inputs:
path: C:\Program Files (x86)\Intel\oneAPI
key: '"install" | "$(WINDOWS_HPCKIT_URL)" | "$(WINDOWS_FORTRAN_COMPONENTS)" | "compiler" | ci/intel-scripts/cache_exclude_windows.sh'
cacheHitVar: CACHE_RESTORED
condition: eq(variables.ifort, 'true')
- script: ci/intel-scripts/install_windows.bat $(WINDOWS_HPCKIT_URL) $(WINDOWS_FORTRAN_COMPONENTS)
displayName: install ifort
condition: and(ne(variables.CACHE_RESTORED, 'true'), eq(variables.ifort, 'true'))
- bash: ci/intel-scripts/cache_exclude_windows.sh
displayName: exclude unused files from cache
condition: and(ne(variables.CACHE_RESTORED, 'true'), eq(variables.ifort, 'true'))
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
architecture: 'x64'
- task: BatchScript@1
displayName: insert ifort into environment
inputs:
filename: ci/intel-scripts/activate_windows.bat
arguments: vs2019
modifyEnvironment: True
condition: eq(variables.ifort, 'true')
- task: PowerShell@2
inputs:
targetType: 'filePath'
Expand All @@ -83,22 +124,47 @@ jobs:
arch: x64
compiler: msvc2019
backend: ninja
ifort: true
vc2019x64vs:
arch: x64
compiler: msvc2019
backend: vs2019
# mysteriously, several tests fail because vs cannot find
# executables such as cmd.exe ???
ifort: false
vc2019arm64ninjacross:
arch: arm64
compiler: msvc2019
backend: ninja
extraargs: --cross arm64cl.txt --cross-only
# ifort doesn't support arm64
ifort: false

steps:
- task: Cache@2
inputs:
path: C:\Program Files (x86)\Intel\oneAPI
key: '"install" | "$(WINDOWS_HPCKIT_URL)" | "$(WINDOWS_FORTRAN_COMPONENTS)" | "compiler" | ci/intel-scripts/cache_exclude_windows.sh'
cacheHitVar: CACHE_RESTORED
condition: eq(variables.ifort, 'true')
- script: ci/intel-scripts/install_windows.bat $(WINDOWS_HPCKIT_URL) $(WINDOWS_FORTRAN_COMPONENTS)
displayName: install ifort
condition: and(ne(variables.CACHE_RESTORED, 'true'), eq(variables.ifort, 'true'))
- bash: ci/intel-scripts/cache_exclude_windows.sh
displayName: exclude unused files from cache
condition: and(ne(variables.CACHE_RESTORED, 'true'), eq(variables.ifort, 'true'))
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
architecture: 'x64'
- task: BatchScript@1
displayName: insert ifort into environment
inputs:
filename: ci/intel-scripts/activate_windows.bat
arguments: vs2019
modifyEnvironment: True
condition: eq(variables.ifort, 'true')
- task: PowerShell@2
inputs:
targetType: 'filePath'
Expand Down
16 changes: 16 additions & 0 deletions ci/intel-scripts/activate_windows.bat
@@ -0,0 +1,16 @@
REM SPDX-FileCopyrightText: 2020 Intel Corporation
REM
REM SPDX-License-Identifier: MIT

set VS_VER=%1

@call "C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat" %VS_VER%

for /f "tokens=* usebackq" %%f in (`dir /b "C:\Program Files (x86)\Intel\oneAPI\compiler\" ^| findstr /V latest ^| sort`) do @set "LATEST_VERSION=%%f"
@call "C:\Program Files (x86)\Intel\oneAPI\compiler\%LATEST_VERSION%\env\vars.bat"

echo "Visual Studio Version: %VS_VER%"
echo "OneAPI version: %LATEST_VERSION%"
echo "C:\Program Files (x86)\Intel\oneAPI\compiler\%LATEST_VERSION%\env\vars.bat"
echo "OneAPI root directory: %ONEAPI_ROOT%"
where ifort.exe
15 changes: 15 additions & 0 deletions ci/intel-scripts/cache_exclude_windows.sh
@@ -0,0 +1,15 @@
#!/bin/bash

# SPDX-FileCopyrightText: 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT

#shellcheck disable=SC2010
LATEST_VERSION=$(ls -1 "C:\Program Files (x86)\Intel\oneAPI\compiler" | grep -v latest | sort | tail -1)

rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\compiler\lib\ia32_win"
rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\bin\intel64_ia32"
rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\emu"
rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\oclfpga"
rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\ocloc"
rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\x86"
16 changes: 16 additions & 0 deletions ci/intel-scripts/install_windows.bat
@@ -0,0 +1,16 @@
REM SPDX-FileCopyrightText: 2022 Intel Corporation
REM
REM SPDX-License-Identifier: MIT

set URL=%1
set COMPONENTS=%2

curl.exe --output %TEMP%\webimage.exe --url %URL% --retry 5 --retry-delay 5
start /b /wait %TEMP%\webimage.exe -s -x -f webimage_extracted --log extract.log
del %TEMP%\webimage.exe
if "%COMPONENTS%"=="" (
webimage_extracted\bootstrapper.exe -s --action install --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=.
) else (
webimage_extracted\bootstrapper.exe -s --action install --components=%COMPONENTS% --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=.
)
rd /s/q "webimage_extracted"
2 changes: 1 addition & 1 deletion ci/run.ps1
Expand Up @@ -67,7 +67,7 @@ echo ($env:Path).Replace(';',"`n")
echo "=== PATH END ==="
echo ""

$progs = @("python","ninja","pkg-config","cl","rc","link","pypy3")
$progs = @("python","ninja","pkg-config","cl","rc","link","pypy3","ifort")
foreach ($prog in $progs) {
echo ""
echo "Locating ${prog}:"
Expand Down
1 change: 1 addition & 0 deletions cross/arm64cl.txt
@@ -1,6 +1,7 @@
[binaries]
c = 'cl'
cpp = 'cl'
fc = 'false'
ar = 'lib'
windres = 'rc'

Expand Down
1 change: 1 addition & 0 deletions cross/none.txt
Expand Up @@ -11,6 +11,7 @@ endian = 'little'
[binaries]
c = ['false']
cpp = ['false']
fc = ['false']
objc = ['false']
objcpp = ['false']
ar = ['false']
Expand Down

0 comments on commit 79db787

Please sign in to comment.