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-8897] libdispatch is underlinked - it does not link libswiftCore #648

Closed
kevints mannequin opened this issue Oct 2, 2018 · 5 comments
Closed

[SR-8897] libdispatch is underlinked - it does not link libswiftCore #648

kevints mannequin opened this issue Oct 2, 2018 · 5 comments

Comments

@kevints
Copy link
Mannequin

kevints mannequin commented Oct 2, 2018

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

Swift 4.2-RELEASE
Ubuntu 14.04

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

md5: d0ae55b32dda9f738148fca4ddf298c6

Issue Description:

the libdispatch shared library shipped with swift-4.2-RELEASE references symbols defined by the swift runtime, for example:

root@1c33bbf3ea71:/code/build/Ninja-DebugAssert/libdispatch-linux-x86_64# readelf -W --dyn-syms /code/swift-4.2-RELEASE-ubuntu14.04/usr/lib/swift/linux/libdispatch.so | grep -E '(swift_alloc)'
   246: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND swift_allocObject
   247: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND swift_allocateGenericClassMetadata

However, it does not link to the swift runtime (we'd expect a NEEDED: libswiftCore.so) in this list:

$ readelf -d /code/swift-4.2-RELEASE-ubuntu14.04/usr/lib/swift/linux/libdispatch.so

Dynamic section at offset 0x8baf0 contains 33 entries:
  Tag        Type                         Name/Value
 0x0000000000000003 (PLTGOT)             0x8cfe8
 0x0000000000000002 (PLTRELSZ)           5976 (bytes)
 0x0000000000000017 (JMPREL)             0x31110
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000007 (RELA)               0x12798
 0x0000000000000008 (RELASZ)             125304 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffff9 (RELACOUNT)          5011
 0x0000000000000006 (SYMTAB)             0x200
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000005 (STRTAB)             0x6680
 0x000000000000000a (STRSZ)              40672 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x10560
 0x0000000000000001 (NEEDED)             Shared library: [libbsd.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]
 0x000000000000000e (SONAME)             Library soname: [libdispatch.so]
 0x000000000000000c (INIT)               0x32868
 0x000000000000000d (FINI)               0x60804
 0x000000000000001a (FINI_ARRAY)         0x71348
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x0000000000000019 (INIT_ARRAY)         0x71350
 0x000000000000001b (INIT_ARRAYSZ)       16 (bytes)
 0x000000006ffffff0 (VERSYM)             0x11de8
 0x000000006ffffffc (VERDEF)             0x12648
 0x000000006ffffffd (VERDEFNUM)          1
 0x000000006ffffffe (VERNEED)            0x12664
 0x000000006fffffff (VERNEEDNUM)         5
 0x0000000000000000 (NULL)               0x0

This seems to be related to the structure of the dispatch build system. It uses the host C++ compiler to link libdispatch, rather than swiftc -emit-library [1] and as such omits swiftCore (and swiftOnoneSupport in debug builds).

[1] https://github.com/apple/swift-corelibs-libdispatch/blob/swift-4.2-RELEASE/src/CMakeLists.txt#L95

@belkadan
Copy link

belkadan commented Oct 2, 2018

Hm, I though libdispatch.so deliberately only included the C stuff, and then there was still a separate libswiftDispatch.so. Am I misremembering? cc dgrove-oss (JIRA User)

@kevints
Copy link
Mannequin Author

kevints mannequin commented Oct 2, 2018

On Linux there's currently no separate libswiftDispatch.so (but @compnerd and I are discussing on apple/swift#19640 (review) that there probably should be). But as released libdispatch.so depends on swiftCore without linking it.

@swift-ci
Copy link

swift-ci commented Oct 2, 2018

Comment by David Grove (JIRA)

I don't remember exactly why we did it this way. I vaguely remember there were some circular build dependencies because some step in building swiftCore actually depended on the C-level dispatch library. Maybe in the last two years that has been untangled (or the dependencies are more explicit, so understandable to CMake now that the build has switched to being driven by CMake)? phabouzit (JIRA User) might remember.

@compnerd
Copy link
Collaborator

I think that we can close this as swift and swiftDispatch are separate entities now.

@compnerd
Copy link
Collaborator

Resolving this as I believe it is fixed. If not, please reopen.

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

No branches or pull requests

3 participants