Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] RFC: Add an __attribute__((destructor)) function to opal
From: Paul Hargrove (phhargrove_at_[hidden])
Date: 2014-07-17 21:20:23


On Thu, Jul 17, 2014 at 5:55 PM, George Bosilca <bosilca_at_[hidden]> wrote:

> Are these also called for shared libraries?
>
  George.
>

If you are asking specifically about Solaris w/ the vendor compilers, then
apparently Yes:

-bash-3.00$ cat test.c
#include <stdio.h>
int X = 0;
__attribute__((__constructor__)) void hello(void) { X = 42; }
__attribute__((__destructor__)) void goodbye(void) { printf("X = %d\n", X);
}
-bash-3.00$ cc -fPIC -c test.c
-bash-3.00$ cc -shared -o libtest.so test.o

-bash-3.00$ cat main.c
int main(void) { return 0; }
-bash-3.00$ cc main.c -L. -ltest
-bash-3.00$ ./a.out
X = 42

That is the ancient toolchain in /usr/bin:

-bash-3.00$ cc -V
cc: Sun C 5.9 SunOS_sparc 2007/05/03
usage: cc [ options] files. Use 'cc -flags' for details
-bash-3.00$ ld -V
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.489

Same result with Solaris Studio 12.3 compilers:

-bash-3.00$ cc -V
cc: Sun C 5.12 SunOS_sparc 2011/11/16
-bash-3.00$ cc -fPIC -c test.c
-bash-3.00$ cc -shared -o libtest.so test.o
-bash-3.00$ cc main.c -L. -ltest
-bash-3.00$ ./a.out
X = 42

-Paul

>
>
> On Wed, Jul 16, 2014 at 3:36 PM, Paul Hargrove <phhargrove_at_[hidden]> wrote:
>
>>
>> On Wed, Jul 16, 2014 at 7:36 AM, Nathan Hjelm <hjelmn_at_[hidden]> wrote:
>>
>>> Correction. xlc does support the destructor function attribute. The odd
>>> one out is PGI.
>>>
>>
>> Are the Solaris Studio compilers still of interest to the Open MPI
>> community?
>> If so, I've confirmed support using the following 5-line test on a
>> Solaris-10/SPARC platform.
>>
>> #include <stdio.h>
>> int X = 0;
>> __attribute__((__constructor__)) void hello(void) { X = 42; }
>> __attribute__((__destructor__)) void goodbye(void) { printf("X = %d\n",
>> X); }
>> int main(void) { return 0; }
>>
>>
>>
>> -Paul
>>
>>
>>
>>
>> --
>> Paul H. Hargrove PHHargrove_at_[hidden]
>> Future Technologies Group
>> Computer and Data Sciences Department Tel: +1-510-495-2352
>> Lawrence Berkeley National Laboratory Fax: +1-510-486-6900
>>
>> _______________________________________________
>> devel mailing list
>> devel_at_[hidden]
>> Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/devel
>> Link to this post:
>> http://www.open-mpi.org/community/lists/devel/2014/07/15183.php
>>
>
>
> _______________________________________________
> devel mailing list
> devel_at_[hidden]
> Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/devel
> Link to this post:
> http://www.open-mpi.org/community/lists/devel/2014/07/15191.php
>

-- 
Paul H. Hargrove                          PHHargrove_at_[hidden]
Future Technologies Group
Computer and Data Sciences Department     Tel: +1-510-495-2352
Lawrence Berkeley National Laboratory     Fax: +1-510-486-6900