This is an archive of the discontinued LLVM Phabricator instance.

[Flang][CMake] Add explicit libFortranCommon dependency for f18 etc.
ClosedPublic

Authored by ro on Apr 23 2020, 2:47 PM.

Details

Summary

When I tried Solaris builds with -DBUILD_SHARED_LIBS=ON, some commands failed
to link:

[ 94%] Linking CXX executable ../../../../bin/f18
Undefined                       first referenced
 symbol                             in file
Fortran::common::IntrinsicTypeDefaultKinds::set_sizeIntegerKind(int) CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
Fortran::common::IntrinsicTypeDefaultKinds::set_subscriptIntegerKind(int) CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
Fortran::common::EnumIndexToString[abi:cxx11](int, char const*) CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
Fortran::common::IntrinsicTypeDefaultKinds::set_defaultIntegerKind(int) CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
Fortran::common::IntrinsicTypeDefaultKinds::IntrinsicTypeDefaultKinds() CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
Fortran::common::IntrinsicTypeDefaultKinds::set_defaultRealKind(int) CMakeFiles/f18.dir/f18.cpp.o  (symbol belongs to implicit dependency /var/llvm/local-amd64-release-shared-gcc8-make/lib/libFortranCommon.so.11git)
ld: fatal: symbol referencing errors

This patch fixes this by adding explicit dependencies on libFortranCommon to the
affected commands.

Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11, and
x86-64-pc-linux-gnu. Ok for master?

Diff Detail

Event Timeline

ro created this revision.Apr 23 2020, 2:47 PM
Herald added a project: Restricted Project. · View Herald Transcript
DavidTruby accepted this revision.Apr 24 2020, 7:49 AM

I think we should make the libraries have transitive dependencies so that you can choose to link only against the one that you think you're using. For example, linking against any of the other libraries should link against FortranCommon anyway I believe?
This should be doable with CMake's target properties, perhaps the add_flang_library should do this.

The change itself looks fine though, if it fixes builds for you I think you can merge it while we look at doing what I suggest above.

This revision is now accepted and ready to land.Apr 24 2020, 7:49 AM

@ro are you able to commit this or do you need someone to do it for you?

ro added a comment.Apr 28 2020, 2:08 AM

I am. However, I'm usually using hg with the hg-git extension and had trouble comitting this particular patch (connection closed by git server).

This revision was automatically updated to reflect the committed changes.