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

doctor: check for combination of ccache and static analysis in iOS #1576

Open
mikehardy opened this issue Mar 30, 2022 · 10 comments
Open

doctor: check for combination of ccache and static analysis in iOS #1576

mikehardy opened this issue Mar 30, 2022 · 10 comments
Labels
command: doctor feature request no-stale-bot This issue cannot be marked as stale by stale bot

Comments

@mikehardy
Copy link
Contributor

Describe the Feature

@tido64 noted in facebook/react-native-website#3027 (comment) (a pull request that implies using ccache is great) that if you enable static analysis in your Xcode project, ccache is incompatible because of some pathing issues inside Xcode tooling

Possible Implementations

  • inspect pbxproj files for static analysis flags
  • somehow discover if ccache is in use on the system for the Xcode build?
    • inspect pbxproj?
    • check Podfile for CLANG/CLANG++ etc settings in post_install?
    • check environment variables - somehow as they are setup for build - to see if CLANG is defined && CCACHE_DISABLE is not?

Related Issues

Linked above

@mikehardy
Copy link
Contributor Author

I looked through the react-native-macos CI definition files but they are pretty modular and I was unable to find the specific pbxproj settings to examine, so for that part at least I suppose checking the diff of the pbxproj file before and after toggling them on (and seeing the failure if ccache is in use - to make sure this happens!) is the way to determine them.

And if we can't determine ccache is in use at all, we could at least emit an info line perhaps saying "static analysis will not work in combination with compiler caches, ensure compiler caches are disabled" or similar

@tido64
Copy link
Contributor

tido64 commented Mar 30, 2022

Compiler flags are in separate .xcconfig files. You can find the ones for iOS and macOS here:

In CocoaPods/Ruby, you can get the resolved build settings using xcodeproj (example). I don't know if there's an equivalent in JS.

I'm not sure how you can reliably detect whether Ccache is in use. You'd have to invoke xcodebuild and see which compiler it is using, and scan the binary for ccache references?

@mikehardy
Copy link
Contributor Author

Thanks so much for those pointers! One of the main Flutter advantages at the moment is "developer tooling", that's pretty vague but people always talk about how great it is. I think a large part of that is their doctor checks and bug reporting infrastructure so I'm queuing up a large set of hopefully-improvements inspired by that ecosystem and how well their doctor + bug report stuff works. So knowing more about how to perform these inspections is really helpful

Anyway - I am also not sure at all how to figure out the xcodebuild settings since you can just set environment variables on the command line as well, thus my thought on simply being informative / giving soft advice in known-incompatible cases

@github-actions
Copy link

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

@github-actions github-actions bot added the stale label Nov 26, 2022
@tido64
Copy link
Contributor

tido64 commented Nov 28, 2022

@mikehardy: Should we close this? Prefabs will be enabled as of 0.71 so I don't know how relevant this will be for 99% of use cases.

@mikehardy
Copy link
Contributor Author

While I understand the Pareto Principle is critical to employ in much software development, I think the hope for the doctor scripts is that they are not just 80% good but that they are excellent / world-class, implying that they are 99.999% or similar. Which also implies that if there's a known incompatibility in certain combinations and it is detectable, it should be done.

But open source being what it is, maybe that's just one more stale cycle then if it is still just hanging out, the issue goes to 🛌

@mikehardy mikehardy removed the stale label Nov 28, 2022
@adamTrz
Copy link
Collaborator

adamTrz commented Nov 28, 2022

Hey @mikehardy @tido64 , thanks for responding to the issue and turning it back life 🙂
Any wat we can help here?

@mikehardy
Copy link
Contributor Author

I think a successful implementation will resolve via some exploration the questions in the comment above #1576 (comment)

1- obtain and resolve Xcode settings to see if static analysis is enabled
2- determine if ccache is in use

For 1, it may be that doctor has an enhanced mode that allows for some otherwise-optional download+installs and xcodeproj is used to analyze settings?

For 2, it may be a good start to do a which clang and compare it to InstalledDir of clang --version for difference (see below) or perhaps check which clang, check whether it is a symbolic link, check if dereferenced symbolic link goes to ccache?

mike@osxvm:~ % which clang
/usr/local/bin/clang
mike@osxvm:~ % ls -lat /usr/local/bin/clang
lrwxr-xr-x  1 mike  admin  21 Jun  7 12:22 /usr/local/bin/clang@ -> /usr/local/bin/ccache
mike@osxvm:~ % clang --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@github-actions
Copy link

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

@github-actions github-actions bot added the stale label Feb 27, 2023
@tido64
Copy link
Contributor

tido64 commented Feb 28, 2023

We can probably use readlink to detect Ccache:

% ls clang
clang -> /opt/homebrew/bin/ccache

% ./clang --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

% $(readlink ./clang) --version
ccache version 4.7.4
Features: file-storage http-storage redis+unix-storage redis-storage

Copyright (C) 2002-2007 Andrew Tridgell
Copyright (C) 2009-2022 Joel Rosdahl and other contributors

See <https://ccache.dev/credits.html> for a complete list of contributors.

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.

Also, is there a tag we can add to prevent the bot from tagging this as stale?

@cortinico cortinico added no-stale-bot This issue cannot be marked as stale by stale bot and removed stale labels Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command: doctor feature request no-stale-bot This issue cannot be marked as stale by stale bot
Projects
None yet
Development

No branches or pull requests

4 participants