buck icon indicating copy to clipboard operation
buck copied to clipboard

HeaderSymlinkWithHeaderMap missing in cache break Swift build

Open zayhero-zz opened this issue 9 years ago • 4 comments

Right now if we use cxx_library or apple_library to build cxx files, it generate header map like MyProject#header-mode-symlink-tree-with-header-map,headers.hmap. However, this file is not cached correctly, if MyProject is not being updated in incremental build, this file will not exist. This works fine when we only have objC code. But if you have a swift file which need to use the cxx files in MyProject, this will break. Under current Buck build logic, we are using bridging header to import header files from MyProject to current project. But since the header map file is missing, the import will fail and receive error saying the header file not found.

Here is a sample https://github.com/zayhero/BugSample

Repo step:

  1. run buck build ... --config cache.dir="~/.cache/buck/build-cache" --config cache.dir_mode=readwrite . Everything should works fine and Greeter#header-mode-symlink-tree-with-header-map,headers.hmap is generated.
  2. run rm -rf buck-out to clear the cache
  3. edit main.swift to add one more line (anything is ok, e.g. Greeter.sayHello("ObjC Again"))
  4. run buck build ... --config cache.dir="~/.cache/buck/build-cache" --config cache.dir_mode=readonly. This should get the error:

[2017-04-23 10:50:44.553][error][command:f17fe6c9-f0aa-4629-836a-b121bfbce7aa][tid:30][com.facebook.buck.swift.SwiftCompileStep] Error running /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -frontend -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -target x86_64-apple-ios10.3 -import-objc-header bridging-header.h -F /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks -Xcc -I/Users/brian_zhang/projects/airbnb/BugSample/buck-out/gen/Greeter#header-mode-symlink-tree-with-header-map,headers.hmap -Xcc -Ibuck-out/gen/SwiftCallsObjC#headers,iphonesimulator-x86_64 -Xcc -Ibuck-out/gen/SwiftCallsObjC#iphonesimulator-x86_64,private-headers -Xcc -I/Users/brian_zhang/projects/airbnb/BugSample/buck-out -c -enable-objc-interop -module-name SwiftCallsObjC -emit-module -emit-module-path buck-out/gen/SwiftCallsObjC#iphonesimulator-x86_64,swift-compile/SwiftCallsObjC.swiftmodule -o buck-out/gen/SwiftCallsObjC#iphonesimulator-x86_64,swift-compile/SwiftCallsObjC.o -emit-objc-header-path buck-out/gen/SwiftCallsObjC#iphonesimulator-x86_64,swift-compile/SwiftCallsObjC-Swift.h main.swift: /Users/brian_zhang/projects/airbnb/BugSample/./bridging-header.h:1:9: error: 'Greeter/Greeter.h' file not found #import <Greeter/Greeter.h>

cc @Coneko @nguyentruongtho

zayhero-zz avatar Apr 23 '17 18:04 zayhero-zz

cc @milend

Coneko avatar Apr 24 '17 16:04 Coneko

cc @robbertvanginkel

Coneko avatar Apr 24 '17 16:04 Coneko

Any update on this?

zayhero-zz avatar Apr 26 '17 18:04 zayhero-zz

This problem is resolve after @milend rewrite Buck. Closing it now.

zayhero-zz avatar Oct 09 '17 04:10 zayhero-zz