Skip to content
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
28 changes: 28 additions & 0 deletions recipes/flang-activation/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2012, Anaconda, Inc.
Copyright (c) 2015-2019, conda-forge
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 changes: 12 additions & 0 deletions recipes/flang-activation/activate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set "CONDA_BACKUP_FC=%FC%"
set "CONDA_BACKUP_FFLAGS=%FFLAGS%"
set "CONDA_BACKUP_LD=%LD%"
set "CONDA_BACKUP_LDFLAGS=%LDFLAGS%"

:: flang 19 still uses "temporary" name
set "FC=flang-new"
set "LD=lld-link.exe"

:: following https://github.com/conda-forge/clang-win-activation-feedstock/blob/main/recipe/activate-clang_win-64.bat
set "FFLAGS=-D_CRT_SECURE_NO_WARNINGS -fms-runtime-lib=dll -fuse-ld=lld -I%LIBRARY_INC%"
set "LDFLAGS=%LDFLAGS% -Wl,-defaultlib:%CONDA_PREFIX:\=/%/lib/clang/@MAJOR_VER@/lib/windows/clang_rt.builtins-x86_64.lib"
2 changes: 2 additions & 0 deletions recipes/flang-activation/activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export CONDA_BACKUP_FC=$FC
export FC="@CHOST@-flang"
27 changes: 27 additions & 0 deletions recipes/flang-activation/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
CBUILD:
- x86_64-conda-linux-gnu # [linux]
- x86_64-pc-windows-msvc # [win]
- dummy # [osx]

CHOST:
- x86_64-conda-linux-gnu # [linux]
# - wasm32-unknown-emscripten # [linux]
- x86_64-pc-windows-msvc # [win]
- dummy # [osx]

cross_target_platform:
- linux-64 # [linux]
# - emscripten-wasm32 # [linux]
- win-64 # [win]
- dummy # [osx]

zip_keys:
-
- CHOST
- cross_target_platform

channel_targets:
- conda-forge llvm_rc

channel_sources:
- conda-forge/label/llvm_rc,conda-forge
4 changes: 4 additions & 0 deletions recipes/flang-activation/deactivate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set "FC=%CONDA_BACKUP_FC%"
set "FFLAGS=%CONDA_BACKUP_FFLAGS%"
set "LD=%CONDA_BACKUP_LD%"
set "LDFLAGS=%CONDA_BACKUP_LDFLAGS%"
1 change: 1 addition & 0 deletions recipes/flang-activation/deactivate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export FC=$CONDA_BACKUP_FC
3 changes: 3 additions & 0 deletions recipes/flang-activation/hello_world.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
program hello
print *, "Hello World!"
end program hello
13 changes: 13 additions & 0 deletions recipes/flang-activation/install_flang.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@echo on

for /f "tokens=1 delims=." %%i in ("%PKG_VERSION%") do (
set "MAJOR_VER=%%i"
)

:: Copy the [de]activate scripts to %PREFIX%\etc\conda\[de]activate.d.
:: This will allow them to be run on environment activation.
FOR %%F IN (activate deactivate) DO (
IF NOT EXIST %PREFIX%\etc\conda\%%F.d MKDIR %PREFIX%\etc\conda\%%F.d
COPY %RECIPE_DIR%\%%F.bat %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.bat
sed -i 's/@MAJOR_VER@/%MAJOR_VER%/g' %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.bat
)
9 changes: 9 additions & 0 deletions recipes/flang-activation/install_flang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -ex

for CHANGE in "activate" "deactivate"
do
mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d"
cp "${RECIPE_DIR}/${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh"
sed -i 's/@CHOST@/${CHOST}/g' ${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh
done
9 changes: 9 additions & 0 deletions recipes/flang-activation/install_flang_impl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -ex

pushd "${PREFIX}"/bin
ln -s flang-new ${CHOST}-flang
if [[ "${CBUILD}" != ${CHOST} ]]; then
ln -s flang-new ${CBUILD}-flang
fi
popd
59 changes: 59 additions & 0 deletions recipes/flang-activation/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{% set version = "19.1.0.rc4" %}

package:
name: flang-activation
version: {{ version }}

build:
number: 0
# intentionally only windows (main target) & linux (debuggability)
skip: true # [osx]

outputs:
- name: flang_impl_{{ cross_target_platform }}
script: install_flang_impl.sh # [unix]
# we don't cross-compile on windows -> no symlinks
requirements:
- flang ={{ version }}
- lld # [win]
- compiler-rt_{{ cross_target_platform }} ={{ version }}
test:
commands:
- {{ CBUILD }}-flang --version # [unix]
- {{ CHOST }}-flang --version # [unix]

- name: flang_{{ cross_target_platform }}
script: install_flang.sh # [unix]
script: install_flang.bat # [win]
run_exports:
strong:
- libflang >={{ version }}
requirements:
build:
- sed # [unix]
- m2-sed # [win]
run:
- {{ pin_subpackage("flang_impl_" ~ cross_target_platform, exact=True) }}
test:
files:
- hello_world.f90
commands:
# on linux we point FC to the symlink; on windows, we point to the binary;
# the latter is still named "flang-new" instead of "flang" as of v19, see
# https://discourse.llvm.org/t/proposal-rename-flang-new-to-flang/69462
- $FC hello_world.f90 # [unix]
- "%FC% hello_world.f90" # [win]
- ./a.out # [unix]
- a.exe # [win]

about:
home: https://flang.llvm.org
license: BSD-3-Clause
license_file: LICENSE
summary: Flang is a Fortran compiler targeting LLVM.
dev_url: https://github.com/llvm/llvm-project

extra:
recipe-maintainers:
- isuruf
- h-vetinari