This is an archive of the discontinued LLVM Phabricator instance.

Add Clang dependency for new Flang driver in out-of-tree builder.
ClosedPublic

Authored by stevanradakovic on Mar 17 2021, 8:54 AM.

Details

Summary

When building out-of-tree we need to use CLANG_DIR to find
installed Clang components.

Diff Detail

Event Timeline

stevanradakovic requested review of this revision.Mar 17 2021, 8:54 AM
rovka added a comment.Mar 18 2021, 2:18 AM

This seems fine to me, but maybe @awarzynski can also have a look, since he knows the details of the new driver build better :)

@stevanradakovic , are LLVM, MLIR and Clang _installed_ or just _built_? Basically, CLANG_DIRneeds to point to a directory that contains AddClang.cmake. AFAIK, that script is not copied into the build directory (but it will be installed in CMAKE_INSTALL_PREFIX). Could you double check?

@awarzynski you're right it's not there. I have a local builder and it failed for this exact reason: http://ex40-01.tcwglab.linaro.org:8019/#/builders/16/builds/112
so what is the default value for CMAKE_INSTALL_PREFIX? is that where clang_dir should point to?

@awarzynski you're right it's not there. I have a local builder and it failed for this exact reason: http://ex40-01.tcwglab.linaro.org:8019/#/builders/16/builds/112
so what is the default value for CMAKE_INSTALL_PREFIX? is that where clang_dir should point to?

Yes, but CMAKE_INSTALL_PREFIX will be empty unless the install target is run, e.g. ninja install (or make install). Alternatively, AddClang.cmake could be copied into the build dir (similarly to AddLLVM.cmake and AddClang.cmake). Either should work. Previous effort in this direction: https://reviews.llvm.org/D94533.

stevanradakovic added a comment.EditedMar 22 2021, 1:25 AM

@awarzynski Hm even after running ninja install it's still not found here. Even though in step 7 I can clearly see AddClang.cmake (line 2629). I thought the CLANG_DIR path was ambiguous but it's not.

rovka added a comment.Mar 22 2021, 4:13 AM

I think the issue might be here: https://github.com/llvm/llvm-project/blob/7515e81e8c58ca07ac5fede7149634c0dfacae8a/flang/CMakeLists.txt#L52
We seem to be using CLANG_DIR directly, but for LLVM_DIR and MLIR_DIR we build absolute paths if needed.
@awarzynski, does this sound correct to you?

I think the issue might be here: https://github.com/llvm/llvm-project/blob/7515e81e8c58ca07ac5fede7149634c0dfacae8a/flang/CMakeLists.txt#L52
We seem to be using CLANG_DIR directly, but for LLVM_DIR and MLIR_DIR we build absolute paths if needed.
@awarzynski, does this sound correct to you?

Thanks for looking into this! It sounds very plausible. Have you been able to test it?

I've also noticed that you're installing into the build dir (as opposed to some other, dedicated directory). I think that that should work fine (though I haven't checked), but it's possible that LLVM_DIR, MLIR_DIR and CLANG_DIR refer to build locations (which will work for LLVM and MLIR, but not for Clang). It's something that's worth double-checking.

@awarzynski no dice. The result is the same if I put the arbitrary install path http://ex40-01.tcwglab.linaro.org:8019/#/builders/16/builds/224

@awarzynski no dice. The result is the same if I put the arbitrary install path http://ex40-01.tcwglab.linaro.org:8019/#/builders/16/builds/224

Noted, thanks for checking! @rovka's suggestion implemented here: https://reviews.llvm.org/D99088.

Add install step for Clang.

Great work everyone. Thanks to @rovka's changes, the build is now properly running

Great work everyone. Thanks to @rovka's changes, the build is now properly running

Great to see this progressing!

So is the CMake change not required then? Since https://reviews.llvm.org/D99088 hasn't been merged yet, and this already works.

No no, I hacked it manually to include that change. It is certainly still necessary.

awarzynski accepted this revision.Mar 23 2021, 7:29 AM

No no, I hacked it manually to include that change. It is certainly still necessary.

Ah, makes sense :) Thanks for confirming. Great effort, really pleased to see this one working!

LGTM

PS Please could you double-check the latest version of https://reviews.llvm.org/D99088, it should be OK!

This revision is now accepted and ready to land.Mar 23 2021, 7:29 AM