[clang] [clang-cl] Accept `cl`-style output arguments (`/Fo`, `-Fo`) for `--precompile` (PR #121046)

Sharadh Rajaraman via cfe-commits cfe-commits at lists.llvm.org
Thu May 22 02:11:55 PDT 2025


sharadhr wrote:

> xmake dev said he can fix the problem by /clang:-o

We [tried this, but it didn't seem to work](https://gitlab.kitware.com/cmake/cmake/-/issues/25731#note_1603818). However, I think that issue has a subtle but important difference: @Arthapz has used [`/clang:-o -clang:<BMIfile>`](https://github.com/xmake-io/xmake/pull/6477/files#diff-b526124d8e7f20d143a49c263e4bf8ba6ebb77b799aa1b8d5e93639fd4e2d77cR44) whereas we used `/clang:-o<BMIfile>`. I'm not sure why this difference manifested, but it seems to _almost_ work now with the above change.

However, a `scan-with-pch` test still fails because `clang-cl: error: cannot specify -o when generating multiple output files`.

```
CMake Error at R:/cmake/Tests/RunCMake/RunCMake.cmake:289 (message):
examples/scan-with-pch-build - FAILED:

Result is [1], not [0].

Command was:

command> "R:/cmake/out/build/RelWithDebInfo/bin/cmake.exe" "--build" "." "--config" "Debug"

Actual stdout:

actual-stdout> [1/5] Building CXX object CMakeFiles\simple.dir\cmake_pch.cxx.obj
actual-stdout> FAILED: CMakeFiles/simple.dir/cmake_pch.cxx.obj
actual-stdout> R:\llvm-project\build\x64-release\bin\clang-cl.exe  /nologo -TP   /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++20 -MDd -Zi /YcR:/cmake/out/build/RelWithDebInfo/Tests/RunCMake/CXXModules/examples/scan-with-pch-build/CMakeFiles/simple.dir/cmake_pch.hxx /FpR:/cmake/out/build/RelWithDebInfo/Tests/RunCMake/CXXModules/examples/scan-with-pch-build/CMakeFiles/simple.dir/./cmake_pch.cxx.pch /FIR:/cmake/out/build/RelWithDebInfo/Tests/RunCMake/CXXModules/examples/scan-with-pch-build/CMakeFiles/simple.dir/cmake_pch.hxx /showIncludes -clang:-oCMakeFiles\simple.dir\cmake_pch.cxx.obj /FdCMakeFiles\simple.dir\ -c -- R:\cmake\out\build\RelWithDebInfo\Tests\RunCMake\CXXModules\examples\scan-with-pch-build\CMakeFiles\simple.dir\cmake_pch.cxx
actual-stdout> clang-cl: error: cannot specify -o when generating multiple output files
actual-stdout> ninja: build stopped: subcommand failed.
```


https://github.com/llvm/llvm-project/pull/121046


More information about the cfe-commits mailing list