mozilla / sccache

Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible. Sccache has the capability to utilize caching in remote storage environments, including various cloud storage options, or alternatively, in local storage.
Apache License 2.0
5.83k stars 547 forks source link

`-Xarch` Clang compiler option not supported #2090

Open cgytrus opened 8 months ago

cgytrus commented 8 months ago

I'm not sure what the exact conditions are, but CMake (sometimes?) generates -Xarch_<arch> before architecture-specific PCH includes with (both LLVM and Apple) Clang on macOS. The option's syntax is kind of weird (-Xarch_<arg1> <arg2> Clang CLI ref) and it not being properly supported results in arguments getting reordered weirdly causing the following errors:

/usr/local/bin/sccache /usr/local/opt/llvm/bin/clang++ <...> -arch x86_64 <...> -Winvalid-pch -Xarch_x86_64 -include/Users/runner/work/geode/geode/build/loader/CMakeFiles/geode-loader.dir/cmake_pch_x86_64.hxx <...>
clang++: error: no such file or directory: 'x86_64'
clang++: error: invalid Xarch argument: '-Xarch_x86_64 -arch', options requiring arguments are unsupported
[2024-02-13T11:50:19Z DEBUG sccache::compiler::gcc] cmd after -arch rewrite: Some(<...> "/usr/local/opt/llvm/bin/clang++" <...> "-include" "/Users/runner/work/geode/geode/build/loader/CMakeFiles/geode-loader.dir/cmake_pch_x86_64.hxx" <...> "-Winvalid-pch" "-Xarch_x86_64" "-arch" "x86_64" <...>)

I managed to work around the issue for my specific use case in this commit, but obviously this isn't sustainable long-term, since it should actually parse 2 arguments from the option (arg1 and arg2) which doesn't seem to be possible right now.

Noxybot commented 6 months ago

Same for me... Is there a resolution for this?

tomconder commented 3 months ago

+1. I also am facing this issue with sccache on Mac OS X.

sylvestre commented 3 months ago

Don't hesitate to propose a patch for this. AFAIK, we (Mozilla) aren't impacted by this.

pauliesnug commented 1 month ago

Don't hesitate to propose a patch for this. AFAIK, we (Mozilla) aren't impacted by this.

I believe a patch wasn't proposed due to the issue mentioned, "obviously this isn't sustainable long-term, since it should actually parse 2 arguments from the option (arg1 and arg2) which doesn't seem to be possible right now."

torarnv commented 1 month ago

I made a stab at a more generic fix in https://github.com/mozilla/sccache/pull/2265

@sylvestre please have a look, thanks!