Skip to content

Set up a client-side C library to talk with C APIs exposed from the compiler #381

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

Merged
merged 1 commit into from
Dec 3, 2020

Conversation

nkcsgexi
Copy link
Contributor

@nkcsgexi nkcsgexi commented Dec 2, 2020

We could use functions like dlopen and dlsym in this client-side library to talk with
compiler-side C APIs.

@nkcsgexi
Copy link
Contributor Author

nkcsgexi commented Dec 2, 2020

@swift-ci please test

@nkcsgexi nkcsgexi requested a review from artemcm December 2, 2020 22:50
@cltnschlosser
Copy link
Contributor

Is the idea to use this for llvm?

Copy link
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I try to build this with CMake, I get:

CMake Error at Sources/CMakeLists.txt:9 (add_subdirectory):                                                                                                                                                                              The source directory                                                                                                                                                                                                                                                                                                                                                                                                                                                            /Volumes/Data/GHWorkspace1/swift-driver/Sources/_CSwiftDriver/src

  does not contain a CMakeLists.txt file.

Is there perhaps a file missing from this PR?
This target's CMakeLists should define it as a library, and we need to take care to link it in statically when building libSwiftDriver to avoid having to install another shared library into the toolchain.

@artemcm
Copy link
Contributor

artemcm commented Dec 3, 2020

Is the idea to use this for llvm?

@cltnschlosser, something like this will be an example of where this is useful:
swiftlang/swift#34786

@nkcsgexi
Copy link
Contributor Author

nkcsgexi commented Dec 3, 2020

@cltnschlosser, this is to allow libSwiftDriver to talk with Swift compiler from different toolchains. In that case, we cannot statically link against libraries vendored from a compiler. We need to rely on C APIs like dlopen and dlsym to load dylibs dynamically.

@nkcsgexi
Copy link
Contributor Author

nkcsgexi commented Dec 3, 2020

@artemcm hmm, will take a look at the cmake issue.

@tschuett
Copy link

tschuett commented Dec 3, 2020

@nkcsgexi
Copy link
Contributor Author

nkcsgexi commented Dec 3, 2020

@tschuett yeah, refactoring those pieces seem to me a good idea. Regardless of whether we need to invoke dlopen in C, we still need to set up this C target to host those compiler headers for the dependencies scanning library.

@tschuett
Copy link

tschuett commented Dec 3, 2020

No worries. You are missing some newlines at the end of files in a couple of places.

…ompiler

We could use functions like dlopen and dlsym in this client-side library to talk with
compiler-side C APIs.
@nkcsgexi
Copy link
Contributor Author

nkcsgexi commented Dec 3, 2020

@swift-ci please test

@nkcsgexi nkcsgexi merged commit aa87d8d into swiftlang:main Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants