[LLVMdev] -O4 -fvisibility=hidden

Jean-Daniel Dupas devlists at shadowlab.org
Sun Jan 25 02:38:48 PST 2009


Le 25 janv. 09 à 06:01, Jack Howarth a écrit :

>   After trying the recommended use of -O4 -fvisibility=hidden to
> compile xplor-nih with full LTO optimizations, I discovered three
> symbols become undefined...
>
> llvm-gcc-4 -O4 -fvisibility=hidden -o xplor xplor.o  \
> 	   \
> 	  -L. -lxplorCmd -lxplor -L/Users/howarth/xplor-nih-2.21/ 
> bin.Darwin_9_x86/ -lfft -lintVar -lvmd -lpy -lswigpy-xplor - 
> ltclXplor -lswigtcl8-xplor -lnmrPot -lcommon -lmarvin  \
> 	     -lcrypto  -L/sw/lib/llvm-gcc-4.2/lib -lgfortran -llapack - 
> lblas   -L/Users/howarth/xplor-nih-2.21/bin.Darwin_9_x86/ \
> 	
> Undefined symbols:
>  "_xplorwrapproc_slave_", referenced from:
>      llvm bitcode in xplor.o
>  "_python_interp_", referenced from:
>      llvm bitcode in xplor.o
>  "_tcl_interp_", referenced from:
>      llvm bitcode in xplor.o
> ld: symbol(s) not found
>
> These are all defined as extern as follows...
>
> extern "C" void
> FORTRAN(tcl_interp)   (const long&          canReturn,
>                             long&          qterm,
>                             long&          fd)
>
> extern "C" void
> FORTRAN(python_init)(const long&         argc,
>                           char**        argv)
>
> extern "C" void FORTRAN(xplorwrapproc_slave)();
>

defining them as extern is not enough to mark them as "exported".

You should use the visibility attribute.

extern "C" void FORTRAN(xplorwrapproc_slave)()  
__attribute__((visibility("default")));

> The only symbols that become undefined are those extern
> symbols which calling fortran routines from c++ code.
> I'll look into creating a testcase and opening a PR for
> this issue.
>               Jack







More information about the llvm-dev mailing list