[flang-commits] [flang] [Flang][runtime] Set -target to ignore LLVM_DEFAULT_TARGET_TRIPLE (PR #102916)

Jonathon Penix via flang-commits flang-commits at lists.llvm.org
Mon Aug 12 16:41:49 PDT 2024


================
@@ -84,7 +84,10 @@ if (NOT CMAKE_CROSSCOMPILING)
     set(include_in_link FALSE)
     if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION)
       set(object_output "${CMAKE_CURRENT_BINARY_DIR}/${filename}${CMAKE_CXX_OUTPUT_EXTENSION}")
-      set(compile_with -c -o ${object_output})
+      # flang-new defaults to LLVM_DEFAULT_TARGET_TRIPLE as target, but
+      # currently we can build the runtime for the same target as the host
+      # compiler.
+      set(compile_with -target ${LLVM_TARGET_TRIPLE} -c -o ${object_output})
----------------
jonathonpenix wrote:

I'm not sure if we can use `LLVM_TARGET_TRIPLE` as-is here. IIUC, `LLVM_TARGET_TRIPLE` is set to (or will be overwritten with) `LLVM_DEFAULT_TARGET_TRIPLE` in `llvm/CMakeLists.txt` [here](https://github.com/llvm/llvm-project/blob/b1edac0496f47374c9780f3f83c6773eed73a66e/llvm/CMakeLists.txt#L963-L964), so I think we end up with similar issues even if we specify `LLVM_TARGET_TRIPLE` on the command line.

To use the host target, would `LLVM_HOST_TRIPLE` work instead (which I think is set [here](https://github.com/llvm/llvm-project/blob/b1edac0496f47374c9780f3f83c6773eed73a66e/llvm/cmake/config-ix.cmake#L451-L458))? 

https://github.com/llvm/llvm-project/pull/102916


More information about the flang-commits mailing list