This is an archive of the discontinued LLVM Phabricator instance.

[cmake] Link socket/nsl on SunOS in llvm-jitlink
ClosedPublic

Authored by nikic on Feb 28 2021, 9:31 AM.

Details

Summary

llvm-jitlink and llvm-jitlink-executor make use of APIs that are part of the socket and nsl libraries on SunOS systems (Solaris and Illumos). Make sure they get linked.

Ran into this in Rust CI when cross-compiling LLVM 12 to these targets.

My cmake-foo is rather weak, so I took inspiration from this check for SunOS: https://github.com/llvm/llvm-project/blob/ca5247bb1770a1dfa56b78303d99f1cc9a0a06ee/llvm/utils/benchmark/src/CMakeLists.txt#L43-L45

Diff Detail

Event Timeline

nikic created this revision.Feb 28 2021, 9:31 AM
nikic requested review of this revision.Feb 28 2021, 9:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2021, 9:31 AM
llvm/tools/llvm-jitlink/CMakeLists.txt
28

Are socket and nsl libraries standard and always available, or should we check for them?

llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt
14

debug leftover?

nikic updated this revision to Diff 327141.Mar 1 2021, 9:18 AM

Remove debug code

nikic marked an inline comment as done.Mar 1 2021, 9:31 AM
nikic added inline comments.
llvm/tools/llvm-jitlink/CMakeLists.txt
28

For Solaris-like systems, I believe so. The closest to official documentation on the topic I found is that Oracle man pages list -lsocket -lnsl for socket-related APIs: https://docs.oracle.com/cd/E86824_01/html/E54774/socket-3socket.html

I originally used find_library() but then switched to checking the system after seeing that we already have a couple of checks like this.

llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt
14

Ooops, indeed :)

LGTM then, obviously I trust you on the portability aspect ;-)

This revision is now accepted and ready to land.Mar 9 2021, 12:15 AM
This revision was automatically updated to reflect the committed changes.
nikic marked an inline comment as done.