This is an archive of the discontinued LLVM Phabricator instance.

[Flang] add flang as a new subproject in cmake
ClosedPublic

Authored by schweitz on Jan 8 2020, 2:29 PM.

Details

Summary

This patch is some minor prep work for merging the flang(f18) project into the monorepo. This patch adds "flang" as a supported target for the LLVM_ENABLE_PROJECTS option.

Diff Detail

Event Timeline

schweitz created this revision.Jan 8 2020, 2:29 PM
Herald added a project: Restricted Project. · View Herald Transcript

It helps if you use tags in the title of commits (and reviews), e.g., [Flang] .... Maybe we can make the commit message a bit more specific: "[Flang] Add Flang as subproject in cmake"

schweitz retitled this revision from Prep work for adding flang as a new project to the mono repo to [Flang] Prep work to add flang as a new subproject in cmake.Jan 9 2020, 10:50 AM

It helps if you use tags in the title of commits (and reviews), e.g., [Flang] .... Maybe we can make the commit message a bit more specific: "[Flang] Add Flang as subproject in cmake"

Sure. Done.

fhahn added a comment.Jan 9 2020, 10:55 AM

IIUC this is only needed after the flang merge, right? It will break things before the merge. The change is fine, after flang gets merged. IIUC this is not required as preparation for the merge, rather a follow up. Unless I am missing something, it would be good to clarify the title/commit message.

schweitz added a comment.EditedJan 9 2020, 11:49 AM

Hmm. Yes, it seems this isn't exactly the "prep" patch I wanted w.r.t llvm/CMakeLists.txt. We made the "all" change locally, but it does not appear to be required. Removed it.

We're not going to want f18 to be picked up by the buildbots, since it requires everything get built with C++ 17.

schweitz updated this revision to Diff 237146.Jan 9 2020, 11:56 AM
schweitz retitled this revision from [Flang] Prep work to add flang as a new subproject in cmake to [Flang] add flang as a new subproject in cmake.

Ideally, this ought to go in around the same time that the flang sources get merged into the monorepo. It's not necessary until that time.

My current plan is to add this as the first commit on top of the flang merge and push that all together. That way although there will be commits that don't build in the history (which is unavoidable) there won't actually be a time at which this causes build issues. Does that sound reasonable?

That sounds like a good plan to me, David. Thank you.

DavidTruby requested changes to this revision.EditedMar 9 2020, 6:35 AM

This doesn't seem to be sufficient to build Flang for me. My process was as follows:

git clone https://github.com/llvm/llvm-project
cd llvm-project
arc patch D72416
git clone https://github.com/pmccormick/f18 flang # The f18 branch with LLVM cmake infrastructure changes
mkdir build && cd build
cmake -GNinja -DLLVM_ENABLE_PROJECTS="mlir;flang" ../llvm
ninja

after which I get a correct build of llvm with no errors in the cmake step, but the flang binaries are not present.
My cursory reading of the cmake files suggests to me that we _do_ need flang in LLVM_ALL_PROJECTS, as it seems that LLVM_ENABLE_PROJECTS only affects things that are in LLVM_ALL_PROJECTS. If I add flang to LLVM_ALL_PROJECTS and run the above commands I get a correct in-tree build of flang.

The other option is to special case flang in the handling for LLVM_ENABLE_PRIOJECTS, but I think this is a less nice solution.

This revision now requires changes to proceed.Mar 9 2020, 6:35 AM

Hmm. Interesting. Thanks for testing it again. I can add it back to ALL. No problem. (Locally, I already have, which may explain why I don't see any problem.)

schweitz updated this revision to Diff 249124.Mar 9 2020, 9:09 AM

@hfinkel suggested we make an LLVM_EXTRA_PROJECTS and add that to the logic to search for projects. I have a patch to do that, I'll just link it here when I work out how to!

@hfinkel suggested we make an LLVM_EXTRA_PROJECTS and add that to the logic to search for projects. I have a patch to do that, I'll just link it here when I work out how to!

I agree with Hal. It makes sense to separate the "what's a valid project" logic from the "let's build everything" option.

DavidTruby added a comment.EditedMar 9 2020, 9:21 AM

https://reviews.llvm.org/differential/diff/249126/ this works for me
Although I just spotted I've left an OR ${proj} in there which shouldn't be there. If you ignore that then it works!

schweitz updated this revision to Diff 249692.Mar 11 2020, 11:16 AM
This revision is now accepted and ready to land.Apr 8 2020, 9:48 AM
This revision was automatically updated to reflect the committed changes.