Giter Site home page Giter Site logo

Release builds busted about swift-protobuf HOT 8 CLOSED

apple avatar apple commented on September 7, 2024
Release builds busted

from swift-protobuf.

Comments (8)

thomasvl avatar thomasvl commented on September 7, 2024

Linking SwiftProtobufTestSuite_iOS

Undefined symbols for architecture i386:
  "(extension in SwiftProtobuf):SwiftProtobuf.ProtobufWrapper.init (A.WrappedType.BaseType) -> A", referenced from:
      SwiftProtobufTestSuite_iOS.Test_Api.testInitializer () -> () in Test_Api.o
      SwiftProtobufTestSuite_iOS.Test_Conformance.(testRepeatedBoolWrapper () -> ()).(closure #1) in Test_Conformance.o
      SwiftProtobufTestSuite_iOS.Test_Conformance.(testRepeatedBoolWrapper () -> ()).(closure #2) in Test_Conformance.o
      SwiftProtobufTestSuite_iOS.Test_Wrappers.testDoubleValue () throws -> () in Test_Wrappers.o
      SwiftProtobufTestSuite_iOS.Test_Wrappers.testFloatValue () throws -> () in Test_Wrappers.o
      SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #11) in Test_Wrappers.o
      SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #13) in Test_Wrappers.o
      ...
  "protocol witness table for SwiftProtobuf.Google_Protobuf_BoolValue : SwiftProtobuf.ProtobufWrapper in SwiftProtobuf", referenced from:
      SwiftProtobufTestSuite_iOS.Test_Conformance.(testRepeatedBoolWrapper () -> ()).(closure #1) in Test_Conformance.o
      SwiftProtobufTestSuite_iOS.Test_Conformance.(testRepeatedBoolWrapper () -> ()).(closure #2) in Test_Conformance.o
  "protocol witness table for SwiftProtobuf.Google_Protobuf_FloatValue : SwiftProtobuf.ProtobufWrapper in SwiftProtobuf", referenced from:
      SwiftProtobufTestSuite_iOS.Test_Wrappers.testFloatValue () throws -> () in Test_Wrappers.o
  "protocol witness table for SwiftProtobuf.Google_Protobuf_DoubleValue : SwiftProtobuf.ProtobufWrapper in SwiftProtobuf", referenced from:
      SwiftProtobufTestSuite_iOS.Test_Wrappers.testDoubleValue () throws -> () in Test_Wrappers.o
  "protocol witness table for SwiftProtobuf.Google_Protobuf_StringValue : SwiftProtobuf.ProtobufWrapper in SwiftProtobuf", referenced from:
      SwiftProtobufTestSuite_iOS.Test_Api.testInitializer () -> () in Test_Api.o
      SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #11) in Test_Wrappers.o
      SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #13) in Test_Wrappers.o
      SwiftProtobufTestSuite_iOS.Test_Api.testInitializer () -> () in Test_Api.o
      SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #11) in Test_Wrappers.o
      SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #13) in Test_Wrappers.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

from swift-protobuf.

thomasvl avatar thomasvl commented on September 7, 2024

repeats for both macOS and iOS release builds.

from swift-protobuf.

allevato avatar allevato commented on September 7, 2024

At first glance, this looks like a potential compiler/linker bug to me, where it's possibly getting confused because we have external code (the test module) trying to call an initializer that's defined on an internal protocol, even though the initializer is re-declared public in the extension where the default is implemented.

One way to test it would be to move the public init(_ value: WrappedType.BaseType) impl into the individual wrapper extensions to see if that fixes the visibility issue.

Will investigate further.

from swift-protobuf.

allevato avatar allevato commented on September 7, 2024

Confirmed: adding the initializer into the concrete wrapper type instead of the protocol extension fixes the issue. I'll have a PR shortly that copies the initializer into each of the concrete types; unfortunately this will create a small amount of duplication in the runtime library.

I'll see if I can isolate this into a small example that can be submitted as a Swift bug. My understanding is that one of two things should be happening here:

  1. Designating a method as public on an extension of an internal protocol should be allowed and the linker should be able to see that method when resolving calls from externally linked code.
  2. Designating a method as public on an extension of an internal protocol should not be allowed and the compiler should flag this as an error before it ever gets to the linker.

Presumably this only occurs on release builds due to stripping or optimization settings that reduce the visibility of certain symbols.

from swift-protobuf.

thomasvl avatar thomasvl commented on September 7, 2024

Thanks. Lets make sure we track (maybe make a label for them and open issues for tracking them) these sort things (that are possibly compiler bugs). I'm a little worried about making sure we under stand them as if they are settings related, this could show up multiple times (the checked in project, CocoaPods generated projects, Swift package manager).

from swift-protobuf.

allevato avatar allevato commented on September 7, 2024

I've filed https://bugs.swift.org/browse/SR-2925 about this to see if what we were trying to do should be allowed.

from swift-protobuf.

yoiang avatar yoiang commented on September 7, 2024

@allevato can you clarify your temporary fix? I am running into what looks like a similar issue, when I reference one of my generated classes' (GTFS) initializers I am getting linking errors:

Undefined symbols for architecture x86_64:
  "default argument 1 of (extension in SwiftProtobuf):SwiftProtobuf.Message.init(serializedData: Foundation.Data, extensions: SwiftProtobuf.ExtensionMap?, partial: Swift.Bool, options: SwiftProtobuf.BinaryDecodingOptions) throws -> A", referenced from:
      GTFSRealtimeKitTests.GTFSRealtimeBindingsTests.testGTFSRealtimeAPI_FeedMessage_decode() -> () in gtfs-realtime.pb.o
  "default argument 2 of (extension in SwiftProtobuf):SwiftProtobuf.Message.init(serializedData: Foundation.Data, extensions: SwiftProtobuf.ExtensionMap?, partial: Swift.Bool, options: SwiftProtobuf.BinaryDecodingOptions) throws -> A", referenced from:
      GTFSRealtimeKitTests.GTFSRealtimeBindingsTests.testGTFSRealtimeAPI_FeedMessage_decode() -> () in gtfs-realtime.pb.o
  "default argument 3 of (extension in SwiftProtobuf):SwiftProtobuf.Message.init(serializedData: Foundation.Data, extensions: SwiftProtobuf.ExtensionMap?, partial: Swift.Bool, options: SwiftProtobuf.BinaryDecodingOptions) throws -> A", referenced from:
      GTFSRealtimeKitTests.GTFSRealtimeBindingsTests.testGTFSRealtimeAPI_FeedMessage_decode() -> () in gtfs-realtime.pb.o
  "(extension in SwiftProtobuf):SwiftProtobuf.Message.init(serializedData: Foundation.Data, extensions: SwiftProtobuf.ExtensionMap?, partial: Swift.Bool, options: SwiftProtobuf.BinaryDecodingOptions) throws -> A", referenced from:
      GTFSRealtimeKitTests.GTFSRealtimeBindingsTests.testGTFSRealtimeAPI_FeedMessage_decode() -> () in gtfs-realtime.pb.o
ld: symbol(s) not found for architecture x86_64

from swift-protobuf.

allevato avatar allevato commented on September 7, 2024

The fix I describe above was solely internal to the runtime library, so it shouldn't be affecting any user code. The tl;dr is that I defined an internal protocol and a default implementation of a method in that protocol so I could share its implementation across all conformers. I made that method public because I wanted it to be exposed without exposing the protocol itself. That visibility mixing shouldn't have been allowed, and in release builds, the method wasn't visible.

Are you doing a debug or release build? Is this something that worked before but stopped working with a newer release, or is this the first time you're trying it? Any additional information would be helpful.

from swift-protobuf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.