From 8cccda27bcc5102a042859786c5929785f3b22f3 Mon Sep 17 00:00:00 2001 From: Leandro Lupori Date: Tue, 31 Oct 2023 11:20:54 -0300 Subject: [PATCH] [flang] Fix flang tests on MacOS (#70811) Adjust some of the tests run by check-flang to make them pass on MacOS, either by skipping unsupported tests or by adapting the test for correct execution on MacOS. For now ctofortran.f90 test is marked as unsupported, but it can be adapted to run on MacOS once support for -isysroot flag is added to flang. Issues #70805 and #70807 are tracking the failing tests that remain, as these reveal real problems with flang. --- flang/test/Driver/ctofortran.f90 | 3 ++- flang/test/Driver/lto-flags.f90 | 12 +++++++----- flang/test/Driver/save-mlir-temps.f90 | 5 +++-- flang/test/Evaluate/fold-out_of_range.f90 | 2 +- flang/test/lit.cfg.py | 5 ++++- flang/test/lit.site.cfg.py.in | 1 + 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/flang/test/Driver/ctofortran.f90 b/flang/test/Driver/ctofortran.f90 index 6483e0deb3866..828e87e89db69 100644 --- a/flang/test/Driver/ctofortran.f90 +++ b/flang/test/Driver/ctofortran.f90 @@ -1,4 +1,5 @@ -! UNSUPPORTED: system-windows +! MacOS needs -isysroot with clang and flang to build binaries. +! UNSUPPORTED: system-windows, system-darwin ! RUN: split-file %s %t ! RUN: chmod +x %t/runtest.sh ! RUN: %t/runtest.sh %t %flang $t/ffile.f90 $t/cfile.c diff --git a/flang/test/Driver/lto-flags.f90 b/flang/test/Driver/lto-flags.f90 index da456b47ef435..2b3b08fbcc711 100644 --- a/flang/test/Driver/lto-flags.f90 +++ b/flang/test/Driver/lto-flags.f90 @@ -10,7 +10,9 @@ ! RUN: %flang -### -S -flto=jobserver %s 2>&1 | FileCheck %s --check-prefix=FULL-LTO ! Also check linker plugin opt for Thin LTO -! RUN: %flang -### -flto=thin %s 2>&1 | FileCheck %s --check-prefix=THIN-LTO +! RUN: %flang -### -flto=thin %s 2>&1 | FileCheck %s \ +! RUN: --check-prefixes=%if system-darwin %{THIN-LTO-ALL%} \ +! RUN: %else %{THIN-LTO-ALL,THIN-LTO-LINKER-PLUGIN%} ! RUN: not %flang -### -S -flto=somelto %s 2>&1 | FileCheck %s --check-prefix=ERROR @@ -25,9 +27,9 @@ ! FULL-LTO: "-fc1" ! FULL-LTO-SAME: "-flto=full" -! THIN-LTO: flang-new: warning: the option '-flto=thin' is a work in progress -! THIN-LTO: "-fc1" -! THIN-LTO-SAME: "-flto=thin" -! THIN-LTO: "-plugin-opt=thinlto" +! THIN-LTO-ALL: flang-new: warning: the option '-flto=thin' is a work in progress +! THIN-LTO-ALL: "-fc1" +! THIN-LTO-ALL-SAME: "-flto=thin" +! THIN-LTO-LINKER-PLUGIN: "-plugin-opt=thinlto" ! ERROR: error: unsupported argument 'somelto' to option '-flto= diff --git a/flang/test/Driver/save-mlir-temps.f90 b/flang/test/Driver/save-mlir-temps.f90 index 8985271e27282..50bc83030caa9 100644 --- a/flang/test/Driver/save-mlir-temps.f90 +++ b/flang/test/Driver/save-mlir-temps.f90 @@ -6,8 +6,9 @@ ! As `flang` does not implement `-fc1as` (i.e. a driver for the integrated ! assembler), we need to use `-fno-integrated-as` here. - -! UNSUPPORTED: system-windows +! However, calling an external assembler on arm64 Macs fails, because it's +! currently being invoked with the `-Q` flag, that is not supported on arm64. +! UNSUPPORTED: system-windows, system-darwin !-------------------------- ! Invalid output directory diff --git a/flang/test/Evaluate/fold-out_of_range.f90 b/flang/test/Evaluate/fold-out_of_range.f90 index fd1b1c286f2fb..de66c803b103e 100644 --- a/flang/test/Evaluate/fold-out_of_range.f90 +++ b/flang/test/Evaluate/fold-out_of_range.f90 @@ -1,5 +1,5 @@ ! RUN: %python %S/test_folding.py %s %flang_fc1 -! UNSUPPORTED: target=powerpc{{.*}}, target=aarch{{.*}}, system-windows, system-solaris +! UNSUPPORTED: target=powerpc{{.*}}, target=aarch{{.*}}, target=arm{{.*}}, system-windows, system-solaris ! Tests folding of OUT_OF_RANGE(). module m integer(1), parameter :: i1v(*) = [ -huge(1_1) - 1_1, huge(1_1) ] diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py index dda8ed456c986..ac504dc5d1fbd 100644 --- a/flang/test/lit.cfg.py +++ b/flang/test/lit.cfg.py @@ -163,7 +163,10 @@ and os.path.isdir(include) ): config.available_features.add("c-compiler") - tools.append(ToolSubst("%cc", command=config.cc, unresolved="fatal")) + cc_cmd = config.cc + if config.osx_sysroot: + cc_cmd += " -isysroot " + config.osx_sysroot + tools.append(ToolSubst("%cc", command=cc_cmd, unresolved="fatal")) tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal")) tools.append(ToolSubst("%libdecimal", command=libdecimal, unresolved="fatal")) tools.append(ToolSubst("%include", command=include, unresolved="fatal")) diff --git a/flang/test/lit.site.cfg.py.in b/flang/test/lit.site.cfg.py.in index 46ba53ef672ef..32099f43d3135 100644 --- a/flang/test/lit.site.cfg.py.in +++ b/flang/test/lit.site.cfg.py.in @@ -22,6 +22,7 @@ config.flang_standalone_build = @FLANG_STANDALONE_BUILD@ config.has_plugins = @LLVM_ENABLE_PLUGINS@ config.linked_bye_extension = @LLVM_BYE_LINK_INTO_TOOLS@ config.cc = "@CMAKE_C_COMPILER@" +config.osx_sysroot = path(r"@CMAKE_OSX_SYSROOT@") config.targets_to_build = "@TARGETS_TO_BUILD@" import lit.llvm