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-83] Can't link to UUID library #5334

Closed
colemancda opened this issue Dec 6, 2015 · 8 comments
Closed

[SR-83] Can't link to UUID library #5334

colemancda opened this issue Dec 6, 2015 · 8 comments
Labels

Comments

@colemancda
Copy link

Previous ID SR-83
Radar None
Original Reporter @colemancda
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Ubuntu 14.04 VMWare Fusion

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: e3676bcb79fba0363bae0879a54c8e91

Issue Description:

I cannot link to the UUID library despite installing uuid-dev package.

Proposed fix:

I believe I know what the problem is. The SPM (Swift Package Manager) seems to be linking against libraries in /usr/lib. The UUID library in Ubuntu 14.04 is in /usr/lib/x86-linux-gnu/libuuid.so. The fix for this has to be either in Swift, under the Glibc module, or in the SPM.

Log:

coleman@ubuntu:~/Swift/SwiftFoundationExample$ swift build
Compiling Swift Module 'SwiftFoundationExample' (1 sources)
Linking Executable: .build/debug/SwiftFoundationExample
/home/coleman/Swift/SwiftFoundationExample/.build/debug/SwiftFoundation.a(POSIXUUID.swift.o): In function `TFF15SwiftFoundation21POSIXUUIDCreateRandomFT_TVs5UInt8S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0U_FGSpTS0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0T*':
/home/coleman/Swift/SwiftFoundationExample/Packages/SwiftFoundation-1.0.1/Sources/POSIXUUID.swift:35: undefined reference to `uuid_generate'
/home/coleman/Swift/SwiftFoundationExample/.build/debug/SwiftFoundation.a(POSIXUUID.swift.o): In function `TFF15SwiftFoundation28POSIXUUIDConvertToUUIDStringFTVs5UInt8S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0TVs4Int8S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1U_FTGSpTS0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0GSpTS1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1_S1*_T':
/home/coleman/Swift/SwiftFoundationExample/Packages/SwiftFoundation-1.0.1/Sources/POSIXUUID.swift:60: undefined reference to `uuid_unparse'
/home/coleman/Swift/SwiftFoundationExample/.build/debug/SwiftFoundation.a(POSIXUUID.swift.o): In function `TF15SwiftFoundation28POSIXUUIDConvertStringToUUIDFSSGSqTVs5UInt8S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0_S0
_':
/home/coleman/Swift/SwiftFoundationExample/Packages/SwiftFoundation-1.0.1/Sources/POSIXUUID.swift:85: undefined reference to `uuid_parse'
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)
<unknown>:0: error: build had 1 command failures
swift-build: exit(1): ["/home/coleman/Swift/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/bin/swift-build-tool", "-f", "/home/coleman/Swift/SwiftFoundationExample/.build/debug/SwiftFoundationExample.o/llbuild.yaml"]

@colemancda
Copy link
Author

I believe I know what the problem is. The SPM (Swift Package Manager) seems to be linking against libraries in /usr/lib. The UUID library in Ubuntu 14.04 is in /usr/lib/x86-linux-gnu/libuuid.so. The fix for this has to be either in Swift, under the Glibc module, or in the SPM.

@colemancda
Copy link
Author

So fixing the issue at the Swift level has been declined apple/swift#276

This only leaves fixing it at the Package manager level. The issue seems to be that my module is linking against the libuuid library. The only problem is that /usr/local/lib is set as the Library Search Path. I believe that if I could somehow set /usr/local/lib/x86_64-linux-gnu as an additional search path, the example executable would link and compile correctly.

@mxcl
Copy link
Contributor

mxcl commented Dec 7, 2015

/cc @ddunbar

@mxcl
Copy link
Contributor

mxcl commented Dec 24, 2015

I'm working on a proposal for this problem. There are two other tickets open here too for this issue if you want to see some other discussion.

@colemancda
Copy link
Author

@mxcl Awesome! Can you give me links to the other discussions pls?

@drewcrawford
Copy link
Contributor

I've PRed a workaround for this issue, #107. If that PR is merged, we can say

otherLinkerOptions:["-L/usr/lib/x86-linux-gnu/"]

to work around this bug.

@ddunbar
Copy link
Member

ddunbar commented Apr 30, 2016

I believe this was intended to be solved with the pkg-config work, can someone verify if it is?

@ankitspd
Copy link
Member

Using pkgConfig property in Package.swift resolves this issue. Here is the log from a sample package I tested on.

/home/ankit/swift.org/swiftpm/.build/debug/swiftc -module-name User -incremental -emit-dependencies -emit-module -emit-module-path /tmp/ankit/User/.build/debug/User.swiftmodule -output-file-map /tmp/ankit/User/.build/debug/User.build/output-file-map.json -num-threads 8 -c /tmp/ankit/User/Sources/main.swift -I /tmp/ankit/User/.build/debug -j8 -D SWIFT_PACKAGE -Onone -g -enable-testing -Xcc -fmodule-map-file=/tmp/ankit/User/Packages/UUID-1.0.0/module.modulemap -Xcc -I/usr/include/uuid -L/usr/lib/x86_64-linux-gnu -luuid -module-cache-path /tmp/ankit/User/.build/debug/ModuleCache

/home/ankit/swift.org/swiftpm/.build/debug/swiftc -Xlinker '-rpath=$ORIGIN' -g -L/tmp/ankit/User/.build/debug -o /tmp/ankit/User/.build/debug/User -emit-executable -Xcc -I/usr/include/uuid '-L/usr/lib/x86_64-linux-gnu' -luuid /tmp/ankit/User/.build/debug/User.build/main.swift.o

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

No branches or pull requests

5 participants