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

Stale modulemaps are not cleared in non-sandboxed mode if skip_packaging = ["modulemap"] added #610

Open
ivan-golub opened this issue Nov 21, 2022 · 0 comments

Comments

@ivan-golub
Copy link

ivan-golub commented Nov 21, 2022

Setup:

  1. Bazel setup with 2 frameworks (Foo and Bar) and 3 objc classes (A, B, C)
  2. Headers A and B are in Foo framework, Header C in Bar framework
  3. Bar depends on Foo
  4. Header C import Foo/A.h

Repro steps:

  1. Build framework Bar bazelisk build tests/ios/frameworks/modulemap:Bar --spawn_strategy=standalone
  2. Ensure its compilable
  3. Add skip_packaging = ["modulemap"] to Foo framework bazel file
  4. Remove B.h and B.m references from BUILD file
  5. Try building Bar again bazelisk build tests/ios/frameworks/modulemap:Bar --spawn_strategy=standalone
  6. Observe error C.m:3:9: fatal error: could not build module 'Foo' as rules still assume Foo exposes modulemap and should be imported as module, even if we clearly removed module. This happens because stale modulemap file is not removed and objc_library see it through search path -Fbazel-out/macos-arm64-applebin_macos-darwin_x86_64-dbg-ST-cd2b3b8d4835/bin/tests/ios/frameworks/modulemap/Foo
  7. Run bazelisk clean
  8. Try bulding Bar again bazelisk build tests/ios/frameworks/modulemap:Bar --spawn_strategy=standalone
  9. Observe that after clean Bar is compilable again

Repro project:

  1. Checkout https://github.com/ivan-golub/rules_ios/pull/1/commits/b2f1e65b3a962bcd3c52f9283b443852af3eeb38
  2. bazelisk build tests/ios/frameworks/modulemap:Bar --spawn_strategy=standalone
  3. Checkout https://github.com/ivan-golub/rules_ios/pull/1/commits/35163432528155bf5034242caf1df70175c3c546
  4. bazelisk build tests/ios/frameworks/modulemap:Bar --spawn_strategy=standalone
  5. Observe error:
ivan.golub@MV43T917V1 rules_ios % bazelisk build tests/ios/frameworks/modulemap:Bar --spawn_strategy=standalone
INFO: Analyzed target //tests/ios/frameworks/modulemap:Bar (1 packages loaded, 38 targets configured).
INFO: Found 1 target...
ERROR: /Users/ivan.golub/Snapchat/Dev/open_source/rules_ios/tests/ios/frameworks/modulemap/BUILD.bazel:16:16: Compiling tests/ios/frameworks/modulemap/C.m failed: (Aborted): wrapped_clang failed: error executing command 
  (cd /private/var/tmp/_bazel_ivan.golub/143184cdca2da33cc5402513b944e3f7/execroot/build_bazel_rules_ios && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=13.0 \
    PATH=/Users/ivan.golub/Library/Caches/bazelisk/downloads/bazelbuild/bazel-5.3.2-darwin-arm64/bin:/Users/ivan.golub/.pyenv/shims:/Users/ivan.golub/.nvm/versions/node/v16.16.0/bin:/Users/ivan.golub/Snapchat/Dev/google-cloud-sdk/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki:/Library/Apple/usr/bin:/opt/snapchat/bin:/Users/ivan.golub/Library/Android/sdk/tools:/Users/ivan.golub/Library/Android/sdk/platform-tools:/Users/ivan.golub/Library/Android/sdk/ndk/21.3.6528147 \
    XCODE_VERSION_OVERRIDE=14.1.0.14B47b \
    ZERO_AR_DATE=1 \
  external/local_config_cc/wrapped_clang -target arm64-apple-macosx13.0 '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g 'DEBUG_PREFIX_MAP_PWD=.' -include rules/library/common.pch -Wshorten-64-to-32 -Wbool-conversion -Wconstant-conversion -Wduplicate-method-match -Wempty-body -Wenum-conversion -Wint-conversion -Wunreachable-code -Wmismatched-return-types -Wundeclared-selector -Wuninitialized -Wunused-function -Wunused-variable -iquote . -iquote bazel-out/macos-arm64-applebin_macos-darwin_arm64-dbg-ST-d07250c41911/bin -MD -MF bazel-out/macos-arm64-applebin_macos-darwin_arm64-dbg-ST-d07250c41911/bin/tests/ios/frameworks/modulemap/_objs/Bar_objc/arc/C.d -Fbazel-out/macos-arm64-applebin_macos-darwin_x86_64-dbg-ST-cd2b3b8d4835/bin/tests/ios/frameworks/modulemap/Foo -DOS_MACOSX -fno-autolink -isysroot __BAZEL_XCODE_SDKROOT__ -F__BAZEL_XCODE_SDKROOT__/System/Library/Frameworks -F__BAZEL_XCODE_DEVELOPER_DIR__/Platforms/MacOSX.platform/Developer/Library/Frameworks -fobjc-arc -Werror -ivfsoverlaybazel-out/macos-arm64-applebin_macos-darwin_arm64-dbg-ST-d07250c41911/bin/tests/ios/frameworks/modulemap/Bar_vfs.yaml -F/build_bazel_rules_ios/frameworks -Ibazel-out/macos-arm64-applebin_macos-darwin_arm64-dbg-ST-d07250c41911/bin/tests/ios/frameworks/modulemap/Bar_private_hmap.hmap -Ibazel-out/macos-arm64-applebin_macos-darwin_arm64-dbg-ST-d07250c41911/bin/tests/ios/frameworks/modulemap/Bar_public_hmap.hmap -Ibazel-out/macos-arm64-applebin_macos-darwin_arm64-dbg-ST-d07250c41911/bin/tests/ios/frameworks/modulemap/Bar_private_angled_hmap.hmap -iquotebazel-out/macos-arm64-applebin_macos-darwin_arm64-dbg-ST-d07250c41911/bin/tests/ios/frameworks/modulemap/Bar_private_hmap.hmap -fmodules '-fmodule-name=Bar' -I. -index-store-path bazel-out/rules_ios_global_index_store.indexstore '-fmodules-cache-path=bazel-out/macos-arm64-applebin_macos-darwin_arm64-dbg-ST-d07250c41911/bin/_objc_module_cache' -O0 '-DDEBUG=1' -fstack-protector -fstack-protector-all -g -c tests/ios/frameworks/modulemap/C.m -o bazel-out/macos-arm64-applebin_macos-darwin_arm64-dbg-ST-d07250c41911/bin/tests/ios/frameworks/modulemap/_objs/Bar_objc/arc/C.o)
# Configuration: 8772067652d6607a1c25c35d38c04cc589658d7d39d2d2301975edcdbe7ca275
# Execution platform: @local_config_platform//:host
While building module 'Foo' imported from tests/ios/frameworks/modulemap/C.m:3:
In file included from <module-includes>:1:
bazel-out/macos-arm64-applebin_macos-darwin_x86_64-dbg-ST-cd2b3b8d4835/bin/tests/ios/frameworks/modulemap/Foo/Foo.framework/Headers/Foo-umbrella.h:20:1: error: umbrella header for module 'Foo' does not include header 'B.h' [-Werror,-Wincomplete-umbrella]
tests/ios/frameworks/modulemap/C.m:3:9: fatal error: could not build module 'Foo'
#import <Foo/A.h>
 ~~~~~~~^
2 errors generated.
Error in child process '/usr/bin/xcrun'. 1
Target //tests/ios/frameworks/modulemap:Bar failed to build
INFO: Elapsed time: 0.255s, Critical Path: 0.13s
INFO: 4 processes: 4 internal.
FAILED: Build did NOT complete successfully

6.bazelisk clean; bazelisk build tests/ios/frameworks/modulemap:Bar --spawn_strategy=standalone
7. Observe no error

ivan.golub@MV43T917V1 rules_ios % bazelisk clean; bazelisk build tests/ios/frameworks/modulemap:Bar --spawn_strategy=standalone
INFO: Starting clean.
INFO: Analyzed target //tests/ios/frameworks/modulemap:Bar (66 packages loaded, 1255 targets configured).
INFO: Found 1 target...
Target //tests/ios/frameworks/modulemap:Bar up-to-date:
  bazel-out/applebin_macos-darwin_x86_64-dbg-ST-cd2b3b8d4835/bin/tests/ios/frameworks/modulemap/Bar/Bar.framework/Bar
  bazel-out/applebin_macos-darwin_x86_64-dbg-ST-cd2b3b8d4835/bin/tests/ios/frameworks/modulemap/Bar/Bar.framework/Headers/C.h
  bazel-out/applebin_macos-darwin_x86_64-dbg-ST-cd2b3b8d4835/bin/tests/ios/frameworks/modulemap/Bar/Bar.framework/Headers/Bar-umbrella.h
  bazel-out/applebin_macos-darwin_x86_64-dbg-ST-cd2b3b8d4835/bin/tests/ios/frameworks/modulemap/Bar/Bar.framework/Modules/module.modulemap
INFO: Elapsed time: 3.542s, Critical Path: 2.10s
INFO: 36 processes: 22 internal, 14 local.
INFO: Build completed successfully, 36 total actions

Related to issue that was fixed in #209. FYI @congt

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

1 participant