On 2008-09-08 21:54+0100 Andrew Ross wrote: > A quick look suggests some implementational issues with the gcc > visibility stuff. > > The #pragma statements are at the beginning / end of plplot.h. This > means anything defined elsewhere (for example in plplotP.h) will be > public by default. Functions only defined in source files will also be > public unless otherwise marked. Since everything in plplot.h is actually > marked to be exported then changing the #pragma statements should have > no effect at all, but it does! > > Anyway this shouldn't be the cause of the problem, although it will > need fixing. This is actually slightly tricky without scattering > #pragma statements throughout the source code. I guess eventually > explicitly marking all functions as visibility default or hidden is > the answer (as suggested in the wiki page). It might be worth > trying compiling with -fvisibility=hidden too.
I temporarily bypassed the #pragmas using #if 0 in plplot.h. The idea was to remember the syntax, but we can pick that up elsewhere so in retrospect it probably would have been better to remove them altogether. Anyhow, feel free to do that if you like. For now we can test out gcc visibility on Linux using -fvisibility=hidden, which appears to work much better than the #pragma idea (see below). I also fixed up some Linux gcc visibility issues in lib/csa/csadll.h and lib/nn/nndll.h. Here was what I did to test the simplest case with an initially empty build tree: export CC='gcc -fvisibility=hidden' cmake -DCMAKE_INSTALL_PREFIX=/home/software/plplot_cvs/installcmake \ -DBUILD_TEST=ON -DDEFAULT_NO_BINDINGS=ON -DDEFAULT_NO_DEVICES=ON \ -DPLD_ps=ON -DENABLE_DYNDRIVERS=OFF ../plplot_cmake >& cmake.out "make" and "ctest" executed without any obvious problems. Also, "nm --extern-only --defined-only " and "ldd -r" gave the expected results for lib/csa/libcsirocsa.so, lib/nn/libcsironn.so, and src/libplplotd.so. So this is a good Linux/gcc visibility start which we can build on. In fact, after some changes in binding/f77 and bindings/f95 (revision 8757) I got a good make and ctest results for the -DENABLE_cxx=ON -DENABLE_f77=ON -DENABLE_f95=ON case. So this looks like I am on the right track with our C, C++, f77, and f95 libraries working for the -fvisibility=hidden option for gcc, but then I tried one experient too far. :-( That experiment was the -DENABLE_DYNDRIVERS=ON case, but for that case the link of get-drv-info fails with the following error: /usr/bin/gcc -fvisibility=hidden CMakeFiles/get-drv-info.dir/get-drv-info.o -o get-drv-info -rdynamic ../src/libplplotd.so.9.5.0 -lltdl -ldl ../lib/csa/libcsirocsa.so.0.0.1 -lm ../lib/nn/libcsironn.so.0.0.1 -lfreetype -lqhull -Wl,-rpath,/home/software/plplot_cvs/HEAD/build_dir/drivers:/home/software/plplot_cvs/HEAD/build_dir/src:/home/software/plplot_cvs/HEAD/build_dir/lib/csa:/home/software/plplot_cvs/HEAD/build_dir/lib/nn:/usr/lib CMakeFiles/get-drv-info.dir/get-drv-info.o: In function `main': get-drv-info.c:(.text+0x72): undefined reference to `plGetDrvDir' collect2: ld returned 1 exit status make[2]: *** [drivers/get-drv-info] Error 1 make[2]: Leaving directory `/home/software/plplot_cvs/HEAD/build_dir' make[1]: *** [drivers/CMakeFiles/get-drv-info.dir/all] Error 2 make[1]: Leaving directory `/home/software/plplot_cvs/HEAD/build_dir' make: *** [all] Error 2 To attempt to address this issue in plplotP.h for plGetDrvDir I tried to follow the syntax of what was done in that same header with the char PLDLLIMPEXP * plstrdup(const char *src); declaration by locally changing from char* plGetDrvDir (void); to char PLDLLIMPEXP * plGetDrvDir (void); I also similarly and locally changed the definition of plGetDrvDir in plcore.c following what was done for the definition of plstrdup in plctrl.c even though it appears from one of the references that changing the definition is not necessary so long as the declaration is covered. but the result from nm (whether the definition is changed or not) is 000000000001a0af t plGetDrvDir 000000000002125c T plstrdup (i.e., plGetDrvDir is still internal despite my local changes to plplotP.h and plcore.c [or not]), and I continue to get the above error message as a result. Note in the above, for the Linux GCC case PLDLLIMPEXP is #defined to be __attribute__ ((visibility("default"))) as recommended in the Linux GCC visibility references. Can anybody help me figure out this issue? Why should plstrdup and plGetDrvDir end up with different visibility given the above local changes? Note the -DENABLE_DYNDRIVERS=ON case is new visibility territory that has not been tested before because PLplot windows developers never use that option (since to work on Windows you need a libltdl version that is suitable for that platform). So if anybody wants to push this further in a hurry following what was done for visibility on windows it might be best to bypass that issue by using -DENABLE_DYNDRIVERS=OFF for now for further visibility experiments. But it would also be nice to deal with the -DENABLE_DYNDRIVERS=ON case if somebody has an answer to the above question. Alan __________________________ Alan W. Irwin Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); PLplot scientific plotting software package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel