Skip to content

[SR-2280] swiftc -static-stdlib option fails on Ubuntu 14.04 & 15.10 #44887

@abertelrud

Description

@abertelrud
Previous ID SR-2280
Radar None
Original Reporter @abertelrud
Type Bug
Status Resolved
Resolution Done
Environment

Ubuntu 14.04, Ubuntu 15.10

Additional Detail from JIRA
Votes 4
Component/s Compiler
Labels Bug
Assignee @spevans
Priority Medium

md5: 12b3c71761ce9762d3e3755bd28b44eb

blocks:

  • SR-648 swift package manager should have the option to produce statically linked binaries

relates to:

  • SR-648 swift package manager should have the option to produce statically linked binaries
  • SR-730 Flag to statically link Swift standard library
  • SR-1520 Create Static Libraries with Swift

Issue Description:

The `-static-stdlib` option fails on Ubuntu 14.04 and on 15.10 (on macOS it works). This is using the latest nightly toolchain (`LLVM 3a878c6fdb, Clang cb02d1caed, Swift 8436ef8`).

To reproduce:

echo 'print("hello")' > main.swift
swiftc -static-stdlib main.swift -o main

The result is this:

<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
user@ubuntu:/var/tmp/Static$ ^C
user@ubuntu:/var/tmp/Static$ swiftc -static-stdlib main.swift
/usr/bin/ld: cannot find -lbsd
/usr/bin/ld: cannot find -licui18n
/usr/bin/ld: cannot find -licuuc
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)

Passing `-v` yields this:

Swift version 3.0-dev (LLVM 3a878c6fdb, Clang cb02d1caed, Swift 8436ef8993)
Target: x86_64-unknown-linux-gnu
/home/user/Documents/usr/bin/swift -frontend -c -primary-file main.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -module-name main -o /tmp/main-58b97c.o
/home/user/Documents/usr/bin/swift-autolink-extract /tmp/main-58b97c.o -o /tmp/main-f05ff6.autolink
/usr/bin/clang++ -fuse-ld=gold -target x86_64-unknown-linux-gnu -Xlinker -rpath -Xlinker /home/user/Documents/usr/lib/swift/linux /home/user/Documents/usr/lib/swift/linux/x86_64/swift_begin.o /tmp/main-58b97c.o -L /home/user/Documents/usr/lib/swift_static/linux -ldl -lpthread -lbsd -licui18n -licuuc -Xlinker -export-dynamic -Xlinker --exclude-libs -Xlinker ALL --target=x86_64-unknown-linux-gnu -lswiftCore @/tmp/main-f05ff6.autolink /home/user/Documents/usr/lib/swift/linux/x86_64/swift_end.o -o main
/usr/bin/ld: cannot find -lbsd
/usr/bin/ld: cannot find -licui18n
/usr/bin/ld: cannot find -licuuc
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)

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions