From 9e76021b94e52318c666c8325079260cd1d8bd4d Mon Sep 17 00:00:00 2001 From: Andi <andi8647@gmail.com> Date: Fri, 22 Dec 2023 09:16:06 +0100 Subject: [PATCH] Remove usage of RTLD_DEEPBIND and add PIC (#1554) --- src/CMakeLists.txt | 5 ++++- src/memgraph.cpp | 2 +- src/query/procedure/module.hpp | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ba8784b19..ab6a8c54d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -53,7 +53,10 @@ set_target_properties(memgraph PROPERTIES OUTPUT_NAME "memgraph-${MEMGRAPH_VERSION}_${CMAKE_BUILD_TYPE}" # Output the executable in main binary dir. - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + + POSITION_INDEPENDENT_CODE ON + ) # Create symlink to the built executable. add_custom_command(TARGET memgraph POST_BUILD diff --git a/src/memgraph.cpp b/src/memgraph.cpp index 057b30982..217d4a71c 100644 --- a/src/memgraph.cpp +++ b/src/memgraph.cpp @@ -163,7 +163,7 @@ int main(int argc, char **argv) { // libstd. auto gil = memgraph::py::EnsureGIL(); // NOLINTNEXTLINE(hicpp-signed-bitwise) - auto *flag = PyLong_FromLong(RTLD_NOW | RTLD_DEEPBIND); + auto *flag = PyLong_FromLong(RTLD_NOW); auto *setdl = PySys_GetObject("setdlopenflags"); MG_ASSERT(setdl); auto *arg = PyTuple_New(1); diff --git a/src/query/procedure/module.hpp b/src/query/procedure/module.hpp index 8963173e7..41cda0ca6 100644 --- a/src/query/procedure/module.hpp +++ b/src/query/procedure/module.hpp @@ -169,7 +169,7 @@ class ModuleRegistry final { // mentioned library will be first performed in the already existing binded // libraries and then the global namespace. // RTLD_DEEPBIND => https://linux.die.net/man/3/dlopen - SharedLibraryHandle libstd_handle{"libstdc++.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND, kLibstdcppWarning}; + SharedLibraryHandle libstd_handle{"libstdc++.so.6", RTLD_NOW | RTLD_LOCAL, kLibstdcppWarning}; #endif std::vector<std::filesystem::path> modules_dirs_; std::filesystem::path internal_module_dir_;