-----Original Message----- From: Smith-Rowland, Edward M Sent: Thu 4/3/2008 5:06 PM To: gcc-help@xxxxxxxxxxx Cc: Smith-Rowland, Edward M; 3dw4rd@xxxxxxxxxxx Subject: gfortran and -fvisibility I am having trouble with symbol visibility with gfortran on Linux x86_64. It looks like -fvisibility=hidden doesn't work. [ed@alion7 tirem-3.2]$ gfortran -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux Thread model: posix gcc version 4.1.2 20070626 (Red Hat 4.1.2-14) So I copied and translated a gcc.dg/visibility-9.c to Fortran for a small test case. I compiled with gfortran to a shared library (x86_64 ELF Linux etc.). visibility-1.f90 -------------------------------------------------------------------- ! Test that -fvisibility works. ! { dg-do compile } ! { dg-require-visibility "" } ! { dg-options "-fvisibility=hidden" } ! { dg-final { scan-hidden "foo" } } subroutine foo end subroutine -------------------------------------------------------------------- [ed@alion7 ~]$ gfortran -shared -fvisibility=default -fPIC -o visibility-1.so visibility-1.f90 [ed@alion7 ~]$ nm -C -D visibility-1.so w _Jv_RegisterClasses 00000000002007c8 A __bss_start w __cxa_finalize w __gmon_start__ 00000000002007c8 A _edata 00000000002007d8 A _end 0000000000000548 T _fini 00000000000003f0 T _init 00000000000004fc T foo_ The "foo_" at the end is teh bad thing. I haven't checked a gfortran less than 4.1 but g77 as of gcc-3.4 supports visibility. I've checked with an almost release gcc-4.3 and visibility still didn't work. Is anyone else seeing a problem? I'll check PPC MacOS and i32 Cygwin when I get home. Ed Smith-Rowland ------------------------------------------------------- I just verified this on PPC MacOSX: MacOSX:~ ed$ bin-4.3/bin/gfortran -v Using built-in specs. Target: powerpc-apple-darwin7.9.0 Configured with: ../gcc/configure --prefix=/Users/ed/bin-4.3 --enable-languages=c,c++,objc,obj-c++,fortran,treelang Thread model: posix gcc version 4.3.0 20071116 (experimental) (GCC) The results of nm: MacOSX:~ ed$ bin-4.3/bin/gfortran -dynamiclib -fvisibility=default -fPIC -o visibility-1.dylib visibility-1.f90 MacOSX:~ ed$ nm visibility-1.dylib ... visibility-1.dylib(ccsE7pf3.o): 00001db0 T _foo_ ...