Skip to content
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

LLVM Flang 17 #28

Merged
merged 32 commits into from
Sep 3, 2023
Merged

LLVM Flang 17 #28

merged 32 commits into from
Sep 3, 2023

Conversation

h-vetinari
Copy link
Member

@h-vetinari h-vetinari commented Jul 27, 2023

Carrying forward the work from #27 to LLVM 17. Expanding the open points from the last discussion into a TODO:

  • Fix windows default compilation (currently failing on missing symbol)
  • Get rid of sysroot-hacks
  • libflang_main needs to depend on libfortran_main_{{ cross_platform }} (not the other way around)
    • we also need to put it on a path that's distinct per target triple to support e.g. having both x64 & aarch64 in the same environment (this will likely need patching of flang)
    • Currently deprioritized, because the interaction with clang is tricky, and we need cross-compilation less urgently than windows builds.
  • windows activation
    • we'll probably need to do something like the clang-win activation does to set +/- the equivalent of /MD, which will also likely have to go into a separate feedstock
  • drop osx builds
    • we're can drop osx builds as soon as they become troublesome: one compiler per language & platform is enough (and in contrast to clang, which can target the gcc runtime, flang cannot target gfortran). We're still keeping linux because it's easier to debug for general problems, but will have to make it conflict with libgfortran-ng.

Potentially:

  • improve flang vs. compiler-rt setup (i.e. detection of the latter when using msvc; ideally avoid patching)
  • decide whether to carry patch renaming flang-new to flang

Also worth noting: https://reviews.llvm.org/D154869 will reshuffle the runtime libs a lot, but this didn't land for LLVM 17.

* add lit

* don't build tests

* adapt bld.bat

* reduce parallelism in `cmake --build`

* build shared libs

* use cos7 sysroot

* host-depend on llvm/libclang-cpp for run-exports

* use flang-new for now
* use CMake modules from LLVM source

* set correct path for mlir-tblgen

* use relative paths in bld.bat

* add mlir as a build-dep when cross-compiling

* don't enable -Werror on windows

* need newer glibc
* add patch to ensure compiler-rt gets linked on windows/unix directly
  (patching HandleCompilerRT did not work)

* remove -Werror also on unix (fails on osx)

* run-depend on sysroot on linux

* also use -DCMAKE_MODULE_PATH on unix
* add build env for outputs; for strong run-exports and because windows expects it

* add ninja to install flang

* avoid clobbering libs in other outputs

* remove extra call in win flang tests

* remove host-deps of libfortran-main

* run-depend on compiler-rt for libflang on windows

* depend on conda to deduplicate already-installed files

* clean-up libfortran-main
for some silly reason, conda-build insists on merging build
& host envs for the later outputs, leading to resolution
conflicts due to llvm-opemp vs. libgomp coming from gcc.

According to the link-check on linux, it's also not used anyway...
@conda-forge-webservices
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@h-vetinari
Copy link
Member Author

@isuruf, I'd like to drop libfortran_main_{{ target }} for now. The reason is that - due to the design of flang being based on the clang driver - it's being picked up in a path that belongs to clang, so developing this patch would be very painful as we'd have to build a full clang build each time.

It's also much less relevant based on the discussion that we don't need flang on linux/osx, so we don't have to worry about cross-compilation for aarch/ppc etc. The only point where I see this becoming relevant soon-ish is for win-arm64 support, but I'd like to cross that bridge when we get there, and not block flang on win-64 over that.

Finally, https://reviews.llvm.org/D154869 will overhaul a lot of the upstream integration of the runtime libs (including fortran_main), so we'd have to redo whatever patches we come up with anyway.

we don't need cross-compilation capabilities for now, linux & osx
have gfortran anyway, and win-arm64 is not ready yet.
@h-vetinari
Copy link
Member Author

Not sure why it's still necessary after your conda-forge/clangdev-feedstock#231.

That's for linux, not windows.

You had added a test using set "CONDA_BUILD_SYSROOT=" # [win] in that PR, so I thought it also applies to windows...

recipe/meta.yaml Outdated Show resolved Hide resolved
recipe/meta.yaml Outdated Show resolved Hide resolved
Co-authored-by: Isuru Fernando <isuruf@gmail.com>
@h-vetinari
Copy link
Member Author

Alright, the sysroot on linux now gets found without having {{ compiler("cxx") }} do its own activation. 🥳

@h-vetinari
Copy link
Member Author

I've updated the todo list in the OP. The last big open question is how to do the windows compiler activation correctly. When we last spoke about this you mentioned we might need a separate feedstock. Is that necessary even if we're not doing the cross-compilation setup for now?

@h-vetinari h-vetinari changed the title WIP: Flang 17 Flang 17 Aug 31, 2023
@h-vetinari h-vetinari changed the title Flang 17 LLVM Flang 17 Aug 31, 2023
@h-vetinari h-vetinari marked this pull request as ready for review August 31, 2023 03:44
@h-vetinari
Copy link
Member Author

@isuruf, what do you think we publish this to llvm_rc? That way it's hidden away from general use, but I could start testing it out in scipy, and we'll see which problems we'll run into anyway...?

@isuruf
Copy link
Member

isuruf commented Sep 1, 2023

@isuruf, what do you think we publish this to llvm_rc?

Sure.

Is that necessary even if we're not doing the cross-compilation setup for now?

Nope

@isuruf
Copy link
Member

isuruf commented Sep 1, 2023

decide whether to carry patch renaming flang-new to flang

Let's keep using flang-new or change to llvm-flang as Chris Lattner mentioned. I don't think it's good to name it flang just yet.

@h-vetinari
Copy link
Member Author

OK, thanks!

Both those things (llvm_rc and flang-new) represent the state of this PR, so it sounds like we're good to merge?!

@h-vetinari
Copy link
Member Author

Gentle ping @isuruf - OK for you if we push the button here?

@isuruf
Copy link
Member

isuruf commented Sep 3, 2023

Yeah, sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants