# problems with linking .tbd frameworks in test suite

**URL:** <https://forums.swift.org/t/problems-with-linking-tbd-frameworks-in-test-suite/384>\
**Category:** Compiler\
**Created:** [December 10, 2015, 5:10am UTC](https://forums.swift.org/t/problems-with-linking-tbd-frameworks-in-test-suite/384 "2015-12-10T05:10:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Lew](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@Alex\_Lew](https://forums.swift.org/u/Alex_Lew)\
**Post date:** [December 10, 2015, 5:10am UTC](https://forums.swift.org/t/problems-with-linking-tbd-frameworks-in-test-suite/384/1 "2015-12-10T05:10:56Z")

</div>

Hi all,

Apologies if this is not the right place to ask this.

I built Swift successfully today, but was failing lots of tests because the  
linker couldn't find CoreFoundation (or other frameworks, including  
libsystem and libobjc). It looks like ld was invoked with the arguments:

-syslibroot  
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk

The MacOSX10.11.sdk/usr/lib directory \*did\* have the desired  
libraries/frameworks in it, but they had the extension .tbd, not .dylib,  
and I think that confused the linker. I commented out the following lines  
from swift/lib/Driver/ToolChains.cpp:

&nbsp;&nbsp;if (!context.OI.SDKPath.empty()) {  
&nbsp;&nbsp;&nbsp;&nbsp;Arguments.push\_back("-syslibroot");  
&nbsp;&nbsp;&nbsp;&nbsp;Arguments.push\_back(context.Args.MakeArgString(context.OI.SDKPath));  
&nbsp;&nbsp;}

(lines 915-918), reran util/build-script -t, and everything started working  
(presumably because the linker was now searching in /usr/lib, where the  
dylib files are).

I'm curious to understand what was going on here. Should I have been using  
a different version of ld? Configured something else differently? I'm in a  
little over my head.

Thank you!

-Alex

---

<div class="post-metadata">

**Author:** ![ddunbar](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ddunbar/32/1933_2.png) [@ddunbar](https://forums.swift.org/u/ddunbar)\
**Post date:** [December 10, 2015, 5:25am UTC](https://forums.swift.org/t/problems-with-linking-tbd-frameworks-in-test-suite/384/2 "2015-12-10T05:25:57Z")

</div>

What version of ld are you using? (ld -v)

If you have .tbd files in your SDK, then the ld that shipped with that version of Xcode should be capable of using them to link. The tools should be using that version of ld by default, but it is possible something is going wrong.

If might help to run the command that is failing with "-v", and include the full command and its errors.

- Daniel

> **···**
>
> > On Dec 9, 2015, at 9:10 PM, Alex Lew via swift-dev \<swift-dev@swift.org\> wrote:
> > 
> > Hi all,
> > 
> > Apologies if this is not the right place to ask this.
> > 
> > I built Swift successfully today, but was failing lots of tests because the linker couldn't find CoreFoundation (or other frameworks, including libsystem and libobjc). It looks like ld was invoked with the arguments:
> > 
> > -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
> > 
> > The MacOSX10.11.sdk/usr/lib directory did have the desired libraries/frameworks in it, but they had the extension .tbd, not .dylib, and I think that confused the linker. I commented out the following lines from swift/lib/Driver/ToolChains.cpp:
> > 
> > &nbsp;&nbsp;if (!context.OI.SDKPath.empty()) {  
> > &nbsp;&nbsp;&nbsp;&nbsp;Arguments.push\_back("-syslibroot");  
> > &nbsp;&nbsp;&nbsp;&nbsp;Arguments.push\_back(context.Args.MakeArgString(context.OI.SDKPath));  
> > &nbsp;&nbsp;}
> > 
> > (lines 915-918), reran util/build-script -t, and everything started working (presumably because the linker was now searching in /usr/lib, where the dylib files are).
> > 
> > I'm curious to understand what was going on here. Should I have been using a different version of ld? Configured something else differently? I'm in a little over my head.
> > 
> > Thank you!
> > 
> > -Alex  
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-dev mailing list  
> > swift-dev@swift.org  
> > [https://lists.swift.org/mailman/listinfo/swift-dev](https://lists.swift.org/mailman/listinfo/swift-dev)

---

<div class="post-metadata">

**Author:** ![Alex\_Lew](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@Alex\_Lew](https://forums.swift.org/u/Alex_Lew)\
**Post date:** [December 10, 2015, 5:51am UTC](https://forums.swift.org/t/problems-with-linking-tbd-frameworks-in-test-suite/384/3 "2015-12-10T05:51:00Z")

</div>

Gahh... yep, turns out I was using an old MacPorts version of ld. I thought  
I'd cleared out gcc, ld, etc. from /opt/local/bin a while ago, but I guess  
not. Should have been my first thought. Thanks! And sorry for bothering!

-Alex

> **···**
>
> On Thu, Dec 10, 2015 at 12:25 AM, Daniel Dunbar \<daniel\_dunbar@apple.com\> wrote:
> 
> > What version of ld are you using? (ld -v)
> > 
> > If you have .tbd files in your SDK, then the ld that shipped with that  
> > version of Xcode should be capable of using them to link. The tools should  
> > be using that version of ld by default, but it is possible something is  
> > going wrong.
> > 
> > If might help to run the command that is failing with "-v", and include  
> > the full command and its errors.
> > 
> > - Daniel
> > 
> > On Dec 9, 2015, at 9:10 PM, Alex Lew via swift-dev \< swift-dev@swift.org\> \> wrote:
> > 
> > Hi all,
> > 
> > Apologies if this is not the right place to ask this.
> > 
> > I built Swift successfully today, but was failing lots of tests because  
> > the linker couldn't find CoreFoundation (or other frameworks, including  
> > libsystem and libobjc). It looks like ld was invoked with the arguments:
> > 
> > -syslibroot  
> > /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
> > 
> > The MacOSX10.11.sdk/usr/lib directory \*did\* have the desired  
> > libraries/frameworks in it, but they had the extension .tbd, not .dylib,  
> > and I think that confused the linker. I commented out the following lines  
> > from swift/lib/Driver/ToolChains.cpp:
> > 
> > &nbsp;&nbsp;if (!context.OI.SDKPath.empty()) {  
> > &nbsp;&nbsp;&nbsp;&nbsp;Arguments.push\_back("-syslibroot");  
> > &nbsp;&nbsp;&nbsp;&nbsp;Arguments.push\_back(context.Args.MakeArgString(context.OI.SDKPath));  
> > &nbsp;&nbsp;}
> > 
> > (lines 915-918), reran util/build-script -t, and everything started  
> > working (presumably because the linker was now searching in /usr/lib, where  
> > the dylib files are).
> > 
> > I'm curious to understand what was going on here. Should I have been using  
> > a different version of ld? Configured something else differently? I'm in a  
> > little over my head.
> > 
> > Thank you!
> > 
> > -Alex  
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-dev mailing list  
> > swift-dev@swift.org  
> > [https://lists.swift.org/mailman/listinfo/swift-dev](https://lists.swift.org/mailman/listinfo/swift-dev)
