Skip to content

Set -DLIBOMP_FORTRAN_MODULES=ON on windows #134

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

Merged
merged 7 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions recipe/build-pkg.bat → recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,9 @@ cmake -G "Ninja" ^
-DCMAKE_BUILD_TYPE="Release" ^
-DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
-DCMAKE_INSTALL_PREFIX:PATH=%LIBRARY_PREFIX% ^
-DLIBOMP_FORTRAN_MODULES=ON ^
..
if %ERRORLEVEL% neq 0 exit 1

cmake --build . --target install
if %ERRORLEVEL% neq 0 exit 1

:: delete libiomp5md.dll which is incorrectly copied over in the build
:: del /F /Q %LIBRARY_PREFIX%\bin\libiomp5md.dll
:: del /F /Q %LIBRARY_PREFIX%\lib\libiomp5md.dll

if not exist "%LIBRARY_PREFIX%\lib\clang\%PKG_VERSION%\include\" mkdir "%LIBRARY_PREFIX%\lib\clang\%PKG_VERSION%\include"
if %ERRORLEVEL% neq 0 exit 1

:: Standalone libomp build doesn't put omp.h in clang's default search path
cp %LIBRARY_PREFIX%\include\omp.h %LIBRARY_PREFIX%\lib\clang\%PKG_VERSION%\include
cmake --build .
if %ERRORLEVEL% neq 0 exit 1
11 changes: 0 additions & 11 deletions recipe/build-pkg.sh → recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,3 @@ cmake -G Ninja \
..

cmake --build .
cmake --install .

rm -f $PREFIX/lib/libgomp$SHLIB_EXT

mkdir -p $PREFIX/lib/clang/$PKG_VERSION/include
# Standalone libomp build doesn't put omp.h in clang's default search path
cp $PREFIX/include/omp.h $PREFIX/lib/clang/$PKG_VERSION/include
if [[ "$target_platform" == linux-* ]]; then
# move libarcher.so so that it doesn't interfere
mv $PREFIX/lib/libarcher.so $PREFIX/lib/libarcher.so.bak
fi
4 changes: 4 additions & 0 deletions recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fortran_compiler: # [win]
- flang # [win]
fortran_compiler_version: # [win]
- 19 # [win]
19 changes: 19 additions & 0 deletions recipe/install_pkg.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo on

cd openmp/build

cmake --install .
if %ERRORLEVEL% neq 0 exit 1

if not exist "%LIBRARY_PREFIX%\lib\clang\%PKG_VERSION%\include\" mkdir "%LIBRARY_PREFIX%\lib\clang\%PKG_VERSION%\include"
if %ERRORLEVEL% neq 0 exit 1

:: Standalone libomp build doesn't put omp.h in clang's default search path
cp %LIBRARY_PREFIX%\include\omp.h %LIBRARY_PREFIX%\lib\clang\%PKG_VERSION%\include
if %ERRORLEVEL% neq 0 exit 1

:: remove fortran bits from regular llvm-openmp package
if "%PKG_NAME%" NEQ "llvm-openmp-fortran" (
del /s /q %LIBRARY_INC%\omp_lib.mod
del /s /q %LIBRARY_INC%\omp_lib_kinds.mod
)
16 changes: 16 additions & 0 deletions recipe/install_pkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -ex

cd openmp/build

cmake --install .

rm -f $PREFIX/lib/libgomp$SHLIB_EXT

mkdir -p $PREFIX/lib/clang/$PKG_VERSION/include
# Standalone libomp build doesn't put omp.h in clang's default search path
cp $PREFIX/include/omp.h $PREFIX/lib/clang/$PKG_VERSION/include
if [[ "$target_platform" == linux-* ]]; then
# move libarcher.so so that it doesn't interfere
mv $PREFIX/lib/libarcher.so $PREFIX/lib/libarcher.so.bak
fi
68 changes: 57 additions & 11 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,40 @@ source:
- patches/0001-link-libomp-to-compiler-rt-on-osx-arm.patch

build:
number: 0
number: 1

requirements:
build:
- {{ stdlib("c") }}
- {{ compiler("cxx") }}
- {{ compiler("fortran") }} # [win]
- clang # [win]
- cmake
- ninja
host:
- llvmdev {{ version }}
# see https://github.com/llvm/llvm-project/issues/54596
- compiler-rt # [osx and arm64]

outputs:
- name: llvm-openmp
script: build-pkg.sh # [unix]
script: build-pkg.bat # [win]
script: install_pkg.sh # [unix]
script: install_pkg.bat # [win]
build:
ignore_run_exports_from:
- {{ compiler("cxx") }}
- {{ compiler("fortran") }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .mod files are specific to the gfortran version (maybe not the major version, but the soversion. not sure), so it's not possible to remove these.

run_exports:
strong:
- {{ pin_subpackage("llvm-openmp", max_pin=None) }}
- _openmp_mutex >={{ openmp_ver }} # [linux]
- _openmp_mutex * *_llvm # [linux]
requirements:
build:
- cmake
# for run-exports
- {{ stdlib("c") }}
- {{ compiler("cxx") }}
- clang # [win]
- cmake
- ninja
- perl
host:
- llvmdev {{ version }}|{{ version }}.*
# see https://github.com/llvm/llvm-project/issues/54596
- compiler-rt # [osx and arm64]
run_constrained:
- openmp {{ version }}|{{ version }}.*
test:
Expand All @@ -58,6 +66,12 @@ outputs:
- test -f $PREFIX/include/omp.h # [unix]
- if not exist %LIBRARY_INC%\omp.h exit 1 # [win]

# absence of fortran bits
- test ! -f $PREFIX/include/omp_lib.mod # [linux]
- test ! -f $PREFIX/include/omp_lib_kinds.mod # [linux]
- if exist %LIBRARY_INC%\omp_lib.mod exit 1 # [win]
- if exist %LIBRARY_INC%\omp_lib_kinds.mod exit 1 # [win]

# shared library
- test -f $PREFIX/lib/libomp.so # [linux]
- test -f $PREFIX/lib/libomp.dylib # [osx]
Expand All @@ -71,6 +85,38 @@ outputs:
- ./omp_hello # [unix]
- '%cd%\omp_hello.exe' # [win]

- name: llvm-openmp-fortran
script: install_pkg.sh # [unix]
script: install_pkg.bat # [win]
build:
# restricted to windows for now
skip: true # [not win]
run_exports:
strong:
- {{ pin_subpackage("llvm-openmp", max_pin=None) }}
- _openmp_mutex >={{ openmp_ver }} # [linux]
- _openmp_mutex * *_llvm # [linux]
requirements:
build:
- cmake
# for run-exports
- {{ stdlib("c") }}
- {{ compiler("cxx") }}
- {{ compiler("fortran") }} # [linux]
host:
- {{ pin_subpackage("llvm-openmp", exact=True) }}
run:
- {{ pin_subpackage("llvm-openmp", exact=True) }}
run_constrained:
# already contains the version
- {{ compiler("fortran") }}
test:
commands:
- test -f $PREFIX/include/omp_lib.mod # [linux]
- test -f $PREFIX/include/omp_lib_kinds.mod # [linux]
- if not exist %LIBRARY_INC%\omp_lib.mod exit 1 # [win]
- if not exist %LIBRARY_INC%\omp_lib_kinds.mod exit 1 # [win]

about:
home: http://openmp.llvm.org/
license: Apache-2.0 WITH LLVM-exception
Expand Down