[PATCH] D119438: [fir] Fix FlangOptimizerTests link on Solaris

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 10 06:57:36 PST 2022


ro created this revision.
ro added reviewers: clementval, jeanPerier, mleair.
ro added a project: Flang.
Herald added subscribers: Chia-hungDuan, rriddle, jdoerfert, fedor.sergeev, jyknight.
ro requested review of this revision.
Herald added a subscriber: stephenneuendorffer.
Herald added a project: LLVM.

As reported in Issue #53690, `tools/flang/unittests/Optimizer/FlangOptimizerTests` `FAIL`s 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`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119438

Files:
  flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h


Index: flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
===================================================================
--- flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -100,6 +100,12 @@
   };
 }
 template <>
+constexpr TypeBuilderFunc getModel<char>() {
+  return [](mlir::MLIRContext *context) -> mlir::Type {
+    return mlir::IntegerType::get(context, 8 * sizeof(char));
+  };
+}
+template <>
 constexpr TypeBuilderFunc getModel<signed char>() {
   return [](mlir::MLIRContext *context) -> mlir::Type {
     return mlir::IntegerType::get(context, 8 * sizeof(signed char));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119438.407521.patch
Type: text/x-patch
Size: 668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220210/c646c01b/attachment.bin>


More information about the llvm-commits mailing list