-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[flang][Driver] Don't require -fno-integrated-as when using -save-temps #119624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Currently, --save-temps requires -fno-integrated-as since flang does not have `fc1as` i.e. a driver for an integrated assembler. This simply checks if the driver is in flang-mode and forces useIntegratedAs() to return true if -save-temps was found on the command line. This will also allow us to enable some tests in the gfortran test suite within the LLVM test suite. Fixes llvm#58587
@llvm/pr-subscribers-clang Author: Tarun Prabhu (tarunprabhu) ChangesCurrently, --save-temps requires -fno-integrated-as since flang does not have This will also allow us to enable some tests in the gfortran test suite within the LLVM test suite. Fixes #58587 Full diff: https://github.com/llvm/llvm-project/pull/119624.diff 4 Files Affected:
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 9f174fbda398b5..39b8dda7871096 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -155,9 +155,16 @@ llvm::vfs::FileSystem &ToolChain::getVFS() const {
}
bool ToolChain::useIntegratedAs() const {
- return Args.hasFlag(options::OPT_fintegrated_as,
- options::OPT_fno_integrated_as,
- IsIntegratedAssemblerDefault());
+ // When -save-temps is enabled in flang, it will attempt to use -cc1as which
+ // will not work. For now, we would like -save-temps to imply
+ // -fno-integrated-as. Eventually, we may want to consider having -fc1as - the
+ // flang analog of clang's cc1as.
+ if (D.IsFlangMode() && Args.hasArg(options::OPT_save_temps_EQ))
+ return false;
+ else
+ return Args.hasFlag(options::OPT_fintegrated_as,
+ options::OPT_fno_integrated_as,
+ IsIntegratedAssemblerDefault());
}
bool ToolChain::useIntegratedBackend() const {
diff --git a/flang/test/Driver/save-mlir-temps.f90 b/flang/test/Driver/save-mlir-temps.f90
index e9478a6c521b2e..70cd32a25f349d 100644
--- a/flang/test/Driver/save-mlir-temps.f90
+++ b/flang/test/Driver/save-mlir-temps.f90
@@ -4,8 +4,8 @@
! the driver does not generate specific passes for MLIR. Instead, they are
! generated during code generation as additional outputs.
-! As `flang` does not implement `-fc1as` (i.e. a driver for the integrated
-! assembler), we need to use `-fno-integrated-as` here.
+! `flang` does not implement `-fc1as` (i.e. a driver for the integrated
+! assembler).
! 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
@@ -20,13 +20,13 @@
! Save to cwd
!--------------------------
! RUN: rm -rf %t && mkdir -p %t
-! RUN: pushd %t && %flang -c -fno-integrated-as -save-temps=cwd -o out.o %s 2>&1
+! RUN: pushd %t && %flang -c -save-temps=cwd -o out.o %s 2>&1
! RUN: FileCheck %s -input-file=save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
! RUN: popd
! RUN: rm -rf %t && mkdir -p %t
-! RUN: pushd %t && %flang -c -fno-integrated-as -save-temps -o out.o %s 2>&1
+! RUN: pushd %t && %flang -c -save-temps -o out.o %s 2>&1
! RUN: FileCheck %s -input-file=save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
! RUN: popd
@@ -35,7 +35,7 @@
! Save to output directory
!--------------------------
! RUN: rm -rf %t && mkdir -p %t
-! RUN: %flang -c -fno-integrated-as -save-temps=obj -o %t/out.o %s 2>&1
+! RUN: %flang -c -save-temps=obj -o %t/out.o %s 2>&1
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
@@ -43,7 +43,7 @@
! Save to specific directory
!--------------------------
! RUN: rm -rf %t && mkdir -p %t
-! RUN: %flang -c -fno-integrated-as -save-temps=%t -o %t/out.o %s 2>&1
+! RUN: %flang -c -save-temps=%t -o %t/out.o %s 2>&1
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
diff --git a/flang/test/Driver/save-temps-use-module.f90 b/flang/test/Driver/save-temps-use-module.f90
index 2f184d15898571..fa0661f93f6fa1 100644
--- a/flang/test/Driver/save-temps-use-module.f90
+++ b/flang/test/Driver/save-temps-use-module.f90
@@ -4,7 +4,7 @@
! RUN: rm -rf %t && split-file %s %t
! RUN: mkdir %t/mod_inc_dir
! RUN: mv %t/somemodule.mod %t/mod_inc_dir
-! RUN: %flang -S -emit-llvm --save-temps=obj -I%t/mod_inc_dir -fno-integrated-as \
+! RUN: %flang -S -emit-llvm --save-temps=obj -I%t/mod_inc_dir \
! RUN: %t/ModuleUser.f90 -o %t/ModuleUser
! RUN: ls %t | FileCheck %s
diff --git a/flang/test/Driver/save-temps.f90 b/flang/test/Driver/save-temps.f90
index ab4723c1d16a41..12ca558ab0bb60 100644
--- a/flang/test/Driver/save-temps.f90
+++ b/flang/test/Driver/save-temps.f90
@@ -1,24 +1,28 @@
-! Tests for the `-save-temps` flag. As `flang` does not implement `-fc1as` (i.e. a driver for the integrated assembler), we need to
-! use `-fno-integrated-as` here.
+! Tests for the `-save-temps` flag. As `flang` does not implement `-fc1as`
+! (i.e. a driver for the integrated assembler), we also need to check that
+! clang's integrated assembler does not get used.
! UNSUPPORTED: system-windows
!--------------------------
! Basic case: `-save-temps`
!--------------------------
-! RUN: %flang -save-temps -fno-integrated-as %s -### 2>&1 | FileCheck %s
+! RUN: %flang -save-temps %s -### 2>&1 | FileCheck %s
! CHECK: "-o" "save-temps.i"
! CHECK-NEXT: "-o" "save-temps.bc"
! CHECK-NEXT: "-o" "save-temps.s"
! CHECK-NEXT: "-o" "save-temps.o"
! CHECK-NEXT: "-o" "a.out"
+! RUN: %flang -save-temps %s -### 2>&1 | FileCheck %s --check-prefix=NOCC1AS
+! NOCC1AS-NOT: "-cc1as"
+
!--------------------------
! `-save-temps=cwd`
!--------------------------
! This should work the same as -save-temps above
-! RUN: %flang -save-temps=cwd -fno-integrated-as %s -### 2>&1 | FileCheck %s -check-prefix=CWD
+! RUN: %flang -save-temps=cwd %s -### 2>&1 | FileCheck %s -check-prefix=CWD
! CWD: "-o" "save-temps.i"
! CWD-NEXT: "-o" "save-temps.bc"
! CWD-NEXT: "-o" "save-temps.s"
@@ -31,14 +35,14 @@
! Check that temp files are saved in the same directory as the output file
! regardless of whether -o is specified.
-! RUN: %flang -save-temps=obj -fno-integrated-as -o obj/dir/a.out %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ
+! RUN: %flang -save-temps=obj -o obj/dir/a.out %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ
! CHECK-OBJ: "-o" "obj/dir/save-temps.i"
! CHECK-OBJ-NEXT: "-o" "obj/dir/save-temps.bc"
! CHECK-OBJ-NEXT: "-o" "obj/dir/save-temps.s"
! CHECK-OBJ-NEXT: "-o" "obj/dir/save-temps.o"
! CHECK-OBJ-NEXT: "-o" "obj/dir/a.out"
-! RUN: %flang -save-temps=obj -fno-integrated-as %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ-NOO
+! RUN: %flang -save-temps=obj %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ-NOO
! CHECK-OBJ-NOO: "-o" "save-temps.i"
! CHECK-OBJ-NOO-NEXT: "-o" "save-temps.bc"
! CHECK-OBJ-NOO-NEXT: "-o" "save-temps.s"
|
@llvm/pr-subscribers-clang-driver Author: Tarun Prabhu (tarunprabhu) ChangesCurrently, --save-temps requires -fno-integrated-as since flang does not have This will also allow us to enable some tests in the gfortran test suite within the LLVM test suite. Fixes #58587 Full diff: https://github.com/llvm/llvm-project/pull/119624.diff 4 Files Affected:
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 9f174fbda398b5..39b8dda7871096 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -155,9 +155,16 @@ llvm::vfs::FileSystem &ToolChain::getVFS() const {
}
bool ToolChain::useIntegratedAs() const {
- return Args.hasFlag(options::OPT_fintegrated_as,
- options::OPT_fno_integrated_as,
- IsIntegratedAssemblerDefault());
+ // When -save-temps is enabled in flang, it will attempt to use -cc1as which
+ // will not work. For now, we would like -save-temps to imply
+ // -fno-integrated-as. Eventually, we may want to consider having -fc1as - the
+ // flang analog of clang's cc1as.
+ if (D.IsFlangMode() && Args.hasArg(options::OPT_save_temps_EQ))
+ return false;
+ else
+ return Args.hasFlag(options::OPT_fintegrated_as,
+ options::OPT_fno_integrated_as,
+ IsIntegratedAssemblerDefault());
}
bool ToolChain::useIntegratedBackend() const {
diff --git a/flang/test/Driver/save-mlir-temps.f90 b/flang/test/Driver/save-mlir-temps.f90
index e9478a6c521b2e..70cd32a25f349d 100644
--- a/flang/test/Driver/save-mlir-temps.f90
+++ b/flang/test/Driver/save-mlir-temps.f90
@@ -4,8 +4,8 @@
! the driver does not generate specific passes for MLIR. Instead, they are
! generated during code generation as additional outputs.
-! As `flang` does not implement `-fc1as` (i.e. a driver for the integrated
-! assembler), we need to use `-fno-integrated-as` here.
+! `flang` does not implement `-fc1as` (i.e. a driver for the integrated
+! assembler).
! 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
@@ -20,13 +20,13 @@
! Save to cwd
!--------------------------
! RUN: rm -rf %t && mkdir -p %t
-! RUN: pushd %t && %flang -c -fno-integrated-as -save-temps=cwd -o out.o %s 2>&1
+! RUN: pushd %t && %flang -c -save-temps=cwd -o out.o %s 2>&1
! RUN: FileCheck %s -input-file=save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
! RUN: popd
! RUN: rm -rf %t && mkdir -p %t
-! RUN: pushd %t && %flang -c -fno-integrated-as -save-temps -o out.o %s 2>&1
+! RUN: pushd %t && %flang -c -save-temps -o out.o %s 2>&1
! RUN: FileCheck %s -input-file=save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
! RUN: popd
@@ -35,7 +35,7 @@
! Save to output directory
!--------------------------
! RUN: rm -rf %t && mkdir -p %t
-! RUN: %flang -c -fno-integrated-as -save-temps=obj -o %t/out.o %s 2>&1
+! RUN: %flang -c -save-temps=obj -o %t/out.o %s 2>&1
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
@@ -43,7 +43,7 @@
! Save to specific directory
!--------------------------
! RUN: rm -rf %t && mkdir -p %t
-! RUN: %flang -c -fno-integrated-as -save-temps=%t -o %t/out.o %s 2>&1
+! RUN: %flang -c -save-temps=%t -o %t/out.o %s 2>&1
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
diff --git a/flang/test/Driver/save-temps-use-module.f90 b/flang/test/Driver/save-temps-use-module.f90
index 2f184d15898571..fa0661f93f6fa1 100644
--- a/flang/test/Driver/save-temps-use-module.f90
+++ b/flang/test/Driver/save-temps-use-module.f90
@@ -4,7 +4,7 @@
! RUN: rm -rf %t && split-file %s %t
! RUN: mkdir %t/mod_inc_dir
! RUN: mv %t/somemodule.mod %t/mod_inc_dir
-! RUN: %flang -S -emit-llvm --save-temps=obj -I%t/mod_inc_dir -fno-integrated-as \
+! RUN: %flang -S -emit-llvm --save-temps=obj -I%t/mod_inc_dir \
! RUN: %t/ModuleUser.f90 -o %t/ModuleUser
! RUN: ls %t | FileCheck %s
diff --git a/flang/test/Driver/save-temps.f90 b/flang/test/Driver/save-temps.f90
index ab4723c1d16a41..12ca558ab0bb60 100644
--- a/flang/test/Driver/save-temps.f90
+++ b/flang/test/Driver/save-temps.f90
@@ -1,24 +1,28 @@
-! Tests for the `-save-temps` flag. As `flang` does not implement `-fc1as` (i.e. a driver for the integrated assembler), we need to
-! use `-fno-integrated-as` here.
+! Tests for the `-save-temps` flag. As `flang` does not implement `-fc1as`
+! (i.e. a driver for the integrated assembler), we also need to check that
+! clang's integrated assembler does not get used.
! UNSUPPORTED: system-windows
!--------------------------
! Basic case: `-save-temps`
!--------------------------
-! RUN: %flang -save-temps -fno-integrated-as %s -### 2>&1 | FileCheck %s
+! RUN: %flang -save-temps %s -### 2>&1 | FileCheck %s
! CHECK: "-o" "save-temps.i"
! CHECK-NEXT: "-o" "save-temps.bc"
! CHECK-NEXT: "-o" "save-temps.s"
! CHECK-NEXT: "-o" "save-temps.o"
! CHECK-NEXT: "-o" "a.out"
+! RUN: %flang -save-temps %s -### 2>&1 | FileCheck %s --check-prefix=NOCC1AS
+! NOCC1AS-NOT: "-cc1as"
+
!--------------------------
! `-save-temps=cwd`
!--------------------------
! This should work the same as -save-temps above
-! RUN: %flang -save-temps=cwd -fno-integrated-as %s -### 2>&1 | FileCheck %s -check-prefix=CWD
+! RUN: %flang -save-temps=cwd %s -### 2>&1 | FileCheck %s -check-prefix=CWD
! CWD: "-o" "save-temps.i"
! CWD-NEXT: "-o" "save-temps.bc"
! CWD-NEXT: "-o" "save-temps.s"
@@ -31,14 +35,14 @@
! Check that temp files are saved in the same directory as the output file
! regardless of whether -o is specified.
-! RUN: %flang -save-temps=obj -fno-integrated-as -o obj/dir/a.out %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ
+! RUN: %flang -save-temps=obj -o obj/dir/a.out %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ
! CHECK-OBJ: "-o" "obj/dir/save-temps.i"
! CHECK-OBJ-NEXT: "-o" "obj/dir/save-temps.bc"
! CHECK-OBJ-NEXT: "-o" "obj/dir/save-temps.s"
! CHECK-OBJ-NEXT: "-o" "obj/dir/save-temps.o"
! CHECK-OBJ-NEXT: "-o" "obj/dir/a.out"
-! RUN: %flang -save-temps=obj -fno-integrated-as %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ-NOO
+! RUN: %flang -save-temps=obj %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ-NOO
! CHECK-OBJ-NOO: "-o" "save-temps.i"
! CHECK-OBJ-NOO-NEXT: "-o" "save-temps.bc"
! CHECK-OBJ-NOO-NEXT: "-o" "save-temps.s"
|
@llvm/pr-subscribers-flang-driver Author: Tarun Prabhu (tarunprabhu) ChangesCurrently, --save-temps requires -fno-integrated-as since flang does not have This will also allow us to enable some tests in the gfortran test suite within the LLVM test suite. Fixes #58587 Full diff: https://github.com/llvm/llvm-project/pull/119624.diff 4 Files Affected:
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 9f174fbda398b5..39b8dda7871096 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -155,9 +155,16 @@ llvm::vfs::FileSystem &ToolChain::getVFS() const {
}
bool ToolChain::useIntegratedAs() const {
- return Args.hasFlag(options::OPT_fintegrated_as,
- options::OPT_fno_integrated_as,
- IsIntegratedAssemblerDefault());
+ // When -save-temps is enabled in flang, it will attempt to use -cc1as which
+ // will not work. For now, we would like -save-temps to imply
+ // -fno-integrated-as. Eventually, we may want to consider having -fc1as - the
+ // flang analog of clang's cc1as.
+ if (D.IsFlangMode() && Args.hasArg(options::OPT_save_temps_EQ))
+ return false;
+ else
+ return Args.hasFlag(options::OPT_fintegrated_as,
+ options::OPT_fno_integrated_as,
+ IsIntegratedAssemblerDefault());
}
bool ToolChain::useIntegratedBackend() const {
diff --git a/flang/test/Driver/save-mlir-temps.f90 b/flang/test/Driver/save-mlir-temps.f90
index e9478a6c521b2e..70cd32a25f349d 100644
--- a/flang/test/Driver/save-mlir-temps.f90
+++ b/flang/test/Driver/save-mlir-temps.f90
@@ -4,8 +4,8 @@
! the driver does not generate specific passes for MLIR. Instead, they are
! generated during code generation as additional outputs.
-! As `flang` does not implement `-fc1as` (i.e. a driver for the integrated
-! assembler), we need to use `-fno-integrated-as` here.
+! `flang` does not implement `-fc1as` (i.e. a driver for the integrated
+! assembler).
! 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
@@ -20,13 +20,13 @@
! Save to cwd
!--------------------------
! RUN: rm -rf %t && mkdir -p %t
-! RUN: pushd %t && %flang -c -fno-integrated-as -save-temps=cwd -o out.o %s 2>&1
+! RUN: pushd %t && %flang -c -save-temps=cwd -o out.o %s 2>&1
! RUN: FileCheck %s -input-file=save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
! RUN: popd
! RUN: rm -rf %t && mkdir -p %t
-! RUN: pushd %t && %flang -c -fno-integrated-as -save-temps -o out.o %s 2>&1
+! RUN: pushd %t && %flang -c -save-temps -o out.o %s 2>&1
! RUN: FileCheck %s -input-file=save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
! RUN: popd
@@ -35,7 +35,7 @@
! Save to output directory
!--------------------------
! RUN: rm -rf %t && mkdir -p %t
-! RUN: %flang -c -fno-integrated-as -save-temps=obj -o %t/out.o %s 2>&1
+! RUN: %flang -c -save-temps=obj -o %t/out.o %s 2>&1
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
@@ -43,7 +43,7 @@
! Save to specific directory
!--------------------------
! RUN: rm -rf %t && mkdir -p %t
-! RUN: %flang -c -fno-integrated-as -save-temps=%t -o %t/out.o %s 2>&1
+! RUN: %flang -c -save-temps=%t -o %t/out.o %s 2>&1
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-fir.mlir -check-prefix=MLIR-FIR
! RUN: FileCheck %s -input-file=%t/save-mlir-temps-llvmir.mlir -check-prefix=MLIR-LLVMIR
diff --git a/flang/test/Driver/save-temps-use-module.f90 b/flang/test/Driver/save-temps-use-module.f90
index 2f184d15898571..fa0661f93f6fa1 100644
--- a/flang/test/Driver/save-temps-use-module.f90
+++ b/flang/test/Driver/save-temps-use-module.f90
@@ -4,7 +4,7 @@
! RUN: rm -rf %t && split-file %s %t
! RUN: mkdir %t/mod_inc_dir
! RUN: mv %t/somemodule.mod %t/mod_inc_dir
-! RUN: %flang -S -emit-llvm --save-temps=obj -I%t/mod_inc_dir -fno-integrated-as \
+! RUN: %flang -S -emit-llvm --save-temps=obj -I%t/mod_inc_dir \
! RUN: %t/ModuleUser.f90 -o %t/ModuleUser
! RUN: ls %t | FileCheck %s
diff --git a/flang/test/Driver/save-temps.f90 b/flang/test/Driver/save-temps.f90
index ab4723c1d16a41..12ca558ab0bb60 100644
--- a/flang/test/Driver/save-temps.f90
+++ b/flang/test/Driver/save-temps.f90
@@ -1,24 +1,28 @@
-! Tests for the `-save-temps` flag. As `flang` does not implement `-fc1as` (i.e. a driver for the integrated assembler), we need to
-! use `-fno-integrated-as` here.
+! Tests for the `-save-temps` flag. As `flang` does not implement `-fc1as`
+! (i.e. a driver for the integrated assembler), we also need to check that
+! clang's integrated assembler does not get used.
! UNSUPPORTED: system-windows
!--------------------------
! Basic case: `-save-temps`
!--------------------------
-! RUN: %flang -save-temps -fno-integrated-as %s -### 2>&1 | FileCheck %s
+! RUN: %flang -save-temps %s -### 2>&1 | FileCheck %s
! CHECK: "-o" "save-temps.i"
! CHECK-NEXT: "-o" "save-temps.bc"
! CHECK-NEXT: "-o" "save-temps.s"
! CHECK-NEXT: "-o" "save-temps.o"
! CHECK-NEXT: "-o" "a.out"
+! RUN: %flang -save-temps %s -### 2>&1 | FileCheck %s --check-prefix=NOCC1AS
+! NOCC1AS-NOT: "-cc1as"
+
!--------------------------
! `-save-temps=cwd`
!--------------------------
! This should work the same as -save-temps above
-! RUN: %flang -save-temps=cwd -fno-integrated-as %s -### 2>&1 | FileCheck %s -check-prefix=CWD
+! RUN: %flang -save-temps=cwd %s -### 2>&1 | FileCheck %s -check-prefix=CWD
! CWD: "-o" "save-temps.i"
! CWD-NEXT: "-o" "save-temps.bc"
! CWD-NEXT: "-o" "save-temps.s"
@@ -31,14 +35,14 @@
! Check that temp files are saved in the same directory as the output file
! regardless of whether -o is specified.
-! RUN: %flang -save-temps=obj -fno-integrated-as -o obj/dir/a.out %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ
+! RUN: %flang -save-temps=obj -o obj/dir/a.out %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ
! CHECK-OBJ: "-o" "obj/dir/save-temps.i"
! CHECK-OBJ-NEXT: "-o" "obj/dir/save-temps.bc"
! CHECK-OBJ-NEXT: "-o" "obj/dir/save-temps.s"
! CHECK-OBJ-NEXT: "-o" "obj/dir/save-temps.o"
! CHECK-OBJ-NEXT: "-o" "obj/dir/a.out"
-! RUN: %flang -save-temps=obj -fno-integrated-as %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ-NOO
+! RUN: %flang -save-temps=obj %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ-NOO
! CHECK-OBJ-NOO: "-o" "save-temps.i"
! CHECK-OBJ-NOO-NEXT: "-o" "save-temps.bc"
! CHECK-OBJ-NOO-NEXT: "-o" "save-temps.s"
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About time :) Thank you, LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I think this is a good first step. Eventually, I think we'll still have to introduce proper support for -fc1as
, because -fno-integrated-as
(this patch making it the default for Flang) results in target offload programs failing to link.
Thank you for reviewing this. I will look into developing |
The build kite shows a failure on Windows on
This patch forces an external assembler to be used when I am guessing that the failing test "worked" earlier because it would generate an invalid subcommand using the non-existent Do you have any suggestions on how we might handle this case on Windows? |
That's interesting, there is an external assembler on Windows; in fact, LLVM itself builds one (llvm-ml.exe) as well as MSVC providing one (ml.exe). I wonder why we can't just use llvm-ml here, since we know it must be available? I can have a look if this works for clang. If so I guess we should support it in flang too. If not then there's probably some other issue with it and we should just disable save-temps on Windows if it doesn't work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tarunprabhu I get the same failure with clang on Windows so I don't think that's on you to fix. I'd be happy to just have that test disabled on Windows for now.
Funnily enough, none of clang -cc1as, ml64.exe or llvm-ml.exe are actually able to assemble the assembly saved by -save-temps for either clang or flang, at least on my system 🤷. I guess -save-temps is just broken there?
Currently, --save-temps requires -fno-integrated-as since flang does not have
fc1as
i.e. a driver for an integrated assembler. This simply checks if the driver is in flang-mode and forces useIntegratedAs() to return true if -save-temps was found on the command line.This will also allow us to enable some tests in the gfortran test suite within the LLVM test suite.
Fixes #58587