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

[SR-14139] Undefined symbols for architecture x86_64 #312

Open
swift-ci opened this issue Feb 1, 2021 · 5 comments
Open

[SR-14139] Undefined symbols for architecture x86_64 #312

swift-ci opened this issue Feb 1, 2021 · 5 comments
Labels
bug swift-format SwiftSyntax

Comments

@swift-ci
Copy link

@swift-ci swift-ci commented Feb 1, 2021

Previous ID SR-14139
Radar rdar://problem/73832515
Original Reporter maticzav (JIRA User)
Type Bug
Environment

I am running this on 11.1 MacOS Big Sur with 12.0 XCode.

Additional Detail from JIRA
Votes 0
Component/s swift-format, SwiftSyntax
Labels Bug
Assignee None
Priority Medium

md5: 2fe2fd02d5afe157f55c9241f621b7e2

Issue Description:

Hi!

I hope this is not a silly question; how do you use this library inside another Swift library? I am maintaining a GraphQL client library that heavily relies on code generation. Since the code is mainly unformatted, I'd like to format it before writing it out on a disk.

I am trying to use `swift-format` (which relies on `swift-syntax`) and I am getting a strange error when using the library.

```

Undefined symbols for architecture x86_64:
"_$s11SwiftFormat0A9FormatterC13configuration16diagnosticEngineAC0aB13Configuration0G0V_0A6Syntax010DiagnosticF0CSgtcfC", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
"_$s11SwiftFormat0A9FormatterC6format6source15assumingFileURL2toySS_10Foundation0H0VSgxztKs16TextOutputStreamRzlF", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
"_$s11SwiftFormat0A9FormatterCMa", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
"_$s24SwiftFormatConfiguration0C0VACycfC", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
ld: symbol(s) not found for architecture x86_64

```

I've seen the note in swift-syntax's README that talks about linking the library, and I've found a similar issue (and its [fix|SwiftDocOrg/homebrew-formulae@af4cd47),)]), but the other libraries in the examples section in that README don't rely on any such script.

Can you help me? What am I doing wrong? What should I look at to understand the error message?

Thank you!

> I know this is not ideal, but you can find all the code in [SwiftGraphQL|https://github.com/maticzav/swift-graphql/tree/next]'s repo.

@typesanitizer
Copy link

@typesanitizer typesanitizer commented Feb 1, 2021

@swift-ci create

@benlangmuir
Copy link
Member

@benlangmuir benlangmuir commented Feb 2, 2021

@CodaFi
Copy link
Member

@CodaFi CodaFi commented Feb 2, 2021

Looks like SwiftFormat isn't actually in the link line. I just cloned this repo at `next` and the package builds successfully. Have you ensured that you have the proper package dependencies installed? Perhaps trying blowing away your package build directory and resetting package caches to re-pull these dependencies.

@allevato
Copy link
Collaborator

@allevato allevato commented Feb 2, 2021

It looks like the Package.swift in your next branch points to a different SwiftFormat (a community one, rather than the one at https://github.com/apple/swift-format). But the errors you've pasted above definitely refer to symbols in apple/swift-format and not the other one. Did you switch from one to the other but haven't updated the repo yet?

Since both projects export their API with the module name SwiftFormat, I wonder if somehow your project got into a weird state where it's compiling against the right symbols but somehow failing to find the right thing to link against. I agree with Robert that cleaning and/or resetting package caches is probably the first thing to try here.

@swift-ci
Copy link
Author

@swift-ci swift-ci commented Feb 3, 2021

Comment by Matic Zavadlal (JIRA)

Sorry for the trouble with commits. Indeed, we changed it because of the problems. This is the relevent [commit|maticzav/swift-graphql@8e0db37.] Note that the library builds itself. The issue arises when I try running Codegen script - when compiling the StarWars example.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug swift-format SwiftSyntax
Projects
None yet
Development

No branches or pull requests

5 participants