iCepa/Tor.framework

Can't build with Tor 0.4.2.5 and 0.4.1.7

Closed this issue · 10 comments

https://blog.torproject.org/new-release-0425-also-0417-0406-and-0359

Building 0.4.0.6 works out of the box.
However, when trying to build 0.4.2.5 or 0.4.1.7, I'm getting this error:

error: unknown type name 'dispatch_queue_t' in Foundation.framework.

WTF? It seems, somehow Tor mangles with dispatch_queue_t or with anything around it, so the compiler doesn't recognize it anymore.

@mtigas, do you have any idea where to start looking?

While building module 'Foundation' imported from /Users/berhart/workspace/gp/Tor.framework/Tor/TORNode.h:8:
While building module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:60:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFPropertyList.h:17:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:468:77: error: unknown type name 'dispatch_queue_t'
void CFReadStreamSetDispatchQueue(CFReadStreamRef _Null_unspecified stream, dispatch_queue_t _Null_unspecified q) API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0));
                                                                            ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:468:94: error: expected ')'
void CFReadStreamSetDispatchQueue(CFReadStreamRef _Null_unspecified stream, dispatch_queue_t _Null_unspecified q) API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0));
                                                                                             ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:468:34: note: to match this '('
void CFReadStreamSetDispatchQueue(CFReadStreamRef _Null_unspecified stream, dispatch_queue_t _Null_unspecified q) API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0));
                                 ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:471:79: error: unknown type name 'dispatch_queue_t'
void CFWriteStreamSetDispatchQueue(CFWriteStreamRef _Null_unspecified stream, dispatch_queue_t _Null_unspecified q) API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0));
                                                                              ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:471:96: error: expected ')'
void CFWriteStreamSetDispatchQueue(CFWriteStreamRef _Null_unspecified stream, dispatch_queue_t _Null_unspecified q) API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0));
                                                                                               ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:471:35: note: to match this '('
void CFWriteStreamSetDispatchQueue(CFWriteStreamRef _Null_unspecified stream, dispatch_queue_t _Null_unspecified q) API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0));
                                  ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:479:1: error: unknown type name 'dispatch_queue_t'
dispatch_queue_t _Null_unspecified CFReadStreamCopyDispatchQueue(CFReadStreamRef _Null_unspecified stream) API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:479:18: error: expected identifier or '('
dispatch_queue_t _Null_unspecified CFReadStreamCopyDispatchQueue(CFReadStreamRef _Null_unspecified stream) API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0));
                 ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:482:1: error: unknown type name 'dispatch_queue_t'
dispatch_queue_t _Null_unspecified CFWriteStreamCopyDispatchQueue(CFWriteStreamRef _Null_unspecified stream) API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:482:18: error: expected identifier or '('
dispatch_queue_t _Null_unspecified CFWriteStreamCopyDispatchQueue(CFWriteStreamRef _Null_unspecified stream) API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0));
                 ^
While building module 'Foundation' imported from /Users/berhart/workspace/gp/Tor.framework/Tor/TORNode.h:8:
While building module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:73:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFMessagePort.h:63:67: error: unknown type name 'dispatch_queue_t'
CF_EXPORT void CFMessagePortSetDispatchQueue(CFMessagePortRef ms, dispatch_queue_t queue) API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0));
                                                                  ^
While building module 'Foundation' imported from /Users/berhart/workspace/gp/Tor.framework/Tor/TORNode.h:8:
In file included from <module-includes>:1:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10: fatal error: could not build module 'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
 ~~~~~~~~^
While building module 'Foundation' imported from /Users/berhart/workspace/gp/Tor.framework/Tor/TORNode.h:8:
While building module 'Security' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:9:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.h:27:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h:28:10: fatal error: could not build module 'CoreFoundation'
#include <CoreFoundation/CFBase.h>
 ~~~~~~~~^
While building module 'Foundation' imported from /Users/berhart/workspace/gp/Tor.framework/Tor/TORNode.h:8:
While building module 'CFNetwork' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLError.h:12:
In file included from <module-includes>:1:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h:18:10: fatal error: could not build module 'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
 ~~~~~~~~^
In file included from /Users/berhart/workspace/gp/Tor.framework/Tor/TORNode.m:8:
/Users/berhart/workspace/gp/Tor.framework/Tor/TORNode.h:8:9: fatal error: could not build module 'Foundation'
#import <Foundation/Foundation.h>
 ~~~~~~~^
13 errors generated.
Command AnalyzeShallow failed with a nonzero exit code

@chrisballinger Any ideas on this?

Same with newest Tor 0.4.2.6 and 0.4.1.8.

@tladesignz Are you able to compile CPAProxy w/ the latest Tor versions?

Thanks for that idea, @chrisballinger, I'll have a look at it!

@chrisballinger, CPAProxy's build-all script runs with latest versions (Tor 0.4.2.5, OpenSSL 1.1.1d and libevent 2.1.11)
But of course, the Objective-C glue code comes in only afterwards here. (Which is, where my problems lie.)

So I added CPAProxy as a dependency to a test project. First I tried with the original versions:

Undefined symbols for architecture arm64:
  "_inflateEnd", referenced from:
      _tor_zlib_compress_free_ in libtor-compress.a(compress_zlib.o)
  "_deflate", referenced from:
      _tor_zlib_compress_process in libtor-compress.a(compress_zlib.o)
  "_inflate", referenced from:
      _tor_zlib_compress_process in libtor-compress.a(compress_zlib.o)
  "_zlibVersion", referenced from:
      _tor_zlib_get_version_str in libtor-compress.a(compress_zlib.o)
  "_deflateInit2_", referenced from:
      _tor_zlib_compress_new in libtor-compress.a(compress_zlib.o)
  "_deflateEnd", referenced from:
      _tor_zlib_compress_free_ in libtor-compress.a(compress_zlib.o)
  "_inflateInit2_", referenced from:
      _tor_zlib_compress_new in libtor-compress.a(compress_zlib.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Does this thing run at all, in the state it currently is?

I had to replace this:
https://github.com/ursachec/CPAProxy/blob/ee5e827e82275ac80a9153fcbd4209db37fe84ba/CPAProxy/GCDAsyncSocket%2BCPAProxy.h#L9

with this:

#import <CocoaAsyncSocket/GCDAsyncSocket.h>

Otherwise wouldn't start compiling at all.

@tladesignz You just gotta link libz to fix those linker errors. Please check out the marzipan branch not master: https://github.com/ursachec/CPAProxy/tree/marzipan which eliminates the dependency on CocoaAsyncSocket. However I'm not sure if the new Network.framework code written for the control socket is functional, which is why I have Tor disabled in ChatSecure v5.0. It compiles and links just fine though.

Man, that's so annoying. Not everyone is on MacOS 10.15, already. Mostly because it's so shitty.

10.15 ain't so bad now, unless you've got some ancient 32-bit programs as part of your daily workflow. ;)

So, I finally gave in and installed Catalina. I could compile CPAProxy with the marzipan branch. And I don't get this error there.

Reason is: the wrapping layer of CPAProxy around Tor is much thinner. So there's no code, where Tor and Objective-C code using CFStream is used together.

I don't see what I could learn from that, now. :-/

Next steps:

  • Find lowest Tor version which doesn't work.
  • Get into git bisect.

@nmathewson found the problem.
I just did a new release containing Tor 0.4.2.7. Yay!