This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] libgomp: removing nodlopen flag for portability


I don't think altering the tls-model-flag is necessary to fix my problem, I just included it here because Iordan proposed so. I'm not familiar with the different flag modes.

However, LD_PRELOAD fixes the dlopen() problem only for me. I don't know how much space needs to be preallocated for libgomp (especially when using RTLD_LAZY as dlopen mode), but I think people will want to be able to use libgomp just as I did, namely as a shared object providing parallelization of C++ code even when these functions were called from an interpreter such as python. I'm in scientific programming and I think a lot of people do it like that. So far we have been using PGI mainly because this functionality was not there.

Anyway, it's up to you. For me it works.

Greetings Sebastian


Jakub Jelinek wrote:
On Wed, May 02, 2007 at 03:23:15PM +0200, Sebastian Steiger wrote:
This is the patch following the discussion of myself and Andrew Haley in the gcc-help mailing list:

http://gcc.gnu.org/ml/gcc-help/2007-04/msg00300.html

It fixes a problem when trying to dlopen() the libgomp library. This operation is required, for example, when using libgomp from within python. With the new libgomp, I was able to use the OpenMP functionality in C++ functions that were ported to python using the python/C++ API, e.g. with SWIG.

The tls-model flag was proposed by Iordan Hristov who initally encountered the problem:

http://gcc.gnu.org/ml/gcc-help/2006-09/msg00164.html

This is a bad idea, global-dynamic model is much slower than initial-exec. You can LD_PRELOAD=libgomp.so.1 python ... Dropping -Wl,-z,nodlopen is possible on Linux, but you risk running out of the preallocated static TLS space, as libgomp uses quite a lot of TLS vars (on x86_64 64 bytes).

--- libgomp/configure.tgt       (revision 123941)
+++ libgomp/configure.tgt       (working copy)
@@ -17,8 +17,8 @@
   case "${target}" in

     *-*-linux*)
-       XCFLAGS="${XCFLAGS} -ftls-model=initial-exec"
-       XLDFLAGS="${XLDFLAGS} -Wl,-z,nodlopen"
+       XCFLAGS="${XCFLAGS} -ftls-model=global-dynamic"
+       XLDFLAGS="${XLDFLAGS}"
        ;;
   esac
 fi

Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]