charm icon indicating copy to clipboard operation
charm copied to clipboard

Unable to use python bindings that depend on Charm++

Open nilsdeppe opened this issue 4 years ago • 4 comments

Hi folks!

We use python bindings to make some data visualization work easier. Unfortunately the use of -ftls-model=initial-exec is incompatible with loading shared libraries after executable initialization (assuming I've understood all the errors correctly!). This means the only way we can use Charm++ 7 is to patch it:

diff --git a/cmake/detect-features-cxx.cmake b/cmake/detect-features-cxx.cmake
index d3aa6ab94..830da9cf1 100644
--- a/cmake/detect-features-cxx.cmake
+++ b/cmake/detect-features-cxx.cmake
@@ -38,12 +38,12 @@ endif()
 
 # Needed so that tlsglobals works correctly with --build-shared
 # See https://github.com/UIUC-PPL/charm/issues/3168 for details.
-check_cxx_compiler_flag("-ftls-model=initial-exec" CMK_COMPILER_KNOWS_FTLS_MODEL)
-if(CMK_COMPILER_KNOWS_FTLS_MODEL)
-  set(OPTS_CC "${OPTS_CC} -ftls-model=initial-exec")
-  set(OPTS_CXX "${OPTS_CXX} -ftls-model=initial-exec")
-  set(OPTS_LD "${OPTS_LD} -ftls-model=initial-exec")
-endif()
+# check_cxx_compiler_flag("-ftls-model=initial-exec" CMK_COMPILER_KNOWS_FTLS_MODEL)
+# if(CMK_COMPILER_KNOWS_FTLS_MODEL)
+#   set(OPTS_CC "${OPTS_CC} -ftls-model=initial-exec")
+#   set(OPTS_CXX "${OPTS_CXX} -ftls-model=initial-exec")
+#   set(OPTS_LD "${OPTS_LD} -ftls-model=initial-exec")
+# endif()
 
 # Allow seeing own symbols dynamically, needed for programmatic backtraces
 check_cxx_compiler_flag("-rdynamic" CMK_COMPILER_KNOWS_RDYNAMIC)
diff --git a/src/scripts/configure.ac b/src/scripts/configure.ac
index f6c0f311b..41a7c9f46 100644
--- a/src/scripts/configure.ac
+++ b/src/scripts/configure.ac
@@ -820,15 +820,15 @@ then
 fi
 
 # Needed so that tlsglobals works correctly with --build-shared
-# See https://github.com/UIUC-PPL/charm/issues/3168 for details.
-test_cxx "whether C++ compiler accepts -ftls-model=initial-exec" "yes" "no" "-ftls-model=initial-exec"
-if test $strictpass -eq 1
-then
-    add_flag 'CMK_COMPILER_KNOWS_FTLS_MODEL="1"' "tlsglobals"
-    OPTS_CC="$OPTS_CC -ftls-model=initial-exec"
-    OPTS_CXX="$OPTS_CXX -ftls-model=initial-exec"
-    OPTS_LD="$OPTS_LD -ftls-model=initial-exec"
-fi
+# # See https://github.com/UIUC-PPL/charm/issues/3168 for details.
+# test_cxx "whether C++ compiler accepts -ftls-model=initial-exec" "yes" "no" "-ftls-model=initial-exec"
+# if test $strictpass -eq 1
+# then
+#     add_flag 'CMK_COMPILER_KNOWS_FTLS_MODEL="1"' "tlsglobals"
+#     OPTS_CC="$OPTS_CC -ftls-model=initial-exec"
+#     OPTS_CXX="$OPTS_CXX -ftls-model=initial-exec"
+#     OPTS_LD="$OPTS_LD -ftls-model=initial-exec"
+# fi
 
 # Test for a flag important for shared linking
 test_cxx "whether C++ compiler accepts -fvisibility=hidden" "yes" "no" "-fvisibility=hidden"

It would be nice to have a solution that doesn't require us to patch Charm++. From https://github.com/UIUC-PPL/charm/issues/3168 it wasn't clear to me why changing the TLS behavior was the right solution. We've had a lot of issues with allocators like jemalloc and tcmalloc if the TLS module was global-dynamic, and using the faster allocators can actually make a difference. Having said all that, the real issue is not being able to use python bindings anymore. Since all of our classes need to be serializable they all have a pup function and so they all depend on Charm++, so any build flags Charm++ uses basically percolate through our entire build system.

Happy to discuss more and provide any additional details that would be useful in finding a solution that works for everyone!

Cheers,

Nils

nilsdeppe avatar Apr 20 '22 18:04 nilsdeppe

Hi folks! Any update on if there will be an option to disable these flags?

nilsdeppe avatar May 12 '22 19:05 nilsdeppe

Note that this is only an issue on Linux. On macOS we don't need to patch.

nilsdeppe avatar May 12 '22 20:05 nilsdeppe

Note that this is only an issue on Linux. On macOS we don't need to patch.

Would adding an option, e.g., --disable-tls to disable the use of -ftls-model=initial-exec be a sufficient workaround?

ericjbohm avatar Aug 02 '22 17:08 ericjbohm

That would be perfect, thank you!

nilsdeppe avatar Aug 02 '22 19:08 nilsdeppe