This is an archive of the discontinued LLVM Phabricator instance.

[flang] Make flang build compatible with LLVM dylib
ClosedPublic

Authored by serge-sans-paille on Sep 18 2020, 2:14 AM.

Details

Summary

If flang links with LLVM_DYLIB, there's no need to link the support library again.

Diff Detail

Event Timeline

serge-sans-paille requested review of this revision.Sep 18 2020, 2:14 AM
jeanPerier accepted this revision.Sep 23 2020, 11:18 PM

Thanks for fixing this. I tested in my build environment. I could reproduce the failure without this fix at build time with LLVM_LINK_LLVM_DYLIB when Generating ../../include/flang/__fortran_builtins.mod. With this fix, I can still build OK without LLVM_LINK_LLVM_DYLIB. With LLVM_LINK_LLVM_DYLIB, flang now builds, but I see 14 flang regression tests are failing with error CommandLine Error: Option 'disable-symbolication' registered more than once!. I think it may be a test linking issue that is remaining, but at least LLVM_LINK_LLVM_DYLIB now works to build flang.

This revision is now accepted and ready to land.Sep 23 2020, 11:18 PM

Thanks. I'll try to fix this duplicate link issue before commiting this (incomplete) patch then :-)

Harmonize usage of LLVM components througout Flang.

Explicit LLVM Libs where used across several CMakeFIles, which led to incompatibilities with LLVM shlibs.
Fortunately, the LLVM component system can be relied on to harmoniously handle both cases.

serge-sans-paille requested review of this revision.Oct 9 2020, 9:42 AM

ping?

Thanks for this update, I just finished testing it. There is one issue with a really really slow test being run in regression (see inline comment). Apart from that, this patch built in my environment with/without LLVM_LINK_LLVM_DYLIB in/out of LLVM tree.

flang/unittests/Decimal/CMakeLists.txt
7

With this change, thorough-test is now run with make check-flang regression tests which we would like to avoid because it can take ~1hour to run. I think this is because lit just tries to run whatever executable are ending with ".test" in this folder. To fix that, add_flang_nongtest_unittest could avoid adding the ".test" extension to the executable in case SLOW_TEST is passed to it.

(Try to) fix slow tests. Thanks @jeanPerier for spotting that.

jeanPerier accepted this revision.Oct 14 2020, 4:41 AM

I can build and run tests as expected with and without LLVM_LINK_LLVM_DYLIB now. Thanks for making flang work with this build option !

This revision is now accepted and ready to land.Oct 14 2020, 4:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2020, 5:27 AM

@serge-sans-paille Thank you for working on this! Sadly the Flang buildbot is unhappy again:http://lab.llvm.org:8014/#/builders/109/builds/35. I'm guessing that you didn't test with -DFLANG_BUILD_NEW_DRIVER=ON?

IIUC, the add_flang_tool macro needs fixing/updating. I'll take a look and submit something. Perhaps I'll need to revert the changes in flang/tools/flang-driver/CMakeLists.txt. in the interim.

flang/tools/flang-driver/CMakeLists.txt
11

Sadly, add_flang_tool doesn't understand this syntax: http://lab.llvm.org:8014/#/builders/109/builds/35

@serge-sans-paille Thank you for working on this! Sadly the Flang buildbot is unhappy again:http://lab.llvm.org:8014/#/builders/109/builds/35. I'm guessing that you didn't test with -DFLANG_BUILD_NEW_DRIVER=ON?

IIUC, the add_flang_tool macro needs fixing/updating. I'll take a look and submit something. Perhaps I'll need to revert the changes in flang/tools/flang-driver/CMakeLists.txt. in the interim.

Should be fixed here: https://reviews.llvm.org/D89403

The CMake error for flang-new is now fixed, but I'm no longer able to build Flang with BUILD_SHARED_LIBS=On. @serge-sans-paille , have you tested that configuration? I'm struggling to find a fix.

I'll have a look and submit a patch