-
Notifications
You must be signed in to change notification settings - Fork 481
Description
| Previous ID | SR-2205 |
| Radar | rdar://problem/34535228 |
| Original Reporter | mominul (JIRA User) |
| Type | Bug |
Attachment: Download
Environment
DEVELOPMENT-SNAPSHOT-2016-07-25
Ubuntu 16.04
Additional Detail from JIRA
| Votes | 15 |
| Component/s | libdispatch |
| Labels | Bug, Linux |
| Assignee | None |
| Priority | Medium |
md5: 76b3df295dd2c0f2cbc48f0a20b3a982
is duplicated by:
- SR-6434 libdispatch.a missing on Linux
relates to:
Issue Description:
I come across of this situation when I was trying to compile my code as statically linked with stdlib.
If I compile my code without importing Foundation with -static-stdlib flag, the compilation succeeds.
But the actual error occurs when I try to import Foundation. As the linker fails when linking with Foundation.
/usr/bin/ld.gold: error: cannot find -lFoundation
/tmp/main-0993c4.o:/tmp/main-0993c4.o:function main: error: undefined reference to '_TMaC10Foundation8NSString'
/tmp/main-0993c4.o:/tmp/main-0993c4.o:function main: error: undefined reference to 'TFC10Foundation8NSStringCfT13stringLiteralVs12StaticString_S0'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
As I tried to inspect the error with my little knowledge, here is the fact that took my attention:
-
Without the `-static-stdlib` flag the library search path is set as
/path/to/swift/usr/lib/swift/linuxwhere the shared libraries are stored including Foundation. -
But with the `-static-stdlib` flag the library search path is set as
/path/to/swift/usr/lib/swift_static/linuxwhere the static libraries are stored excluding Foundation.
So linker is innocent!
Can it be solved by adding statically linked copy of Foundation?
So is there any solutions? Can I compile my code statically linked with stdlib and Foundation?
To reproduce it, is very easy
import Glibc
//import Foundation
//var str: NSString = "Hello"
//print(str)
print("Hello, world!")
exit(1)
Thanks!