Skip to content

Commit

Permalink
[Driver] Fix test failures when in classic Flang mode
Browse files Browse the repository at this point in the history
Add a new lit feature tag "classic_flang" to select which tests can or cannot
be run when the driver is built for classic Flang.
  • Loading branch information
bryanpkc committed Aug 18, 2020
1 parent ec64f28 commit 3cbed02
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 1 deletion.
3 changes: 3 additions & 0 deletions clang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ add_definitions( -D_GNU_SOURCE )

option(LLVM_ENABLE_CLASSIC_FLANG "Build support for classic Flang instead of the new built-in Flang" OFF)
if(LLVM_ENABLE_CLASSIC_FLANG)
set(LLVM_ENABLE_CLASSIC_FLANG 1)
add_definitions( -DUSE_CLASSIC_FLANG )
else()
set(LLVM_ENABLE_CLASSIC_FLANG 0)
endif()

option(FLANG_LLVM_EXTENSIONS "enable the Flang LLVM extensions" OFF)
Expand Down
1 change: 1 addition & 0 deletions clang/test/Driver/autocomplete.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
// FVECLIBALL: Accelerate
// FVECLIBALL-NEXT: MASSV
// FVECLIBALL-NEXT: none
// FVECLIBALL-NEXT: PGMATH
// FVECLIBALL-NEXT: SVML
// RUN: %clang --autocomplete=-fshow-overloads= | FileCheck %s -check-prefix=FSOVERALL
// FSOVERALL: all
Expand Down
28 changes: 28 additions & 0 deletions clang/test/Driver/flang/classic_flang.f95
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
! Check that the driver can invoke flang1 and flang2 to compile Fortran with
! --driver-mode=flang (default when the file extension is .f95).

! REQUIRES: classic_flang

! RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -c %s -### 2>&1 \
! RUN: | FileCheck --check-prefix=CHECK-OBJECT %s
! CHECK-OBJECT: flang1
! CHECK-OBJECT: flang2
! CHECK-OBJECT-SAME: "-asm" [[LLFILE:.*.ll]]
! CHECK-OBJECT-NOT: cc1as
! CHECK-OBJECT: clang
! CHECK-OBJECT-SAME: -cc1
! CHECK-OBJECT-SAME: "-o" "classic_flang.o"
! CHECK-OBJECT-SAME: "-x" "ir"
! CHECK-OBJECT-SAME: [[LLFILE]]

! RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -S %s -### 2>&1 \
! RUN: | FileCheck --check-prefix=CHECK-ASM %s
! CHECK-ASM: flang1
! CHECK-ASM: flang2
! CHECK-ASM-SAME: "-asm" [[LLFILE:.*.ll]]
! CHECK-ASM-NOT: cc1as
! CHECK-ASM: clang
! CHECK-ASM-SAME: -cc1
! CHECK-ASM-SAME: "-o" "classic_flang.s"
! CHECK-ASM-SAME: "-x" "ir"
! CHECK-ASM-SAME: [[LLFILE]]
2 changes: 2 additions & 0 deletions clang/test/Driver/flang/flang.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
! Check that flang -fc1 is invoked when in --driver-mode=flang.

! UNSUPPORTED: classic_flang

! This is a copy of flang_ucase.F90 because the driver has logic in it which
! differentiates between F90 and f90 files. Flang will not treat these files
! differently.
Expand Down
2 changes: 2 additions & 0 deletions clang/test/Driver/flang/flang_ucase.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
! Check that flang -fc1 is invoked when in --driver-mode=flang.

! UNSUPPORTED: classic_flang

! This is a copy of flang.f90 because the driver has logic in it which
! differentiates between F90 and f90 files. Flang will not treat these files
! differently.
Expand Down
2 changes: 2 additions & 0 deletions clang/test/Driver/flang/multiple-inputs-mixed.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
! Check that flang can handle mixed C and fortran inputs.

! UNSUPPORTED: classic_flang

! RUN: %clang --driver-mode=flang -### -fsyntax-only %S/Inputs/one.f90 %S/Inputs/other.c 2>&1 | FileCheck --check-prefixes=CHECK-SYNTAX-ONLY %s
! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang{{[^"/]*}}" "-fc1"
! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/one.f90"
Expand Down
2 changes: 2 additions & 0 deletions clang/test/Driver/flang/multiple-inputs.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
! Check that flang driver can handle multiple inputs at once.

! UNSUPPORTED: classic_flang

! RUN: %clang --driver-mode=flang -### -fsyntax-only %S/Inputs/one.f90 %S/Inputs/two.f90 2>&1 | FileCheck --check-prefixes=CHECK-SYNTAX-ONLY %s
! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang" "-fc1"
! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/one.f90"
Expand Down
2 changes: 2 additions & 0 deletions clang/test/Driver/fortran.f95
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
! Check that the clang driver can invoke gcc to compile Fortran when in
! --driver-mode=clang. This is legacy behaviour - see also --driver-mode=flang.

! UNSUPPORTED: classic_flang

! RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -c %s -### 2>&1 \
! RUN: | FileCheck --check-prefix=CHECK-OBJECT %s
! CHECK-OBJECT: gcc
Expand Down
4 changes: 3 additions & 1 deletion clang/test/Driver/gfortran.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
! Test that Clang can forward all of the flags which are documented as
! being supported by gfortran to GCC when falling back to GCC for
! a fortran input file.
!

! UNSUPPORTED: classic_flang

! RUN: %clang -no-canonical-prefixes -target i386-linux -### %s -o %t 2>&1 \
! RUN: -Aquestion=answer \
! RUN: -A-question=answer \
Expand Down
3 changes: 3 additions & 0 deletions clang/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,6 @@ def calculate_arch_features(arch_string):

if config.enable_shared:
config.available_features.add("enable_shared")

if config.use_classic_flang:
config.available_features.add("classic_flang")
1 change: 1 addition & 0 deletions clang/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ config.host_arch = "@HOST_ARCH@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
config.has_plugins = @LLVM_ENABLE_PLUGINS@
config.use_classic_flang = @LLVM_ENABLE_CLASSIC_FLANG@

# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.
Expand Down

0 comments on commit 3cbed02

Please sign in to comment.