[llvm-branch-commits] [flang] 3001b0d - [fir] Fix FlangOptimizerTests link on Solaris

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Mar 1 14:24:28 PST 2022


Author: Rainer Orth
Date: 2022-03-01T14:22:00-08:00
New Revision: 3001b0d519630e2f1f0e2c4710379b3dbb43b715

URL: https://github.com/llvm/llvm-project/commit/3001b0d519630e2f1f0e2c4710379b3dbb43b715
DIFF: https://github.com/llvm/llvm-project/commit/3001b0d519630e2f1f0e2c4710379b3dbb43b715.diff

LOG: [fir] Fix FlangOptimizerTests link on Solaris

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`.

Differential Revision: https://reviews.llvm.org/D119438

(cherry picked from commit c2b9e9674d5259c12a055055f4e06eba5b8d0fa6)

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index 072e3f26a49b..8fea99e00873 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -100,6 +100,12 @@ constexpr TypeBuilderFunc getModel<const char32_t *>() {
   };
 }
 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));


        


More information about the llvm-branch-commits mailing list