[PATCH] D126736: TensorFlowCompile: Add object file to list of sources rather than LINK_LIBS

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 31 17:20:12 PDT 2022


MatzeB created this revision.
MatzeB added a reviewer: mtrofin.
Herald added subscribers: modimo, wenlei, mgorny, mcrosier.
Herald added a project: All.
MatzeB requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Put object file with precompiled model into list of source files instead of `LINK_LIBS`.

Without this I would randomly get compilation failures which I believe stem from a bad ordering of `RegallocEvictModel.o` and `libtf_xla_runtime.a`:

  /usr/bin/clang++ ... lib/libtf_xla_runtime.a  lib/CodeGen/RegallocEvictModel.o ...
  ...
  lib/CodeGen/RegallocEvictModel.o:__compute_module:function _xla_home_matthiasb_dev_llvm_tfbuild_lib_CodeGen_RegallocEvictModel_llvm_RegallocEvictModel: error: undefined reference to '__xla_cpu_runtime_EigenSingleThreadedMatMulF32'

specifying the object file in the source file list ensures that it will come before any static libraries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126736

Files:
  llvm/cmake/modules/TensorFlowCompile.cmake


Index: llvm/cmake/modules/TensorFlowCompile.cmake
===================================================================
--- llvm/cmake/modules/TensorFlowCompile.cmake
+++ llvm/cmake/modules/TensorFlowCompile.cmake
@@ -110,8 +110,8 @@
     tf_compile(${LLVM_ML_MODELS_ABSOLUTE} ${tag_set} ${signature_def_key} ${fname} ${cpp_class} ${hdr_file} ${obj_file})
   endif()
 
-  set(GeneratedMLSources ${GeneratedMLSources} ${GENERATED_HEADERS} PARENT_SCOPE)
+  set(GeneratedMLSources ${GeneratedMLSources} ${GENERATED_OBJS} ${GENERATED_HEADERS} PARENT_SCOPE)
   set(MLDeps ${MLDeps} tf_xla_runtime PARENT_SCOPE)
-  set(MLLinkDeps ${MLLinkDeps} tf_xla_runtime ${GENERATED_OBJS} PARENT_SCOPE)
+  set(MLLinkDeps ${MLLinkDeps} tf_xla_runtime PARENT_SCOPE)
   add_definitions(-DLLVM_HAVE_TF_AOT_${fname_allcaps})
 endfunction()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126736.433239.patch
Type: text/x-patch
Size: 815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220601/e7641e34/attachment.bin>


More information about the llvm-commits mailing list