Closed seanliu1 closed 5 years ago
The latest version of Xcode does not seem to ship with a static version of the swift standard library as evident by this line:
[4/4] Linking ./.build/x86_64-apple-macosx/release/protoc-gen-swift
ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/macosx'
I can work around this issue by disabling static-stdlib in the Makefile
diff --git a/Makefile b/Makefile
index a5e699e..f7dd579 100644
--- a/Makefile
+++ b/Makefile
@@ -11,8 +11,8 @@ all:
cp .build/debug/protoc-gen-swiftgrpc .
plugin:
- swift build $(CFLAGS) --product protoc-gen-swift -c release -Xswiftc -static-stdlib
- swift build $(CFLAGS) --product protoc-gen-swiftgrpc -c release -Xswiftc -static-stdlib
+ swift build $(CFLAGS) --product protoc-gen-swift -c release
+ swift build $(CFLAGS) --product protoc-gen-swiftgrpc -c release
Not sure if this is expected, an omission, or the location has moved
I ran into the same problem, I redirected the compiled output to a file and found the following warning
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -L /Users/alpha/Code/grpc-swift/.build/x86_64-apple-macosx/release -o /Users/alpha/Code/grpc-swift/.build/x86_64-apple-macosx/release/protoc-gen-swift -module-name protoc_gen_swift -emit-executable @/Users/alpha/Code/grpc-swift/.build/x86_64-apple-macosx/release/protoc-gen-swift.product/Objects.LinkFileList -Xlinker -rpath -Xlinker /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -Xlinker -lz -Xcc -ISources/BoringSSL/include -static-stdlib
ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/macosx'
ld: warning: Could not find auto-linked library 'swiftFoundation'
ld: warning: Could not find auto-linked library 'swiftDarwin'
ld: warning: Could not find auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find auto-linked library 'swiftIOKit'
ld: warning: Could not find auto-linked library 'swiftCore'
ld: warning: Could not find auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find auto-linked library 'swiftObjectiveC'
ld: warning: Could not find auto-linked library 'swiftDispatch'
Undefined symbols for architecture x86_64:
...
...
...
ld: symbol(s) not found for architecture x86_64
See this similar issue in another repo https://github.com/bazelbuild/rules_swift/issues/162 Specifically the warning that was found
warning: Swift compiler no longer supports statically linking the Swift libraries. They're included in the OS by default starting with macOS Mojave 10.14.4 beta 3. For macOS Mojave 10.14.3 and earlier, there's an optional Swift library package that can be downloaded from "More Downloads" for Apple Developers at https://developer.apple.com/download/more/
See this similar issue in another repo bazelbuild/rules_swift#162 Specifically the warning that was found
warning: Swift compiler no longer supports statically linking the Swift libraries. They're included in the OS by default starting with macOS Mojave 10.14.4 beta 3. For macOS Mojave 10.14.3 and earlier, there's an optional Swift library package that can be downloaded from "More Downloads" for Apple Developers at https://developer.apple.com/download/more/
Hmm, I understand the reasoning behind this, but I guess it does make things more cumbersome for developers not on 10.14.4. I guess we could adjust our build script to only add the flag when using Swift 4, or just drop it altogether (maybe not now, but soon).
Would anybody be interested in preparing a small patch?
I think the same issue. https://github.com/apple/swift-protobuf/pull/852
Fix your Makefile
diff --git a/Makefile b/Makefile
index a5e699e..76e1a6c 100644
--- a/Makefile
+++ b/Makefile
@@ -11,8 +11,8 @@ all:
cp .build/debug/protoc-gen-swiftgrpc .
plugin:
- swift build $(CFLAGS) --product protoc-gen-swift -c release -Xswiftc -static-stdlib
- swift build $(CFLAGS) --product protoc-gen-swiftgrpc -c release -Xswiftc -static-stdlib
+ swift build $(CFLAGS) --product protoc-gen-swift --static-swift-stdlib -c release
+ swift build $(CFLAGS) --product protoc-gen-swiftgrpc --static-swift-stdlib -c release
cp .build/release/protoc-gen-swift .
cp .build/release/protoc-gen-swiftgrpc .
👍
New Issue Checklist
Issue Description
When I run
make plugin
, I get following error. I recently updated to Xcode to 10.2, and swift version is 5. Not sure they are relatedComplete output when running grpc-swift, including the stack trace and command used
Environment