[OpenAFS-devel] shlib on s390x

Peter Somogyi psomogyi@gamax.hu
Wed, 29 Jun 2005 13:25:27 +0200


Hi,

I'm fixing the jafs (JAVA API for OpenAFS, located under src/JAVA) to make it work on s390x (with the latest openafs version).
(We have our own version of jafs, and so far most of the functions are tested and work under 386 and on ppc 32-bit version.)
The compilation output is libjafs.so and libjafsadm.so.

Now I've run into a serious problem under s390x: -fPIC flag is required to the compilation of *EVERY* c source code which take part in an shlib.
It affects mainly the libjafsadm.so, which includes libadmin libs (libbosadmin.a, libvosadmin.a, ...) and
some others (libafsauthent.a, libafsrpc.a, libcmd.a, util.a).

Unfortunately, it's not enough to give -fPIC flag to compile the libjafs sources.
I've tried, and it's even not enough to compile libadmin libs themselves with -fPIC (they also include some other libs).
(It crashes at the first function call which is located in a non-fPIC compiled library.)
I had to write it into src/cf/osconf.m4,  s390x_linux24|s390x_linux26) section:
...
<	XCFLAGS="-O -g -D_LARGEFILE64_SOURCE -D__s390x__
>	XCFLAGS="-O -g -D_LARGEFILE64_SOURCE -D__s390x__ -fPIC
...

And now it doesn't crash because of an -fPIC problem.

NOTE: after this modification, I've run into a second problem: 32/64-bit problem. I've noticed that jafs is still not prepared for 64-bit platform.
(it stores each handles in jint, which is 32-bit...) But this is another problem which I will solve in the next days.

NOTE2: platform is s390x, SLES9, 2.6.5-7.97 kernel, gcc is 3.3.3

NOTE3: on ppc I've got a gcc compilation error about -fPIC when compiling libjafs until I've modified src/libuafs/MakefileProto.LINUX.in, adding -fPIC to CFLAGS.
Strangely, for libjafsdmin (which includes libadmin libs) libadmin libs wasn't requested to be compiled with -fPIC. (It was enough to give this flag for libjafs source.)
i386 seems to ignore this problem.
s390x: Java VM just crashes with segfault at runtime at the first function call which source is not compiled with -fPIC.
So this -fPIC problem seems s390x-specific.

Possible solutions I can imagine:
#1 modify src/config/osconf.m4 to include -fPIC in XCFLAGS (has a global effect)
#2 when "make jafs", it would copy recursively entire openafs source into a temp folder, modify osconf.m4 there, and compile libjafs*so there
#3 create a separate OpenAFS API which is -fPIC (its name would be something like "shlibadmin")

I would avoid #3, because it would result in a huge or lot of duplicate/redundant makefiles and work (see libuafs, shlibafsrpc, shlibafsauthent) which would need also additional maintenance.
#2 is nasty, very slow but well separated;
I'd choose #1, but I don't know whether it would be accepted by the OpenAFS maintainers. That's why I'm writting here.
And our intention is to make jafs to be accepted into the OpenAFS HEAD version.
(As far as I know, -fPIC doesn't hurt. Please correct me if yes.)

I appreciate any answers and advices.


Peter Somogyi