From c9d0e1374f0cf96c8e886355e14385f1fb1d9af5 Mon Sep 17 00:00:00 2001 From: zhushengtao Date: Fri, 7 Jul 2023 17:12:21 +0800 Subject: [PATCH] Add fix import use patch --- 22-fix-import-use.patch | 146 ++++++++++++++++++++++++++++++++++++++++ flang.spec | 6 +- 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 22-fix-import-use.patch diff --git a/22-fix-import-use.patch b/22-fix-import-use.patch new file mode 100644 index 0000000..4e2b0a7 --- /dev/null +++ b/22-fix-import-use.patch @@ -0,0 +1,146 @@ +commit 1756c26ed8a0a6ee46b0b0bcb3edc49f6578ddeb +Author: q00576763 +Date: Thu Jun 1 16:32:51 2023 +0800 + + [Huawei][Flang1] Fix the string operation of file name + + Offering: BiSheng + + This bug came from 0bcbadbf3f7f056b298a7724b9689ebacbdae4e9, which uses + strdup to allocate non-const versions of const string, but does not + change the use of the original string. The use of original string (file + name) terminates the string by removing the last directory. So, we need + to replace the use of original string with the allocated string. + +diff --git a/test/f90_correct/inc/import_mod_from_user.mk b/test/f90_correct/inc/import_mod_from_user.mk +new file mode 100644 +index 00000000..aff318dc +--- /dev/null ++++ b/test/f90_correct/inc/import_mod_from_user.mk +@@ -0,0 +1,30 @@ ++# ++# 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 ++# ++ ++$(TEST): run ++ ++build: $(SRC)/$(TEST).f90 ++ -$(RM) $(TEST).$(EXESUFFIX) core *.d *.mod FOR*.DAT FTN* ftn* fort.* ++ @echo ------------------------------------ building test $@ ++ -$(MKDIR) import_mod_from_user_dir1 ++ -$(CD) import_mod_from_user_dir1 ++ -$(CP) $(SRC)/import_mod_from_user_dir1_m2.f90 . ++ -$(FC) -c import_mod_from_user_dir1_m2.f90 ++ -$(CD) .. ++ -$(MKDIR) import_mod_from_user_dir2 ++ -$(CD) import_mod_from_user_dir2 ++ -$(CP) $(SRC)/import_mod_from_user_dir2* . ++ -$(FC) -c import_mod_from_user_dir2_m2.f90 ++ -$(FC) -c import_mod_from_user_dir2_m1.f90 ++ -$(CD) .. ++ -$(FC) -c -I./import_mod_from_user_dir1 -I./import_mod_from_user_dir2 $(SRC)/$(TEST).f90 -o $(TEST).$(OBJX) ++ -$(FC) $(FFLAGS) $(LDFLAGS) $(TEST).$(OBJX) $(LIBS) -o $(TEST).$(EXESUFFIX) ++ ++run: ++ @echo ------------------------------------ executing test $(TEST) ++ $(TEST).$(EXESUFFIX) ++ ++verify: ; +diff --git a/test/f90_correct/lit/import_mod_from_user.sh b/test/f90_correct/lit/import_mod_from_user.sh +new file mode 100644 +index 00000000..3880a96e +--- /dev/null ++++ b/test/f90_correct/lit/import_mod_from_user.sh +@@ -0,0 +1,9 @@ ++# ++# 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 ++ ++# Shared lit script for each tests. Run bash commands that run tests with make. ++ ++# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t ++# RUN: cat %t | FileCheck %S/runmake +diff --git a/test/f90_correct/makefile b/test/f90_correct/makefile +index 0fcd0e24..0116f806 100644 +--- a/test/f90_correct/makefile ++++ b/test/f90_correct/makefile +@@ -26,6 +26,8 @@ COMP_CHECK=python $(HOMEQA)/../tools/check_compilation.py + + RM=rm -f + CP=cp -f ++CD=cd ++MKDIR=mkdir + UNAME := $(shell uname -a) + + INCLUDES=$(BASE_DIR)/inc +diff --git a/test/f90_correct/src/import_mod_from_user.f90 b/test/f90_correct/src/import_mod_from_user.f90 +new file mode 100644 +index 00000000..1f94b156 +--- /dev/null ++++ b/test/f90_correct/src/import_mod_from_user.f90 +@@ -0,0 +1,16 @@ ++! ++! 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 ++! ++! Test for the import module from the correct path. ++ ++module import_mod_from_user ++contains ++ subroutine sub() ++ use import_source2 ++ end ++end ++ ++ print *, "PASS" ++end +diff --git a/test/f90_correct/src/import_mod_from_user_dir1_m2.f90 b/test/f90_correct/src/import_mod_from_user_dir1_m2.f90 +new file mode 100644 +index 00000000..0d8e44cd +--- /dev/null ++++ b/test/f90_correct/src/import_mod_from_user_dir1_m2.f90 +@@ -0,0 +1,12 @@ ++module import_source ++contains ++ subroutine sub1() ++ end ++ ++ subroutine sub3() ++ end ++ ++ function func() result(funit) ++ integer :: funit ++ end ++end +diff --git a/test/f90_correct/src/import_mod_from_user_dir2_m1.f90 b/test/f90_correct/src/import_mod_from_user_dir2_m1.f90 +new file mode 100644 +index 00000000..63854d67 +--- /dev/null ++++ b/test/f90_correct/src/import_mod_from_user_dir2_m1.f90 +@@ -0,0 +1,3 @@ ++module import_source2 ++ use import_source, only : func, sub1 ++end +diff --git a/test/f90_correct/src/import_mod_from_user_dir2_m2.f90 b/test/f90_correct/src/import_mod_from_user_dir2_m2.f90 +new file mode 100644 +index 00000000..0e9f00ee +--- /dev/null ++++ b/test/f90_correct/src/import_mod_from_user_dir2_m2.f90 +@@ -0,0 +1,13 @@ ++module import_source ++contains ++ subroutine sub1() ++ end ++ ++ subroutine sub2(m) ++ integer, intent(out) :: m ++ end ++ ++ function func() result(funit) ++ integer :: funit ++ end ++end diff --git a/flang.spec b/flang.spec index e8304d0..d8f08d3 100644 --- a/flang.spec +++ b/flang.spec @@ -2,7 +2,7 @@ Name: flang Version: flang_20210324 -Release: 25 +Release: 26 Summary: Fortran language compiler targeting LLVM License: Apache-2.0 @@ -32,6 +32,7 @@ Patch17: 18-add-test-cases-for-attribute-declarations-and-specifications-3.patch Patch18: 19-add-test-cases-for-types-3.patch Patch19: 20-add-align-prgma-for-derived-type.patch Patch20: 21-add-align-prgma-for-fix-shape-array-character-type.patch +Patch21: 22-fix-import-use.patch %description Flang depends on a fork of the LLVM project (https://github.com/flang-compiler/classic-flang-llvm-project). The fork made some changes to the upstream LLVM project to support Flang toolchain. Flang cannot build independently for now. @@ -53,6 +54,9 @@ TODO: support build Flang. %changelog +* Fri July 7 2023 zhushengtao1 - flang_20210324-26 +- Add patch for fix import use bug + * Fri May 19 2023 yinjiawei2023 - flang_20210324-25 - Add patch for add align prgma for fix shape array/character and add some relative test cases -- Gitee