Skip to content

Commit a5cdbef

Browse files
committed
Revert "[LLVM] Replace use of LLVM_RUNTIMES_TARGET with LLVM_DEFAULT_TARGET_TRIPLE (#136208)"
This reverts commit 2e145f1. Somehow causes some static assertions to fail?
1 parent 974a8cc commit a5cdbef

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed

flang-rt/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ endif()
223223

224224
# The GPU targets require a few mandatory arguments to make the standard CMake
225225
# check flags happy.
226-
if ("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgcn")
226+
if ("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn")
227227
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nogpulib")
228-
elseif ("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^nvptx")
228+
elseif ("${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx")
229229
set(CMAKE_REQUIRED_FLAGS
230230
"${CMAKE_REQUIRED_FLAGS} -flto -c -Wno-unused-command-line-argument")
231231
endif()

flang-rt/README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,11 @@ The `CMAKE_Fortran_COMPILER_WORKS` parameter must be set because otherwise CMake
107107
will test whether the Fortran compiler can compile and link programs which will
108108
obviously fail without a runtime library available yet.
109109

110-
Building Flang-RT for cross-compilation triple, the target triple can be
111-
selected using `LLVM_DEFAULT_TARGET_TRIPLE`. Of course, Flang-RT can be built
112-
multiple times with different build configurations, but have to be located
113-
manually when using with the Flang driver using the `-L` option.
110+
Building Flang-RT for cross-compilation triple, the target triple can
111+
be selected using `LLVM_DEFAULT_TARGET_TRIPLE` AND `LLVM_RUNTIMES_TARGET`.
112+
Of course, Flang-RT can be built multiple times with different build
113+
configurations, but have to be located manually when using with the Flang
114+
driver using the `-L` option.
114115

115116
After configuration, build, test, and install the runtime via
116117

flang-rt/cmake/modules/AddFlangRT.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ function (add_flangrt_library name)
234234
endif ()
235235

236236
# Add target specific options if necessary.
237-
if ("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgcn")
237+
if ("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn")
238238
target_compile_options(${tgtname} PRIVATE
239239
$<$<COMPILE_LANGUAGE:CXX>:-nogpulib -flto -fvisibility=hidden>
240240
)
241-
elseif ("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^nvptx")
241+
elseif ("${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx")
242242
target_compile_options(${tgtname} PRIVATE
243243
$<$<COMPILE_LANGUAGE:CXX>:-nogpulib -flto -fvisibility=hidden -Wno-unknown-cuda-version --cuda-feature=+ptx63>
244244
)

flang-rt/lib/runtime/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ else ()
172172
set(f128_sources "")
173173
endif ()
174174

175-
if ("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgcn|^nvptx")
175+
if ("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn|^nvptx")
176176
set(sources ${gpu_sources})
177177
else ()
178178
set(sources ${supported_sources} ${host_sources} ${f128_sources})

libc/cmake/modules/LLVMLibCArchitectures.cmake

+8-8
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,24 @@ set(LIBC_TARGET_ARCHITECTURE ${compiler_arch})
108108
set(LIBC_TARGET_OS ${compiler_sys})
109109
set(LIBC_CROSSBUILD FALSE)
110110

111-
# One should not set LLVM_DEFAULT_TARGET_TRIPLE and LIBC_TARGET_TRIPLE
112-
if(LLVM_DEFAULT_TARGET_TRIPLE AND LLVM_RUNTIMES_BUILD AND LIBC_TARGET_TRIPLE)
111+
# One should not set LLVM_RUNTIMES_TARGET and LIBC_TARGET_TRIPLE
112+
if(LLVM_RUNTIMES_TARGET AND LIBC_TARGET_TRIPLE)
113113
message(FATAL_ERROR
114-
"libc build: Specify only LLVM_DEFAULT_TARGET_TRIPLE if you are doing a "
114+
"libc build: Specify only LLVM_RUNTIMES_TARGET if you are doing a "
115115
"runtimes/bootstrap build. If you are doing a standalone build, "
116116
"specify only LIBC_TARGET_TRIPLE.")
117117
endif()
118118

119119
set(explicit_target_triple)
120-
if(LLVM_DEFAULT_TARGET_TRIPLE AND LLVM_RUNTIMES_BUILD)
121-
set(explicit_target_triple ${LLVM_DEFAULT_TARGET_TRIPLE})
120+
if(LLVM_RUNTIMES_TARGET)
121+
set(explicit_target_triple ${LLVM_RUNTIMES_TARGET})
122122
elseif(LIBC_TARGET_TRIPLE)
123123
set(explicit_target_triple ${LIBC_TARGET_TRIPLE})
124124
endif()
125125

126126
# The libc's target architecture and OS are set to match the compiler's default
127127
# target triple above. However, one can explicitly set LIBC_TARGET_TRIPLE or
128-
# LLVM_DEFAULT_TARGET_TRIPLE (for runtimes/bootstrap build). If one of them is set,
128+
# LLVM_RUNTIMES_TARGET (for runtimes/bootstrap build). If one of them is set,
129129
# then we will use that target triple to deduce libc's target OS and
130130
# architecture.
131131
if(explicit_target_triple)
@@ -200,14 +200,14 @@ endif()
200200

201201

202202
# If the compiler target triple is not the same as the triple specified by
203-
# LIBC_TARGET_TRIPLE or LLVM_DEFAULT_TARGET_TRIPLE, we will add a --target option
203+
# LIBC_TARGET_TRIPLE or LLVM_RUNTIMES_TARGET, we will add a --target option
204204
# if the compiler is clang. If the compiler is GCC we just error out as there
205205
# is no equivalent of an option like --target.
206206
if(explicit_target_triple AND
207207
(NOT (libc_compiler_triple STREQUAL explicit_target_triple)))
208208
set(LIBC_CROSSBUILD TRUE)
209209
if(CMAKE_COMPILER_IS_GNUCXX)
210-
message(WARNING
210+
message(FATAL_ERROR
211211
"GCC target triple (${libc_compiler_triple}) and the explicity "
212212
"specified target triple (${explicit_target_triple}) do not match.")
213213
else()

libc/docs/gpu/building.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ targeting a GPU architecture.
100100
$> TARGET_C_COMPILER=</path/to/clang>
101101
$> TARGET_CXX_COMPILER=</path/to/clang++>
102102
$> cmake ../runtimes \ # Point to the runtimes build
103-
-G Ninja \
104-
-DLLVM_ENABLE_RUNTIMES=libc \
105-
-DCMAKE_C_COMPILER=$TARGET_C_COMPILER \
106-
-DCMAKE_CXX_COMPILER=$TARGET_CXX_COMPILER \
107-
-DLLVM_LIBC_FULL_BUILD=ON \
108-
-DLLVM_DEFAULT_TARGET_TRIPLE=$TARGET_TRIPLE \
103+
-G Ninja \
104+
-DLLVM_ENABLE_RUNTIMES=libc \
105+
-DCMAKE_C_COMPILER=$TARGET_C_COMPILER \
106+
-DCMAKE_CXX_COMPILER=$TARGET_CXX_COMPILER \
107+
-DLLVM_LIBC_FULL_BUILD=ON \
108+
-DLLVM_RUNTIMES_TARGET=$TARGET_TRIPLE \
109109
-DCMAKE_BUILD_TYPE=Release
110110
$> ninja install
111111

0 commit comments

Comments
 (0)