You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/02/09 20:32:45 UTC

[GitHub] [tvm] rkimball commented on a change in pull request #7153: [RUNTIME] Add libbacktrace for backtraces with line numbers

rkimball commented on a change in pull request #7153:
URL: https://github.com/apache/tvm/pull/7153#discussion_r573215686



##########
File path: CMakeLists.txt
##########
@@ -379,6 +386,26 @@ set_property(TARGET tvm APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}")
 add_library(tvm_runtime SHARED $<TARGET_OBJECTS:tvm_runtime_objs>)
 set_property(TARGET tvm_runtime APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}")
 
+target_compile_definitions(tvm_objs PUBLIC DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
+target_compile_definitions(tvm_runtime_objs PUBLIC DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
+target_compile_definitions(tvm PUBLIC DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
+target_compile_definitions(tvm_runtime PUBLIC DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)

Review comment:
       You should be able to define these on the external project for libbacktrace and then when you target_link_libraries to it you will get all of the PUBLIC compile definitions and include directories.

##########
File path: cmake/modules/Libbacktrace.cmake
##########
@@ -0,0 +1,54 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+include(ExternalProject)
+
+# Git tag for libbacktrace
+set(TAG dedbe13fda00253fe5d4f2fb812c909729ed5937)
+
+ExternalProject_Add(project_libbacktrace
+  PREFIX libbacktrace
+  GIT_REPOSITORY https://github.com/ianlancetaylor/libbacktrace.git
+  GIT_TAG "${TAG}"
+  CONFIGURE_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/src/project_libbacktrace/configure"
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+  INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+  BUILD_COMMAND make
+  INSTALL_COMMAND make install
+  BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/lib/libbacktrace.a"
+                   "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include/backtrace.h"
+  # disable the builtin update because it rebuilds on every build
+  UPDATE_COMMAND ""
+  )
+
+# Only rebuild libbacktrace if this file changes
+# libbacktrace has a bug on macOS with shared libraries, so we patch it here
+ExternalProject_Add_Step(project_libbacktrace checkout

Review comment:
       ExternalProject has a PATCH command which can apply a patch file. I have used it often when using external code.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org