Question

I ran into the following code in location.c for the apache jsvc java daemon.

char *location_jvm_cfg[] = {
    "$JAVA_HOME/jre/lib/jvm.cfg",           /* JDK */
    "$JAVA_HOME/lib/jvm.cfg",               /* JRE */
    "$JAVA_HOME/jre/lib/" CPU "/jvm.cfg",   /* JDK */
    "$JAVA_HOME/lib/" CPU "/jvm.cfg",       /* JRE */
    NULL,
};

I grepped through the source code to find out the CPU macro is expanded in the code "$JAVA_HOME/jre/lib/" CPU "/jvm.cfg" but could not find such a MACRO defined.

I am not really sure if CPU is a C Macro or some other thing that is being configured the autoconf tools.

how is the above CPU value being substituted for the real CPU value?

The problem I am facing is that when I build jsvc on Solaris with CFLAGS and LDFLAGS set to -m64 the generated 64 bit solaris binary tries to load the jvm .so files from $JAVA_HOME/jre/lib/sparc/jvm.cfg instead of $JAVA_HOME/jre/lib/sparcv9/jvm.cfg

UPDATE

Running ./configure that ships with JSVC with the following command line does the right thing

configure --with-java=/path/to/jdk1.7.0_45 --host=sparcv9-sun-solaris2.10 CFLAGS="-m64" LDFLAGS="-m64"

the extra --host=sparcv9-sun-solaris2.10 causes the generated gcc command to be

gcc -m64 -DOS_SOLARIS -DDSO_DLFCN -DCPU=\"sparcv9\" -Wall -Wstrict-prototypes

Instead of

gcc -m64 -DOS_SOLARIS -DDSO_DLFCN -DCPU=\"sparc\" -Wall -Wstrict-prototypes

which is what was causing the generated 64 bit jsvc binary to try to link against the 32 bit so files instead of the 64 bit so files.

Was it helpful?

Solution

It absolutely must be a preprocessor define. Nothing else would work in that code.

For making configure use different CPUs, it may be possible that the configure script takes a configuration triplet. That might look like 'i686-unknown-gnu-linux'

Apparently configure.guess does the work of figuring this out. If you specify one of these triplets (quadruplets?) on the configure command line it might think it is building in a cross-compiler, but it should work.

OTHER TIPS

The generated configure script adds -DCPU to CFLAGS, based on the value of configure --host, which defaults to configure --build, which defaults to a guessed value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top