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

Bug: Missing clangs arg count #2881

Open
luispadron opened this issue Jan 25, 2024 · 14 comments
Open

Bug: Missing clangs arg count #2881

luispadron opened this issue Jan 25, 2024 · 14 comments
Labels
bug Something isn't working

Comments

@luispadron
Copy link
Contributor

Description

A user reported an issue where they were on one commit using Xcode 15.1 where things were working correctly. They switched to a commit which uses Xcode 15.0.1 and run into generation errors during project generation:

Generating ".cashcli/Projects/CashApp.xcodeproj"
Starting local Bazel server and connecting to it...
INFO: Invocation ID: fda96df3-b7f4-47d2-96c0-3eeca4eae007
INFO: Analyzed target @rules_xcodeproj~1.15.0~internal~rules_xcodeproj_generated//generator/.cashcli/Projects/CashApp:CashApp (799 packages loaded, 53174 targets configured).
INFO: Found 1 target...
ERROR: Code/SystemResources/AppDependencies/BUILD.bazel:12:15: Generating bazel-out/ios-arm64-min14.0-applebin_ios-ios_arm64-dbg-ST-1085b1e95571/bin/Code/SystemResources/AppDependencies/AppDependencies.rules_xcodeproj.build_settings failed: (Exit 1): universal_target_build_settings failed: error executing command (from target //Code/SystemResources/AppDependencies:AppDependencies) 
  (cd /private/var/tmp/_bazel_<bradfol>/907fcb5025b8b52c1255ae7b70e7bf3a/rules_xcodeproj.noindex/build_output_base/execroot/_main && \
  exec env - \
  bazel-out/darwin_arm64-opt-exec-2B5CBBC6-ST-477482371507/bin/external/rules_xcodeproj~1.15.0/tools/generators/target_build_settings/universal_target_build_settings 1 bazel-out/ios-arm64-min14.0-applebin_ios-ios_arm64-dbg-ST-1085b1e95571/bin/Code/SystemResources/AppDependencies/AppDependencies.rules_xcodeproj.build_settings bazel-out/ios-arm64-min14.0-applebin_ios-ios_arm64-dbg-ST-1085b1e95571/bin/Code/SystemResources/AppDependencies/AppDependencies.rules_xcodeproj.debug_settings 0 1 bazel-out/ios-arm64-min14.0-applebin_ios-ios_arm64-dbg-ST-1085b1e95571/bin/Code/SystemResources/AppDependencies/AppDependencies_swift.rules_xcodeproj.debug_settings '' 0 0 '' '' 0 '' '' '' 0 '' '' bazel-out/darwin_arm64-opt-exec-2B5CBBC6-ST-477482371507/bin/external/rules_swift~1.13.0/tools/worker/worker swiftc @bazel-out/ios-arm64-min14.0-applebin_ios-ios_arm64-dbg-ST-1085b1e95571/bin/Code/SystemResources/AppDependencies/AppDependencies.rules_xcodeproj.build_settings-0.params --- ---)
# Configuration: ba4f66d6c1caab0757ed204ea2949fcf8a4e0a53735846a4b89f2b6948d9fb93
# Execution platform: @local_config_platform//:host
ERROR: Internal precondition failure:
tools/generators/lib/PBXProj/src/TargetSwiftDebugSettings.swift:34: "/private/var/tmp/_bazel_<user>/907fcb5025b8b52c1255ae7b70e7bf3a/rules_xcodeproj.noindex/build_output_base/execroot/_main/bazel-out/ios-arm64-min14.0-applebin_ios-ios_arm64-dbg-ST-1085b1e95571/bin/Code/SystemResources/AppDependencies/AppDependencies_swift.rules_xcodeproj.debug_settings": Missing clang args count
Please file a bug report at https://github.com/MobileNativeFoundation/rules_xcodeproj/issues/new?template=bug.md
ERROR: Code/SystemResources/AppDependencies/BUILD.bazel:12:15: Generating bazel-out/ios-sim_arm64-min14.0-applebin_ios-ios_sim_arm64-dbg-ST-7229f8b34da9/bin/Code/SystemResources/AppDependencies/AppDependencies.rules_xcodeproj.build_settings failed: (Exit 1): universal_target_build_settings failed: error executing command (from target //Code/SystemResources/AppDependencies:AppDependencies) 
  (cd /private/var/tmp/_bazel_<user>/907fcb5025b8b52c1255ae7b70e7bf3a/rules_xcodeproj.noindex/build_output_base/execroot/_main && \
  exec env - \
  bazel-out/darwin_arm64-opt-exec-2B5CBBC6-ST-477482371507/bin/external/rules_xcodeproj~1.15.0/tools/generators/target_build_settings/universal_target_build_settings 1 bazel-out/ios-sim_arm64-min14.0-applebin_ios-ios_sim_arm64-dbg-ST-7229f8b34da9/bin/Code/SystemResources/AppDependencies/AppDependencies.rules_xcodeproj.build_settings bazel-out/ios-sim_arm64-min14.0-applebin_ios-ios_sim_arm64-dbg-ST-7229f8b34da9/bin/Code/SystemResources/AppDependencies/AppDependencies.rules_xcodeproj.debug_settings 0 1 bazel-out/ios-sim_arm64-min14.0-applebin_ios-ios_sim_arm64-dbg-ST-7229f8b34da9/bin/Code/SystemResources/AppDependencies/AppDependencies_swift.rules_xcodeproj.debug_settings '' 0 0 '' '' 0 '' '' '' 0 '' '' bazel-out/darwin_arm64-opt-exec-2B5CBBC6-ST-477482371507/bin/external/rules_swift~1.13.0/tools/worker/worker swiftc @bazel-out/ios-sim_arm64-min14.0-applebin_ios-ios_sim_arm64-dbg-ST-7229f8b34da9/bin/Code/SystemResources/AppDependencies/AppDependencies.rules_xcodeproj.build_settings-0.params --- ---)
# Configuration: 79e7d91f01934ef122458860281ec7fd9d20f8f620a5175739a049a2c36d03cb
# Execution platform: @local_config_platform//:host
ERROR: Internal precondition failure:
tools/generators/lib/PBXProj/src/TargetSwiftDebugSettings.swift:34: "/private/var/tmp/_bazel_<user>/907fcb5025b8b52c1255ae7b70e7bf3a/rules_xcodeproj.noindex/build_output_base/execroot/_main/bazel-out/ios-sim_arm64-min14.0-applebin_ios-ios_sim_arm64-dbg-ST-7229f8b34da9/bin/Code/SystemResources/AppDependencies/AppDependencies_swift.rules_xcodeproj.debug_settings": Missing clang args count
Please file a bug report at https://github.com/MobileNativeFoundation/rules_xcodeproj/issues/new?template=bug.md
INFO: Elapsed time: 38.273s, Critical Path: 0.15s
INFO: 121 processes: 47 disk cache hit, 73 internal, 1 local.
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target

Reproduction steps

From what what was reported to me:

  • Switch from Xcode 15.1 to Xcode 15.0.1 different commits after having generated with 15.1

Expected behavior

The project generates correctly

rules_xcodeproj version

1.15.0

Xcode version

15.1 -> 15.0.1

Bazel version

6.4.0

rules_apple version

3.1.1

rules_swift version

1.13.0

Additional information

No response

@luispadron luispadron added the bug Something isn't working label Jan 25, 2024
@luispadron luispadron changed the title Bug: Missing clangs arg count when switching Xcode Bug: Missing clangs arg count when switching Xcode versions Jan 25, 2024
@luispadron
Copy link
Contributor Author

Workaround was to delete all caches, including our Bazel disk cache

@BalestraPatrick
Copy link
Contributor

I wonder, are you following the suggestion here to get Bazel to pick up correctly the change in Xcode versions? https://github.com/bazelbuild/rules_apple/blob/master/doc/common_info.md#xcode-version-selection-and-invalidation

@luispadron
Copy link
Contributor Author

@BalestraPatrick Yeah we have that all setup (correctly i hope). The command line builds are fine its just when generating the project that we see the failure.

@brentleyjones
Copy link
Contributor

Was /private/var/tmp/_bazel_<user>/907fcb5025b8b52c1255ae7b70e7bf3a/rules_xcodeproj.noindex/build_output_base/execroot/_main/bazel-out/ios-arm64-min14.0-applebin_ios-ios_arm64-dbg-ST-1085b1e95571/bin/Code/SystemResources/AppDependencies/AppDependencies_swift.rules_xcodeproj.debug_settings empty? Did anything else change besides the Xcode version? Like deps?

@brentleyjones
Copy link
Contributor

That file should never be empty (

var data = Data()
data.appendArgs(clangArgs)
data.appendArgs(frameworkIncludes)
data.appendArgs(swiftIncludes)
try data.write(to: url)
), so this sounds like some odd disk cache poisoning issue...

@luispadron
Copy link
Contributor Author

The one thing we did which i think caused other build failures (and forced us to use our action_env cache buster) was we moved our Tools/Rules directory which contained all our rules to Bazel/. Users reported issues at the command line after this change and deleting disk cache was the only solution, so potentially related to that and not a bug in rules_xcodeproj?

@brentleyjones
Copy link
Contributor

Probably. I would need a repro to dig into this more. Looking at the code, it doesn't seem like this condition should be possible outside of cache poisoning.

@brentleyjones brentleyjones closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2024
@luispadron
Copy link
Contributor Author

We had another engineer report the same error (different target).

They reported deleting a target and then trying to generate a project. I don't believe an Xcode change was involved in this case but need to check with them.

Going to try to get a repro, so far haven't been able to myself.

@thiagohmcruz
Copy link
Contributor

thiagohmcruz commented Feb 7, 2024

Consistently hitting this just now in an internal project, tried to clean everything an no luck. Trying to wipe my disk cache now to see if that unblocks me. If I manage to find a repro will share it here as well.

EDIT: confirmed that after deleting my disk cache directory the issue is gone

@luispadron
Copy link
Contributor Author

An engineer just reported this again, should we reopen? It's not immediately obvious what's causing this but clearing out caches seems to fix this

@luispadron
Copy link
Contributor Author

For this recent case I don't believe there was any Xcode switching involved

@brentleyjones
Copy link
Contributor

Until we have a repro, I don't know what we can do. I'm not sure it's not a remote cache things, or a Bazel bug, or if it's something in rules_xcodeproj.

I also asked some questions about the content of files. I'm not even sure what the symptom is, let alone the root cause. Do you have more information on any of that?

@luispadron luispadron changed the title Bug: Missing clangs arg count when switching Xcode versions Bug: Missing clangs arg count Mar 29, 2024
@luispadron
Copy link
Contributor Author

Yeah I don't really know either, personally never run into it.

From the errors we've seen it's the debug_settings file but I haven't been able to look deeper at the contents, etc

@brentleyjones
Copy link
Contributor

I got a similar (but slightly different) report on internal CI, so going to reopen this (still without repro steps though):

(13:49:47) ERROR: /Users/vagrant/git/Modules/EventKit/BUILD.bazel:561:28: Generating bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min15.0-applebin_ios-ST-bd2bf54e2820/bin/Modules/EventKit/DebugLoggerInterface_swift.rules_xcodeproj.build_settings failed: (Killed): universal_target_build_settings failed: error executing WriteTargetBuildSettings command (from target //Modules/EventKit:DebugLoggerInterface_swift) 
  (cd /private/var/tmp/_bazel_vagrant/44b08d771321dac1bc850a6d84c72843/rules_xcodeproj.noindex/build_output_base/execroot/_main && \
  exec env - \
  bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_xcodeproj~/tools/generators/target_build_settings/universal_target_build_settings 1 bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min15.0-applebin_ios-ST-bd2bf54e2820/bin/Modules/EventKit/DebugLoggerInterface_swift.rules_xcodeproj.build_settings bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min15.0-applebin_ios-ST-bd2bf54e2820/bin/Modules/EventKit/DebugLoggerInterface_swift.rules_xcodeproj.debug_settings 1 '' '' 0 0 '' '' '' '' '' 0 '' '' bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_swift~/tools/worker/worker swiftc @bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min15.0-applebin_ios-ST-bd2bf54e2820/bin/Modules/EventKit/DebugLoggerInterface_swift.rules_xcodeproj.build_settings-0.params --- ---)

@brentleyjones brentleyjones reopened this May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants