This is an archive of the discontinued LLVM Phabricator instance.

[fir] Fix FlangOptimizerTests link on Solaris
ClosedPublic

Authored by ro on Feb 10 2022, 6:57 AM.

Details

Summary

As reported in Issue #53690, tools/flang/unittests/Optimizer/FlangOptimizerTests FAILs to link on Solaris:

Undefined                       first referenced
 symbol                             in file
_ZN3fir7runtimeL8getModelIcEEPFN4mlir4TypeEPNS2_11MLIRContextEEv lib/libFIRBuilder.a(Reduction.cpp.o)

which is mlir::Type (*fir::runtime::getModel<char>())(mlir::MLIRContext*).

clang++ warn's

In file included from /var/llvm/llvm-14.0.0-rc1/rc1/llvm-project/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp:14:
/var/llvm/llvm-14.0.0-rc1/rc1/llvm-project/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h:60:34: warning: function 'fir::runtime::getModel<char>' has internal linkage but is not defined [-Wundefined-internal]
static constexpr TypeBuilderFunc getModel();
                                 ^
/var/llvm/llvm-14.0.0-rc1/rc1/llvm-project/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h:289:29: note: used here
      TypeBuilderFunc ret = getModel<RT>();
                            ^

Fixed by adding an explicit template instantiation for getModel<char>. I suppose this is necessary because on Solaris char is signed.

Tested on sparcv9-sun-solaris2.11.

Diff Detail

Event Timeline

ro created this revision.Feb 10 2022, 6:57 AM
ro requested review of this revision.Feb 10 2022, 6:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2022, 6:57 AM
This revision is now accepted and ready to land.Feb 10 2022, 7:01 AM
This revision was landed with ongoing or failed builds.Feb 10 2022, 7:10 AM
This revision was automatically updated to reflect the committed changes.