-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the libvaccel-python.so helper lib
libpython.so loads all dependent libraries lazily. This does not work for us, so by using this dummy wrapper, we force the loader to resolve all lib dependencies at load time. eg, see: python/cpython#65735 (comment) Signed-off-by: Anastassios Nanos <[email protected]>
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
file(GLOB_RECURSE sources *.c) | ||
|
||
# core runtime headers | ||
file(GLOB_RECURSE headers *.h) | ||
|
||
add_library(vaccel-python SHARED ${headers} ${sources}) | ||
target_compile_options(vaccel-python PUBLIC -Wall -Wextra -Werror -pthread) | ||
target_include_directories(vaccel-python PRIVATE ${CMAKE_SOURCE_DIR}/src) | ||
target_include_directories(vaccel-python PRIVATE ${CMAKE_SOURCE_DIR}/src/include) | ||
set_property(TARGET vaccel-python PROPERTY LINK_FLAGS "-pthread") | ||
set_property(TARGET vaccel-python PROPERTY C_STANDARD 11) | ||
target_link_libraries(vaccel-python) | ||
|
||
# Setup make install | ||
install(TARGETS vaccel-python DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
#install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
# Create the pkg-config file | ||
set(DEST_DIR "${CMAKE_INSTALL_PREFIX}") | ||
CONFIGURE_FILE("vaccel-python.pc.in" "vaccel-python.pc" @ONLY) | ||
|
||
# Install the vaccel.pc file | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/vaccel-python.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <stdio.h> | ||
#include <dlfcn.h> | ||
#include <stdlib.h> | ||
#include <vaccel.h> | ||
#include <plugin.h> | ||
#include <assert.h> | ||
|
||
__attribute__((constructor)) | ||
void load_vaccel(void) | ||
{ | ||
printf("Loading libvaccel\n"); | ||
void *dl = dlopen("libvaccel.so", RTLD_LAZY | RTLD_GLOBAL); | ||
if (!dl) { | ||
fprintf(stderr, "Could not open libvaccel\n"); | ||
exit(1); | ||
} | ||
|
||
char *pname = getenv("PYTHON_VACCEL_PLUGIN"); | ||
printf("Loading plugin %s\n", pname); | ||
void *plugin = dlopen(pname, RTLD_NOW); | ||
if (!plugin) { | ||
fprintf(stderr, "Failed to load plugin: %s\n", dlerror()); | ||
exit(1); | ||
} | ||
|
||
struct vaccel_plugin **p; | ||
|
||
int (*register_plugin)(struct vaccel_plugin *) = | ||
dlsym(dl, "register_plugin"); | ||
assert(register_plugin); | ||
|
||
p = dlsym(plugin, "vaccel_plugin"); | ||
if (p == NULL) { | ||
fprintf(stderr, "Cannot find vaccel_plugin symbol\n"); | ||
return; | ||
} | ||
assert(p); | ||
|
||
int ret = register_plugin(*p); | ||
assert(!ret); | ||
if (ret) { | ||
fprintf(stderr, "Failed to register plugin\n"); | ||
return; | ||
} | ||
|
||
ret = (*p)->info->init(); | ||
assert(!ret); | ||
if (ret) { | ||
fprintf(stderr, "Failed to initialize plugin\n"); | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
prefix=@DEST_DIR@ | ||
exec_prefix=${prefix} | ||
libdir=${prefix}/lib | ||
includedir=${prefix}/include | ||
|
||
Name: libvaccel-python | ||
Description: Transparent acceleration for edge and cloud computing hack | ||
Version: 0.4.0 | ||
|
||
Libs: -L${libdir} -lvaccel-python | ||
Cflags: -I${includedir} |