Skip to content

Commit 8cccda2

Browse files
committed
[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.
1 parent bdc0afc commit 8cccda2

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

flang/test/Driver/ctofortran.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
! UNSUPPORTED: system-windows
1+
! MacOS needs -isysroot <osx_sysroot> with clang and flang to build binaries.
2+
! UNSUPPORTED: system-windows, system-darwin
23
! RUN: split-file %s %t
34
! RUN: chmod +x %t/runtest.sh
45
! RUN: %t/runtest.sh %t %flang $t/ffile.f90 $t/cfile.c

flang/test/Driver/lto-flags.f90

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
! RUN: %flang -### -S -flto=jobserver %s 2>&1 | FileCheck %s --check-prefix=FULL-LTO
1111

1212
! Also check linker plugin opt for Thin LTO
13-
! RUN: %flang -### -flto=thin %s 2>&1 | FileCheck %s --check-prefix=THIN-LTO
13+
! RUN: %flang -### -flto=thin %s 2>&1 | FileCheck %s \
14+
! RUN: --check-prefixes=%if system-darwin %{THIN-LTO-ALL%} \
15+
! RUN: %else %{THIN-LTO-ALL,THIN-LTO-LINKER-PLUGIN%}
1416

1517
! RUN: not %flang -### -S -flto=somelto %s 2>&1 | FileCheck %s --check-prefix=ERROR
1618

@@ -25,9 +27,9 @@
2527
! FULL-LTO: "-fc1"
2628
! FULL-LTO-SAME: "-flto=full"
2729

28-
! THIN-LTO: flang-new: warning: the option '-flto=thin' is a work in progress
29-
! THIN-LTO: "-fc1"
30-
! THIN-LTO-SAME: "-flto=thin"
31-
! THIN-LTO: "-plugin-opt=thinlto"
30+
! THIN-LTO-ALL: flang-new: warning: the option '-flto=thin' is a work in progress
31+
! THIN-LTO-ALL: "-fc1"
32+
! THIN-LTO-ALL-SAME: "-flto=thin"
33+
! THIN-LTO-LINKER-PLUGIN: "-plugin-opt=thinlto"
3234

3335
! ERROR: error: unsupported argument 'somelto' to option '-flto=

flang/test/Driver/save-mlir-temps.f90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
! As `flang` does not implement `-fc1as` (i.e. a driver for the integrated
88
! assembler), we need to use `-fno-integrated-as` here.
9-
10-
! UNSUPPORTED: system-windows
9+
! However, calling an external assembler on arm64 Macs fails, because it's
10+
! currently being invoked with the `-Q` flag, that is not supported on arm64.
11+
! UNSUPPORTED: system-windows, system-darwin
1112

1213
!--------------------------
1314
! Invalid output directory

flang/test/Evaluate/fold-out_of_range.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
! RUN: %python %S/test_folding.py %s %flang_fc1
2-
! UNSUPPORTED: target=powerpc{{.*}}, target=aarch{{.*}}, system-windows, system-solaris
2+
! UNSUPPORTED: target=powerpc{{.*}}, target=aarch{{.*}}, target=arm{{.*}}, system-windows, system-solaris
33
! Tests folding of OUT_OF_RANGE().
44
module m
55
integer(1), parameter :: i1v(*) = [ -huge(1_1) - 1_1, huge(1_1) ]

flang/test/lit.cfg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@
163163
and os.path.isdir(include)
164164
):
165165
config.available_features.add("c-compiler")
166-
tools.append(ToolSubst("%cc", command=config.cc, unresolved="fatal"))
166+
cc_cmd = config.cc
167+
if config.osx_sysroot:
168+
cc_cmd += " -isysroot " + config.osx_sysroot
169+
tools.append(ToolSubst("%cc", command=cc_cmd, unresolved="fatal"))
167170
tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
168171
tools.append(ToolSubst("%libdecimal", command=libdecimal, unresolved="fatal"))
169172
tools.append(ToolSubst("%include", command=include, unresolved="fatal"))

flang/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ config.flang_standalone_build = @FLANG_STANDALONE_BUILD@
2222
config.has_plugins = @LLVM_ENABLE_PLUGINS@
2323
config.linked_bye_extension = @LLVM_BYE_LINK_INTO_TOOLS@
2424
config.cc = "@CMAKE_C_COMPILER@"
25+
config.osx_sysroot = path(r"@CMAKE_OSX_SYSROOT@")
2526
config.targets_to_build = "@TARGETS_TO_BUILD@"
2627

2728
import lit.llvm

0 commit comments

Comments
 (0)