Languages and Scripting

Re: Problem when compiling PA-RISC code on Itanium

 
SOLVED
Go to solution
Gilles Allard
Advisor

Problem when compiling PA-RISC code on Itanium

I need to link new C code with a legacy library (PA-RISC). I'm using GCC4.4.3 that I obtained from the HP website (DSPP).
HPUX11.31 is supplied with PA-RISC libraries, so I assumed it would be simple.


hptest> gcc -v
Using built-in specs.
Target: hppa1.1-hp-hpux11.11
Configured with: /tmp/gcc-4.4.3.tar.gz/gcc-4.4.3/configure --host=hppa1.1-hp-hpux11.11 --target=hppa1.1-hp-hpux11.11 --build=hppa1.1-hp-hpux11.11 --prefix=/opt/hp-gcc-4.4.3 --with-gnu-as --without-gnu-ld --enable-threads=posix --enable-languages=c,c++ --with-gmp=/proj/opensrc/be/hppa1.1-hp-hpux11.11 --with-mpfr=/proj/opensrc/be/hppa1.1-hp-hpux11.11 SED=/usr/bin/sed
Thread model: posix
gcc version 4.4.3 (GCC)


My first attempt gave this (some paths shortened)


export LDOPTS="-v"
gcc -v -march=1.1 -I/myinc -L/mylibs mylib1.a prog.c

Using built-in specs.
Target: hppa1.1-hp-hpux11.11
Configured with: /tmp/gcc-4.4.3.tar.gz/gcc-4.4.3/configure --host=hppa1.1-hp-hpux11.11 --target=hppa1.1-hp-hpux11.11 --build=hppa1.1-hp-hpux11.11 --prefix=/opt/hp-gcc-4.4.3 --with-gnu-as --without-gnu-ld --enable-threads=posix --enable-languages=c,c++ --with-gmp=/proj/opensrc/be/hppa1.1-hp-hpux11.11 --with-mpfr=/proj/opensrc/be/hppa1.1-hp-hpux11.11 SED=/usr/bin/sed
Thread model: posix
gcc version 4.4.3 (GCC)
COLLECT_GCC_OPTIONS='-v' '-march=1.1' '-I/myinc' '-L/mylibs' '-mschedule=7100LC'
/opt/hp-gcc-4.4.3/libexec/gcc/hppa1.1-hp-hpux11.11/4.4.3/cc1 -quiet -v -I/myinc prog.c -quiet -dumpbase prog.c -march=1.1 -mschedule=7100LC -auxbase ex3 -version -o /var/tmp//ccFG1Yla.s
ignoring nonexistent directory "/opt/hp-gcc-4.4.3/hppa1.1-hp-hpux11.11/include"
#include "..." search starts here:
#include <...> search starts here:
/myinc
/usr/local/include
/opt/hp-gcc-4.4.3/include
/opt/hp-gcc-4.4.3/lib/gcc/hppa1.1-hp-hpux11.11/4.4.3/include
/opt/hp-gcc-4.4.3/lib/gcc/hppa1.1-hp-hpux11.11/4.4.3/include-fixed
/usr/include
End of search list.
GNU C (GCC) version 4.4.3 (hppa1.1-hp-hpux11.11)
compiled by GNU C version 4.4.3, GMP version 4.2.4, MPFR version 2.4.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: cf6b82a9c6a4c8b4c5c83f9910f85797
COLLECT_GCC_OPTIONS='-v' '-march=1.1' '-I/myinc' '-mschedule=7100LC'
/opt/hp-gcc-4.4.3/hppa1.1-hp-hpux11.11/bin/as -v -I/myinc -o /var/tmp//cceSogXF.o /var/tmp//ccFG1Yla.s
GNU assembler version 2.20 (hppa1.1-hp-hpux11.11) using BFD version (GNU Binutils) 2.20
COMPILER_PATH=/opt/hp-gcc-4.4.3/libexec/gcc/hppa1.1-hp-hpux11.11/4.4.3/:/opt/hp-gcc-4.4.3/libexec/gcc/hppa1.1-hp-hpux11.11/4.4.3/:/opt/hp-gcc-4.4.3/libexec/gcc/hppa1.1-hp-hpux11.11/:/opt/hp-gcc-4.4.3/lib/gcc/hppa1.1-hp-hpux11.11/4.4.3/:/opt/hp-gcc-4.4.3/lib/gcc/hppa1.1-hp-hpux11.11/:/opt/hp-gcc-4.4.3/hppa1.1-hp-hpux11.11/bin/:/usr/ccs/bin/
LIBRARY_PATH=/opt/hp-gcc-4.4.3/lib/gcc/hppa1.1-hp-hpux11.11/4.4.3/:/usr/ccs/lib/:/opt/langtools/lib/:/opt/hp-gcc-4.4.3/lib/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-march=1.1' '-I/myinc' '-L/mylibs' '-mschedule=7100LC'
/opt/hp-gcc-4.4.3/libexec/gcc/hppa1.1-hp-hpux11.11/4.4.3/collect2 -z -u main -u __gcc_plt_call crt0.o unix98.o -L/mylibs -L/opt/hp-gcc-4.4.3/lib/gcc/hppa1.1-hp-hpux11.11/4.4.3 -L/usr/ccs/lib -L/opt/langtools/lib -L/opt/hp-gcc-4.4.3/lib mylib1.a /var/tmp//cceSogXF.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh
ld: Mismatched ABI (not an ELF file) for -lgcc, found /opt/hp-gcc-4.4.3/lib/gcc/hppa1.1-hp-hpux11.11/4.4.3/libgcc.a
Fatal error.
collect2: ld returned 1 exit status


Obviously ctr0.o (the first object file) force the linker to use ELF (Itanium format). Second attempt to use ctr0.o from a different directory. I used SDKROOT (thanks to Dennis).
Here's the result (shortened):


export LDOPTS="-v"
export SDKROOT=/usr/ccs/pa
gcc -v -march=1.1 -I/myinc -L/mylibs mylib1.a prog.c

/usr/ccs/pa/usr/ccs/lbin/ld32 -v -z -u main -u __gcc_plt_call crt0.o unix98.o -Lmylibs -L/opt/hp-gcc-4.4.3/lib/gcc/hppa1.1-hp-hpux11.11/4.4.3 -L/usr/ccs/lib -L/opt/langtools/lib -L/opt/hp-gcc-4.4.3/lib lib1.a /var/tmp//ccQfvieL.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh
LPATH is : /usr/lib:/opt/langtools/lib
/usr/ccs/pa/usr/ccs/lbin/ld32: Can't open crt0.o
/usr/ccs/pa/usr/ccs/lbin/ld32: No such file or directory
collect2: ld returned 1 exit status


Here's the result of next attempt:


export LPATH=/usr/ccs/pa/usr/ccs/lib:/usr/lib:/opt/langtools/lib
export LDOPTS="-v"
export SDKROOT=/usr/ccs/pa
gcc -v -march=1.1 -I/myinc -L/mylibs mylib1.a prog.c

/usr/ccs/pa/usr/ccs/lbin/ld32 -v -z -u main -u __gcc_plt_call /usr/ccs/pa/usr/ccs/lib/crt0.o unix98.o -L/mylibs -L/usr/ccs/pa/usr/ccs/lib -L/opt/langtools/lib -L/opt/hp-gcc-4.4.3/lib/gcc/hppa1.1-hp-hpux11.11/4.4.3 -L/usr/ccs/lib -L/opt/langtools/lib -L/opt/hp-gcc-4.4.3/lib mylib1.a /var/tmp//cconAqDU.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh
LPATH is : /usr/ccs/pa/usr/ccs/lib:/usr/lib:/opt/langtools/lib
Loading /usr/ccs/pa/usr/ccs/lib/crt0.o:
/usr/ccs/pa/usr/ccs/lbin/ld32: Can't open unix98.o
/usr/ccs/pa/usr/ccs/lbin/ld32: No such file or directory
collect2: ld returned 1 exit status


ctr0.o is now OK but unix98.o is not and there is no unix98 file for PA-RISC.

Any suggestion will be appreciated.
Sorry for the long post.
5 REPLIES 5
Dennis Handly
Acclaimed Contributor
Solution

Re: Problem when compiling PA-RISC code on Itanium

>I need to link new C code with a legacy library (PA-RISC).

This is only supported using HP's compilers and only if you are running on Integrity.
http://www.hp.com/go/xpade

>is supplied with PA-RISC libraries, so I assumed it would be simple.

No, these shlibs are there only for running applications, not development.

>crt0.o unix98.o

These would need to be absolute paths.
Gilles Allard
Advisor

Re: Problem when compiling PA-RISC code on Itanium

Hi Dennis
>This is only supported using HP's compilers and only if you are running on Integrity.
>http://www.hp.com/go/xpade
If you look at my original post, gcc worked fine and gcc is using the HP linker.

>>crt0.o unix98.o
>These would need to be absolute paths.
There is no PA-RISC version of unix98.o
Rajesh K Chaurasia
Valued Contributor

Re: Problem when compiling PA-RISC code on Itanium

How did you know gcc worked fine? The compiled code would have used Integrity native header files from /usr/include. Even if the code compiles, it may not work fine depending on structure layout and size differences between PA-RISC and Integrity HP-UX.

As Dennis suggested, what you are trying to accomplish is supported using HP XPADE (PA-RISC cross development environment for Integrity). XPADE provides PA-RISC header files, libraries and special object files e.g. crt0.o, unix*.o suitable for PA-RISC code compilation and linking on Integrity.

unix95.o is present in XPADE (/opt/XPADE/v3/usr/lib/unix95.o)

Regards
-Rajesh
Dennis Handly
Acclaimed Contributor

Re: Problem when compiling PA-RISC code on Itanium

>gcc worked fine and gcc is using the HP linker.

gcc didn't work fine because you have linker errors. gcc includes the link step.

>There is no PA-RISC version of unix98.o

That's correct. An absolute path to where you copied them.

>Rajesh: The compiled code would have used Integrity native header files from /usr/include. Even if the code compiles, it may not work fine depending on structure layout and size differences between PA-RISC and Integrity HP-UX.

Ideally the headers are the same between the two but with #if.
Gilles Allard
Advisor

Re: Problem when compiling PA-RISC code on Itanium

Thank you
XPADE is the solution and it works fine.