[flang-commits] [flang] [Flang][runtime] Set -target to ignore LLVM_DEFAULT_TARGET_TRIPLE (PR #102916)
Michael Kruse via flang-commits
flang-commits at lists.llvm.org
Mon Aug 12 08:28:26 PDT 2024
https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/102916
Currently the runtime is always built with the host compiler, to the same target as the host compiler compiles to, but Flang will be built compiling to `LLVM_DEFAULT_TARGET_TRIPLE`. To still build Fortran modules for the host, we must ignore `LLVM_DEFAULT_TARGET_TRIPLE` and explicitly pass the `-target` instead.
If the host compiler is also already a cross-compiler, then executing `flang-new` itself will already fail miserably unless the platform is setup with multilib support.
>From 3920e3111fdc6f83e97a48bd9dcfb7d1a52faf65 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 12 Aug 2024 17:16:35 +0200
Subject: [PATCH] [Flang][runtime] Set -target to ignore
LLVM_DEFAULT_TARGET_TRIPLE
---
flang/tools/f18/CMakeLists.txt | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index cec4e2d8107206..f94e7211c1ca85 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -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})
set(include_in_link TRUE)
endif()
More information about the flang-commits
mailing list