================
@@ -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 ||
----------------
rthomas-activision wrote:

Yes, we initially tried adding this condition next to `TY_LTO_BC` (line 6577)
but here is why I changed to an isolated condition.

In my understanding, the block under `JA.getType() == types::TY_Object || 
JA.getType() == types::TY_LTO_BC)` is aiming 
for the final object file that is written under the filename 
`MakeCLOutputFilename(..., types::TY_Object);`:

```
$ clang-cl /c /Fomain       # -> main.obj # types::TY_Object 
$ clang-cl /c /Fomain -flto # -> main.obj # types::TY_LTO_BC
```

In our case, the generated `main.bc` is the result of an **intermediate** step 
that
is not used by the linker (compared to `TY_LTO_BC`).

By using `-###` to exapnd the two steps:

```
$ clang-cl /c /Fomain /clang:-fembed-bitcode -### -- ./src/main.cpp
"../bin/clang-23" "-cc1" "-emit-llvm-bc" "-emit-llvm-uselists" 
"-main-file-name" "main.cpp" [...] "-o" "main.bc" "-x" "c++" "./src/main.cpp" # 
Step 1
"../bin/clang-23" "-cc1" "-emit-obj" "-fembed-bitcode=all" 
"-fembed-bitcode=all" "-disable-llvm-passes" "-o" "main.obj" "-x" "ir" 
"main.bc"  # Step 2
```

If we appended `|| JA.getType() == types::TY_LLVM_BC` to the line you 
mentioned, 
Step 1 would write to `main.obj` instead of `main.bc`. 
This happens because `MakeCLOutputFilename` is called with `types::TY_Object` 
as its third parameter, 
which forces the `.obj` extension.

I isolated the condition to prevent this intermediate file from causing a 
naming 
collision with the final output file.




https://github.com/llvm/llvm-project/pull/189977
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to