Skip to content

Use linker scripts instead of symlink. #472

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 3 commits into from
May 26, 2021
Merged

Conversation

diptorupd
Copy link
Contributor

@diptorupd diptorupd commented May 26, 2021

WIP non-functional implementation for linker scripts instead of symlinks. Needs more fixes, cleans up and checks for OS.

@oleksandr-pavlyk
Copy link
Contributor

Linker scripts can not self-reference. Python is not able to deal with chained linker scripts (.so referring to so.1 which refers to so.1.0).

This restricts us to use SOVERSION property to be the same as VERSION property.

With these changes:

diff --git a/dpctl-capi/CMakeLists.txt b/dpctl-capi/CMakeLists.txt
index bca778c..ca35369 100644
--- a/dpctl-capi/CMakeLists.txt
+++ b/dpctl-capi/CMakeLists.txt
@@ -155,20 +155,15 @@ get_version()
 set_target_properties(DPCTLSyclInterface
     PROPERTIES
         VERSION ${VERSION_MAJOR}.${VERSION_MINOR}
-        SOVERSION ${VERSION_MAJOR}
+        SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR}
 )

 set(linker_script1
-    "INPUT(libDPCTLSyclInterface.so libDPCTLSyclInterface.so.${VERSION_MAJOR})"
-)
-set(linker_script2
-    "INPUT(libDPCTLSyclInterface.so.${VERSION_MAJOR} libDPCTLSyclInterface.so.${VERSION_MAJOR}.${VERSION_MINOR})"
+    "INPUT(libDPCTLSyclInterface.so.${VERSION_MAJOR}.${VERSION_MINOR})"
 )
 add_custom_command(TARGET DPCTLSyclInterface POST_BUILD
     COMMAND "${CMAKE_COMMAND}" -E remove "libDPCTLSyclInterface.so"
     COMMAND "${CMAKE_COMMAND}" -E echo "${linker_script1}" > "libDPCTLSyclInterface.so"
-    COMMAND "${CMAKE_COMMAND}" -E remove "libDPCTLSyclInterface.so.${VERSION_MAJOR}"
-    COMMAND "${CMAKE_COMMAND}" -E echo "${linker_script2}" > "libDPCTLSyclInterface.so.${VERSION_MAJOR}"
     VERBATIM
 )

I am able to run pytest and it passes on Linux locally.

Since Python (or dlopen) is not able to follow chained linker scripts
set both properties to be the same, and use one linker script for .so
file which redirectes to .so.MAJOR.MINOR
@coveralls
Copy link
Collaborator

coveralls commented May 26, 2021

Coverage Status

Coverage increased (+0.06%) to 60.728% when pulling 62d67cf on fix/linker_scripts into 414f0a6 on master.

@oleksandr-pavlyk
Copy link
Contributor

BTW, will "${CMAKE_COMMAND}" -E echo "${linker_script1}" > "libDPCTLSyclInterface.so" also create a file on Windows?

@diptorupd diptorupd merged commit 368911d into master May 26, 2021
@diptorupd diptorupd deleted the fix/linker_scripts branch May 26, 2021 18:05
oleksandr-pavlyk added a commit that referenced this pull request May 26, 2021
oleksandr-pavlyk added a commit that referenced this pull request May 26, 2021
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.

3 participants