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-4821] libdispatch.so should contain a NEEDED load command for libswiftCore.so #691

Closed
keith opened this issue May 7, 2017 · 3 comments

Comments

@keith
Copy link

keith commented May 7, 2017

Previous ID SR-4821
Radar None
Original Reporter @keith
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s libdispatch
Labels Bug, Linux
Assignee None
Priority Medium

md5: c0f02d6d8953def87cb00eb74a8a6601

Issue Description:

Currently if you build libdispatch.so on Linux, the resulting binary does not contain the `RUNPATH` or `NEEDED` commands necessary for loading libswiftCore.so. This
results in scripts loading libdispatch.so crashing at runtime for undefined symbols.

This is not a problem if you're using Swift, and link libswiftCore regardless, but for binaries that are dlopening libdispatch, or just don't care about the implementation details of it, this is required for them to work correctly.

To reproduce this using Docker, run these commands:

$ docker pull swift:3.1
$ docker run -it swift:3.1 /bin/bash
# python -c 'import ctypes; ctypes.CDLL("/usr/lib/swift/linux/libdispatch.so")'

By running this you will see this crash:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/ctypes/__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/swift/linux/libdispatch.so: undefined symbol: _TMSV

You can also see that this doesn't happen if you pass libswiftCore with `LD_PRELOAD`:

# LD_PRELOAD=/usr/lib/swift/linux/libswiftCore.so python -c 'import ctypes; ctypes.CDLL("/usr/lib/swift/linux/libdispatch.so")'
@keith
Copy link
Author

keith commented Feb 8, 2018

This is still the case with Swift 4.0.3

@kevints
Copy link
Mannequin

kevints mannequin commented Nov 15, 2018

@compnerd you fixed this on master yeah?

@compnerd
Copy link
Collaborator

@kevints, yeah, I believe that this should be fixed.

@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

2 participants