[PATCH] D93496: [flang] Fix -intrinsic-module-directory in flang script

Tim Keith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 17 15:53:28 PST 2020


tskeith created this revision.
tskeith added reviewers: PeteSteinfeld, sscalpone.
tskeith added a project: Flang.
Herald added subscribers: jdoerfert, mgorny.
tskeith requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93496

Files:
  flang/tools/f18/CMakeLists.txt
  flang/tools/f18/flang
  flang/tools/f18/flang.sh.in


Index: flang/tools/f18/flang.sh.in
===================================================================
--- flang/tools/f18/flang.sh.in
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-#===-- tools/f18/flang.sh -----------------------------------------*- sh -*-===#
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#===------------------------------------------------------------------------===#
-
-function abspath() {
-  pushd . > /dev/null;
-  if [ -d "$1" ]; then
-    cd "$1";
-    dirs -l +0;
-  else
-    cd "`dirname \"$1\"`";
-    cur_dir=`dirs -l +0`;
-    if [ "$cur_dir" == "/" ]; then
-      echo "$cur_dir`basename \"$1\"`";
-    else
-      echo "$cur_dir/`basename \"$1\"`";
-    fi;
-  fi;
-  popd > /dev/null;
-}
-
-wd=`abspath $(dirname "$0")/..`
-
-${wd}/bin/f18 -module-suffix .f18.mod -intrinsic-module-directory ${wd}/include/flang $*
Index: flang/tools/f18/flang
===================================================================
--- /dev/null
+++ flang/tools/f18/flang
@@ -0,0 +1,15 @@
+#!/bin/bash
+#===-- tools/f18/flang.sh -----------------------------------------*- sh -*-===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+wd=$(cd $(dirname "$0")/.. && pwd)
+module_dir=$wd/include/flang
+if [[ ! -d $module_dir ]]; then
+  module_dir=$wd/tools/flang/include/flang
+fi
+$wd/bin/f18 -module-suffix .f18.mod -intrinsic-module-directory $module_dir "$@"
Index: flang/tools/f18/CMakeLists.txt
===================================================================
--- flang/tools/f18/CMakeLists.txt
+++ flang/tools/f18/CMakeLists.txt
@@ -65,28 +65,12 @@
 
 install(TARGETS f18 DESTINATION bin)
 
-set(FLANG_INTRINSIC_MODULES_DIR ${FLANG_BINARY_DIR}/include/flang)
-
 # This flang shell script will only work in a POSIX shell.
 if (NOT WIN32)
-  if (FLANG_STANDALONE_BUILD)
-    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.sh.in ${CMAKE_BINARY_DIR}/tools/flang/bin/flang @ONLY)
-    file(COPY ${CMAKE_BINARY_DIR}/tools/flang/bin/flang DESTINATION ${CMAKE_BINARY_DIR}/bin FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE)
-  else()
-    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.sh.in
-      ${CMAKE_CURRENT_BINARY_DIR}/tools/flang/bin/flang @ONLY)
-    add_custom_command(TARGET f18
-        POST_BUILD
-          COMMAND ${CMAKE_COMMAND} -E copy
-          ${CMAKE_CURRENT_BINARY_DIR}/tools/flang/bin/flang
-          ${LLVM_RUNTIME_OUTPUT_INTDIR}/flang
-            COMMAND chmod +x ${LLVM_RUNTIME_OUTPUT_INTDIR}/flang)
-  endif()
+  file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/flang
+    DESTINATION ${CMAKE_BINARY_DIR}/bin
+    FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE)
+  install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/flang DESTINATION bin)
 endif()
 
-# The flang script to be installed needs a different path to the headers.
-set(FLANG_INTRINSIC_MODULES_DIR ${CMAKE_INSTALL_PREFIX}/include/flang)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.sh.in ${FLANG_BINARY_DIR}/bin/flang-install.sh @ONLY)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/f18_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/f18_version.h @ONLY)
-
-install(PROGRAMS ${FLANG_BINARY_DIR}/bin/flang-install.sh DESTINATION bin RENAME flang)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93496.312631.patch
Type: text/x-patch
Size: 3550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201217/d3ce3a4b/attachment.bin>


More information about the llvm-commits mailing list