From 008f1b887e7aede462932eff14c821b567b13135 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sat, 3 Aug 2024 21:45:46 +1100 Subject: [PATCH 1/2] lighten run-dependencies of flang; no need for all of clangdev --- recipe/meta.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index d48a957..ce2582d 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -106,7 +106,8 @@ outputs: - {{ pin_subpackage('libfortran-main', exact=True) }} run: - sysroot_{{ target_platform }} >={{ c_stdlib_version }} # [linux] - - clangdev =={{ version }} + - clang =={{ version }} + - compiler-rt =={{ version }} - {{ pin_subpackage('libflang', exact=True) }} - {{ pin_subpackage('libfortran-main', exact=True) }} test: From 79d0531d72987c7cfbad03073d201f8dc0e027a9 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sat, 3 Aug 2024 21:47:31 +1100 Subject: [PATCH 2/2] fix activation; doesn't work with enabledelayedexpansion --- recipe/activate.bat | 11 ++--------- recipe/activate.sh | 2 ++ recipe/deactivate.sh | 1 + recipe/install_flang.bat | 7 +++++++ recipe/meta.yaml | 8 +++++++- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/recipe/activate.bat b/recipe/activate.bat index 248f835..74559f1 100644 --- a/recipe/activate.bat +++ b/recipe/activate.bat @@ -1,5 +1,3 @@ -setlocal enabledelayedexpansion - set "_OLD_FC=%FC%" set "_OLD_FFLAGS=%FFLAGS%" set "_OLD_LD=%LD%" @@ -9,11 +7,6 @@ set "_OLD_LDFLAGS=%LDFLAGS%" set "FC=flang-new" set "LD=lld-link.exe" -:: need to read clang version for path to compiler-rt -FOR /F "tokens=* USEBACKQ" %%F IN (`clang.exe -dumpversion`) DO ( - SET "_CLANG_VER=%%F" -) - :: 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 -nostdlib -fms-runtime-lib=dll -fuse-ld=lld -fno-aligned-allocation" -set "LDFLAGS=-nostdlib -Wl,-defaultlib:%CONDA_PREFIX:\=/%/lib/clang/!CLANG_VER:~0,2!/lib/windows/clang_rt.builtins-x86_64.lib" +set "FFLAGS=-D_CRT_SECURE_NO_WARNINGS -nostdlib -fms-runtime-lib=dll -fuse-ld=lld -fno-aligned-allocation -I%LIBRARY_INC%" +set "LDFLAGS=-nostdlib -Wl,-defaultlib:%CONDA_PREFIX:\=/%/lib/clang/@MAJOR_VER@/lib/windows/clang_rt.builtins-x86_64.lib" diff --git a/recipe/activate.sh b/recipe/activate.sh index 33f448c..6a37caf 100644 --- a/recipe/activate.sh +++ b/recipe/activate.sh @@ -1,3 +1,4 @@ +export _OLD_FC=$FC export _OLD_CPATH=$CPATH export _OLD_FFLAGS=$FFLAGS export _OLD_LIBRARY_PATH=$LIBRARY_PATH @@ -14,4 +15,5 @@ else export FORTRANFLAGS="$FORTRANFLAGS --sysroot=$CONDA_BUILD_SYSROOT" fi +export FC="flang-new" export FFLAGS=$FORTRANFLAGS diff --git a/recipe/deactivate.sh b/recipe/deactivate.sh index 71319f2..754aa68 100644 --- a/recipe/deactivate.sh +++ b/recipe/deactivate.sh @@ -1,3 +1,4 @@ +export FC=$_OLD_FC export CPATH=$_OLD_CPATH export FFLAGS=$_OLD_FFLAGS export FORTRANFLAGS=$_OLD_FORTRANFLAGS diff --git a/recipe/install_flang.bat b/recipe/install_flang.bat index 9e023d5..ed29a99 100644 --- a/recipe/install_flang.bat +++ b/recipe/install_flang.bat @@ -1,12 +1,19 @@ +@echo on + cd %SRC_DIR%\build call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 cmake --build . --target install if %ERRORLEVEL% neq 0 exit 1 +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 ) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index ce2582d..6c676e1 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -9,7 +9,7 @@ source: sha256: 09c08693a9afd6236f27a2ebae62cda656eba19021ef3f94d59e931d662d4856 build: - number: 2 + number: 3 # intentionally only windows (main target) & linux (debuggability) skip: true # [osx] @@ -87,6 +87,8 @@ outputs: build: - cmake - ninja + - sed # [unix] + - m2-sed # [win] # for strong run-exports - {{ compiler('c') }} - {{ stdlib('c') }} @@ -114,6 +116,8 @@ outputs: requires: - {{ compiler('c') }} # [win] - {{ compiler('cxx') }} # [win] + - grep # [unix] + - m2-grep # [win] files: - hello_world.f90 commands: @@ -122,6 +126,8 @@ outputs: - flang-new hello_world.f90 - ./a.out # [unix] - a.exe # [win] + # check if activation worked + - env | grep "FC=" - name: flang_{{ target_platform }} run_exports: