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/05/03 15:43:33 UTC

[GitHub] [tvm] tkonolige commented on a change in pull request #7917: allow libbacktrace to be used when cross compiling the runtime

tkonolige commented on a change in pull request #7917:
URL: https://github.com/apache/tvm/pull/7917#discussion_r625176936



##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -16,12 +16,28 @@
 # under the License.
 include(ExternalProject)
 
+
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND (CMAKE_C_COMPILER MATCHES "^/Library"
+  OR CMAKE_C_COMPILER MATCHES "^/Applications"))
+    set(c_compiler "/usr/bin/cc")
+  else()
+    set(c_compiler "${CMAKE_C_COMPILER}")
+endif()
+
 ExternalProject_Add(project_libbacktrace
   PREFIX libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"

Review comment:
       ```suggestion
                       "CC=${c_compiler}"
   ```
   You need this change to match the lines above.

##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -16,12 +16,28 @@
 # under the License.
 include(ExternalProject)
 
+
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND (CMAKE_C_COMPILER MATCHES "^/Library"
+  OR CMAKE_C_COMPILER MATCHES "^/Applications"))
+    set(c_compiler "/usr/bin/cc")
+  else()
+    set(c_compiler "${CMAKE_C_COMPILER}")
+endif()
+
 ExternalProject_Add(project_libbacktrace
   PREFIX libbacktrace
   SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace
   BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/libbacktrace
   CONFIGURE_COMMAND "${CMAKE_CURRENT_LIST_DIR}/../../3rdparty/libbacktrace/configure"
-                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace" --with-pic
+                    "--prefix=${CMAKE_CURRENT_BINARY_DIR}/libbacktrace"
+                    --with-pic
+                    "CC=${CMAKE_C_COMPILER}"
+                    "CFLAGS=${CMAKE_C_FLAGS}"
+                    "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}"
+                    "CPP=${CMAKE_C_COMPILER} -E"

Review comment:
       ```suggestion
                       "CPP=${c_compiler} -E"
   ```

##########
File path: cmake/libs/Libbacktrace.cmake
##########
@@ -16,12 +16,28 @@
 # under the License.
 include(ExternalProject)
 
+

Review comment:
       Could you add this comment:
   
   ```
   # On MacOS, the default C compiler (/usr/bin/cc) is actually a small script that dispatches to a
   # compiler the default SDK (usually /Library/Developer/CommandLineTools/usr/bin/ or
   # /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/). CMake
   # automatically detects what is being dispatched and uses it instead along with all the flags it
   # needs. CMake makes this second compiler avaliable through the CMAKE_C_COMPILER variable, but it
   # does not make the necessary flags available. This leads to configuration errors in libbacktrace
   # because it can't find system libraries. Our solution is to detect if CMAKE_C_COMPILER lives in
   # /Library or /Applications and switch to the default compiler instead.
   ```




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