Commit 561e6899445af328ef30290c6cefb35d33781515

Authored by Jürgen Knödlseder
1 parent 328a02b5

Add automatic setting of RTLD_GLOBAL | RTLD_NOW in ctools initialisation script

configure.ac
1 ############################################################################# 1 #############################################################################
2 # Configuration for ctools - tools for science analysis of CTA data # 2 # Configuration for ctools - tools for science analysis of CTA data #
3 # ------------------------------------------------------------------------- # 3 # ------------------------------------------------------------------------- #
4 -# Copyright (C) 2011-2020 Juergen Knoedlseder # 4 +# Copyright (C) 2011-2021 Juergen Knoedlseder #
5 # ------------------------------------------------------------------------- # 5 # ------------------------------------------------------------------------- #
6 # # 6 # #
7 # This program is free software: you can redistribute it and/or modify # 7 # This program is free software: you can redistribute it and/or modify #
@@ -360,6 +360,13 @@ AC_SUBST(RUNSHARED) @@ -360,6 +360,13 @@ AC_SUBST(RUNSHARED)
360 360
361 361
362 ############################################################################# 362 #############################################################################
  363 +# Determine values of RTLD_GLOBAL and RTLD_NOW #
  364 +#############################################################################
  365 +AX_DLFLAGS(RTLD_GLOBAL)
  366 +AX_DLFLAGS(RTLD_NOW)
  367 +
  368 +
  369 +#############################################################################
363 # Set -arch flags for universal builds on OSX and tweak BASECFLAGS based on # 370 # Set -arch flags for universal builds on OSX and tweak BASECFLAGS based on #
364 # compiler and platform (note that BASECFLAGS are not yet used). # 371 # compiler and platform (note that BASECFLAGS are not yet used). #
365 ############################################################################# 372 #############################################################################
m4/ax_dlflags.m4 0 → 100644
  1 +# ===========================================================================
  2 +#
  3 +# SYNOPSIS
  4 +#
  5 +# AX_DLFLAGS
  6 +#
  7 +# DESCRIPTION
  8 +#
  9 +# This macro determines the value of a DL flags such as RTLD_GLOBAL or
  10 +# RTLD_NOW from the dlfcn.h file.
  11 +#
  12 +# USAGE
  13 +#
  14 +# AX_DLFLAGS(RTLD_GLOBAL)
  15 +# AC_MSG_RESULT($DLFLAGS_RTLD_GLOBAL)
  16 +#
  17 +# LICENSE
  18 +#
  19 +# Copyright (c) 2021 Juergen Knoedlseder
  20 +#
  21 +# This program is free software: you can redistribute it and/or modify
  22 +# it under the terms of the GNU General Public License as published by
  23 +# the Free Software Foundation, either version 3 of the License, or
  24 +# (at your option) any later version.
  25 +#
  26 +# This program is distributed in the hope that it will be useful,
  27 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  28 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29 +# GNU General Public License for more details.
  30 +#
  31 +# You should have received a copy of the GNU General Public License
  32 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
  33 +
  34 +#serial 8
  35 +
  36 +AC_DEFUN([AX_DLFLAGS], [
  37 + DLFLAGS_$1=""
  38 + AC_CHECK_HEADERS([dlfcn.h])
  39 + AS_IF([test "x$ac_cv_header_dlfcn_h" = "xyes"],[
  40 + AC_MSG_CHECKING([for value of $1])
  41 + for flags in 1 2 4 8 16 32 64 128 256 512 ; do
  42 + AC_EGREP_CPP([test_true],[
  43 + #include <dlfcn.h>
  44 + #if defined($1) && $1 == $flags
  45 + test_true
  46 + #endif
  47 + ],[DLFLAGS_$1=$flags],[])
  48 + done
  49 + ])
  50 + AC_MSG_RESULT($DLFLAGS_$1)
  51 + AC_SUBST([DLFLAGS_$1])
  52 +])
pyext/ctools/__init__.py.in
@@ -20,9 +20,18 @@ @@ -20,9 +20,18 @@
20 # import gammalib first 20 # import gammalib first
21 import gammalib 21 import gammalib
22 22
  23 +# Make sur that library symbols are exported by setting the dynamic library
  24 +# loading flag to RTLD_GLOBAL | RTLD_NOW. This is necessary on some systems.
  25 +import sys
  26 +flags = sys.getdlopenflags()
  27 +sys.setdlopenflags(@DLFLAGS_RTLD_GLOBAL@ | @DLFLAGS_RTLD_NOW@)
  28 +
23 # Import sub modules 29 # Import sub modules
24 from @PYTHON_RELATIVE_IMPORT@tools import * 30 from @PYTHON_RELATIVE_IMPORT@tools import *
25 31
  32 +# Reset original flags
  33 +sys.setdlopenflags(flags)
  34 +
26 # Remove swig register stuff 35 # Remove swig register stuff
27 bad_entries = [entry for entry in list(locals()) 36 bad_entries = [entry for entry in list(locals())
28 if entry.endswith('_swigregister')] 37 if entry.endswith('_swigregister')]