Skip to content

Commit f6b577e

Browse files
committed
[flang] Fix -intrinsic-module-directory in flang script
The flang wrapper script that was created as bin/flang in an in-tree build did not have a correct -intrinsic-module-directory option. It was correct for out-of-tree builds and for both kinds of installs. The fix is to pick the correct directory based on what exists. The script is no longer configured by cmake (just copied) so that mechanism can be deleted from the cmake file. Differential Revision: https://reviews.llvm.org/D93496
1 parent 3733463 commit f6b577e

File tree

3 files changed

+19
-49
lines changed

3 files changed

+19
-49
lines changed

flang/tools/f18/CMakeLists.txt

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,12 @@ add_custom_target(module_files ALL DEPENDS ${MODULE_FILES})
6565

6666
install(TARGETS f18 DESTINATION bin)
6767

68-
set(FLANG_INTRINSIC_MODULES_DIR ${FLANG_BINARY_DIR}/include/flang)
69-
7068
# This flang shell script will only work in a POSIX shell.
7169
if (NOT WIN32)
72-
if (FLANG_STANDALONE_BUILD)
73-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.sh.in ${CMAKE_BINARY_DIR}/tools/flang/bin/flang @ONLY)
74-
file(COPY ${CMAKE_BINARY_DIR}/tools/flang/bin/flang DESTINATION ${CMAKE_BINARY_DIR}/bin FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE)
75-
else()
76-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.sh.in
77-
${CMAKE_CURRENT_BINARY_DIR}/tools/flang/bin/flang @ONLY)
78-
add_custom_command(TARGET f18
79-
POST_BUILD
80-
COMMAND ${CMAKE_COMMAND} -E copy
81-
${CMAKE_CURRENT_BINARY_DIR}/tools/flang/bin/flang
82-
${LLVM_RUNTIME_OUTPUT_INTDIR}/flang
83-
COMMAND chmod +x ${LLVM_RUNTIME_OUTPUT_INTDIR}/flang)
84-
endif()
70+
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/flang
71+
DESTINATION ${CMAKE_BINARY_DIR}/bin
72+
FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE)
73+
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/flang DESTINATION bin)
8574
endif()
8675

87-
# The flang script to be installed needs a different path to the headers.
88-
set(FLANG_INTRINSIC_MODULES_DIR ${CMAKE_INSTALL_PREFIX}/include/flang)
89-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.sh.in ${FLANG_BINARY_DIR}/bin/flang-install.sh @ONLY)
9076
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/f18_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/f18_version.h @ONLY)
91-
92-
install(PROGRAMS ${FLANG_BINARY_DIR}/bin/flang-install.sh DESTINATION bin RENAME flang)

flang/tools/f18/flang

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
#===-- tools/f18/flang.sh -----------------------------------------*- sh -*-===#
3+
#
4+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
# See https://llvm.org/LICENSE.txt for license information.
6+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
#
8+
#===------------------------------------------------------------------------===#
9+
10+
wd=$(cd $(dirname "$0")/.. && pwd)
11+
module_dir=$wd/include/flang
12+
if [[ ! -d $module_dir ]]; then
13+
module_dir=$wd/tools/flang/include/flang
14+
fi
15+
$wd/bin/f18 -module-suffix .f18.mod -intrinsic-module-directory $module_dir "$@"

flang/tools/f18/flang.sh.in

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)