llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver
Author: rthomas-activision
<details>
<summary>Changes</summary>
With the following compilation process:
```
$ mkdir -p src/ tmp/
$ cat << 'EOF' > src/main.c
int main() { return 0; }
EOF
$ clang-cl /c /Fo:tmp/ /clang:-fembed-bitcode src/main.c
```
the object file `main.obj` is generated in the `tmp/` directory but the
intermediate `main.bc` is placed in the current working directory.
Ensure that intermediate `.bc` files are written to the same directory
specified by `/Fo`.
---
Full diff: https://github.com/llvm/llvm-project/pull/189977.diff
2 Files Affected:
- (modified) clang/lib/Driver/Driver.cpp (+6)
- (modified) clang/test/Driver/cl-outputs.c (+3)
``````````diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 0686a89d42faf..7d11d61cb84da 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6629,6 +6629,12 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
const JobAction &JA,
->getValue();
NamedOutput =
MakeCLOutputFilename(C.getArgs(), Val, BaseName, types::TY_Object);
+ } else if ((JA.getType() == types::TY_LLVM_BC ||
+ JA.getType() == types::TY_LLVM_IR) &&
+ IsCLMode() && C.getArgs().hasArg(options::OPT__SLASH_Fo)) {
+ StringRef Val = C.getArgs().getLastArg(options::OPT__SLASH_Fo)->getValue();
+ NamedOutput =
+ MakeCLOutputFilename(C.getArgs(), Val, BaseName, JA.getType());
} else {
const char *Suffix =
types::getTypeTempSuffix(JA.getType(), IsCLMode() || IsDXCMode());
diff --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c
index a8509e795c295..fc5fb49d2a514 100644
--- a/clang/test/Driver/cl-outputs.c
+++ b/clang/test/Driver/cl-outputs.c
@@ -310,3 +310,6 @@
// RUN: %clang_cl -target x86_64-windows -fdebug-compilation-dir=. /Z7
/Fofoo/a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
// RELATIVE_OBJPATH2: "-object-file-name=foo\\a.obj"
+
+// RUN: %clang_cl /c /Fodir/ /clang:-fembed-bitcode -### -- %s 2>&1 |
FileCheck -check-prefix=FoNAMEBC %s
+// FoNAMEBC: "-o" "dir/cl-outputs.bc"
``````````
</details>
https://github.com/llvm/llvm-project/pull/189977
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits