Skip to content
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

sccache fails compiling ObjC code with a .cpp extension and -xobjective-c++ #163

Closed
luser opened this issue Jul 26, 2017 · 10 comments
Closed
Assignees

Comments

@luser
Copy link
Contributor

luser commented Jul 26, 2017

Reported on IRC, sccache is failing to build Firefox on Mac currently with some errors in OpenVR code. The OpenVR code is in .cpp files, but includes OS X system headers that use ObjC. The moz.build file passes -xobjective-c++ in CXXFLAGS, but sccache always passes -xwhatever based on the file extension:

let extension = match extension.as_ref() {

We should fix this so that if there's already an -xwhatever on the commandline we don't add another one.

@glandium
Copy link
Collaborator

We should fix this so that if there's already an -xwhatever on the commandline we don't add another one.

hum, you should use the flag that was passed for the preprocessor, but the compilation will need a mapped value for the preprocessed output.

@luser
Copy link
Contributor Author

luser commented Jul 26, 2017

Well if there's already an -xobjective-c++ on the commandline then we can just pass that to both invocations and it should work fine, right? The issue is that since the file is .cpp we're passing -xc++-cpp-output and it breaks.

I guess your point is that we ought to be replacing -xobjective-c++ with -xobjc-cpp-output?

@glandium
Copy link
Collaborator

it should work fine, right?

except for all the warnings that adds.

@glandium
Copy link
Collaborator

See #117 (comment)

@mikeconley
Copy link

Out of curiosity, are there any workarounds for this bug while a proper fix is developed?

@rillian
Copy link
Contributor

rillian commented Aug 1, 2017

The work-around I'm aware of is to use RUSTC_WRAPPER=sccache so you still get caching for rust code, but use plain --enable-ccache to for C/C++/ObjC code.

@mikeconley
Copy link

Cool, thanks @rillian.

For the folks who don't want to look up the dev-platform thread, this appears to be what you want to drop in your mozconfig for now:

mk_add_options "export RUSTC_WRAPPER=sccache"

Assuming sccache is on your PATH.

@luser
Copy link
Contributor Author

luser commented Aug 2, 2017

@glandium are you actively working on this? If not I'll take it.

@glandium
Copy link
Collaborator

glandium commented Aug 2, 2017

I am

glandium added a commit to glandium/sccache that referenced this issue Aug 9, 2017
First and foremost, to generically convey the type of compilation, we
normalize the file extension, and will use that information to feed
the right -x argument to the preprocessor and compiler.

When the compiler command sccache is invoked with already contains a -x
argument, we set the normalized file extension accordingly, such that
it matches what the caller wants, rather than what the source file
extension says.

On the preprocessor end, we then always pass one of `-x c`, `-x c++`,
`-x objective-c` or `-x objective-c++` according to the normalized file
extension.

On the compiler end, we always pass one of `-x cpp-output`, `-x
c++-cpp-output`, `-x objective-c-cpp-output` or `-x
objective-c++-cpp-output` accordingly.

Note that we used to pass `-x objc-cpp-output` to gcc, but that's a
deprecated form that it now warns about. The new form has been available
since at least gcc 4.3, so is fine to use.

And because a same source compiled as C or C++ will yield different
object code, include the normalized extension when computing the hashed
value.

Fixes mozilla#163.
@luser
Copy link
Contributor Author

luser commented Aug 10, 2017

@glandium's patch is in #170

glandium added a commit to glandium/sccache that referenced this issue Aug 11, 2017
First and foremost, to generically convey the type of compilation, we
normalize the file extension, and will use that information to feed
the right -x argument to the preprocessor and compiler.

When the compiler command sccache is invoked with already contains a -x
argument, we set the normalized file extension accordingly, such that
it matches what the caller wants, rather than what the source file
extension says.

On the preprocessor end, we then always pass one of `-x c`, `-x c++`,
`-x objective-c` or `-x objective-c++` according to the normalized file
extension.

On the compiler end, we always pass one of `-x cpp-output`, `-x
c++-cpp-output`, `-x objective-c-cpp-output` or `-x
objective-c++-cpp-output` accordingly.

Note that we used to pass `-x objc-cpp-output` to gcc, but that's a
deprecated form that it now warns about. The new form has been available
since at least gcc 4.3, so is fine to use.

And because a same source compiled as C or C++ will yield different
object code, include the normalized extension when computing the hashed
value.

Fixes mozilla#163.
glandium added a commit to glandium/sccache that referenced this issue Aug 11, 2017
First and foremost, to generically convey the type of compilation, we
normalize the file extension, and will use that information to feed
the right -x argument to the preprocessor and compiler.

When the compiler command sccache is invoked with already contains a -x
argument, we set the normalized file extension accordingly, such that
it matches what the caller wants, rather than what the source file
extension says.

On the preprocessor end, we then always pass one of `-x c`, `-x c++`,
`-x objective-c` or `-x objective-c++` according to the normalized file
extension.

On the compiler end, we always pass one of `-x cpp-output`, `-x
c++-cpp-output`, `-x objective-c-cpp-output` or `-x
objective-c++-cpp-output` accordingly.

Note that we used to pass `-x objc-cpp-output` to gcc, but that's a
deprecated form that it now warns about. The new form has been available
since at least gcc 4.3, so is fine to use.

And because a same source compiled as C or C++ will yield different
object code, include the normalized extension when computing the hashed
value.

Fixes mozilla#163.
@luser luser closed this as completed in ee10eae Aug 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants