1

I have some code written predominantly in C which compiles on HP-UX PA-RISC, HP-UX Itanium, and Solaris SPARC platforms.

My PA-RISC machine is so far EOL its untrue, and I have a client that I need to support on that architecture.

Is it possible to compile C code on a machine other than a HP-UX PA-RISC box, and have it execute fine when the binaries are moved on a PA-RISC machine?

Nick
  • 1,116
  • 2
  • 12
  • 24
  • 3
    This is called "cross compilation." GCC supports it reasonably well; you will have to compile GCC from source and do a bunch of fiddly manual setup, but you should be able to get a compiler on one of your less-geriatric machines that generates code for PA-RISC. See for instance http://wiki.osdev.org/GCC_Cross-Compiler -- this is geared for people working with free-software OSes and/or Windows, but you should be able to work it out. – zwol Sep 29 '16 at 14:28
  • Check the man-pages for gcc/g++... `man g++-6 | grep -A100 HPPA` – Mark Setchell Sep 29 '16 at 14:38
  • How important is *testing* your compiled code *before* you deliver it to your customer? I'd think you'd need to keep a PA-RISC machine around just for testing, and if it's there for testing you might was well compile on it. – Andrew Henle Sep 29 '16 at 14:42

1 Answers1

4

When HP introduced Itanium, I seem to recall that there was a (HP) cross-compiler that could produce Itanium code on a PA-RISC machine. I am, however, not aware of something that works the other way round.

I also remember HP used to run a number of public servers you could use for free to compile for Itanium (not sure for PA-RISC, though, and not sure if they still do)

gcc is conceptually able to run on one platform and cross-compile to some other, it is, however, not exactly trivial to build it for PA RISC, due to a number of peculiarities of HPUX. There are quite a number of references on the net of people who have started to do this, but I have found none so far who actually succeeded.

tofro
  • 5,640
  • 14
  • 31
  • I am not sure what you are getting at here. It is easy to build a cross-compiling GCC targeting e.g. ARM-processors. What makes it different when we're talking PA-RISC backend? If GCC has a code generator for the ISA, it should be trivial - or am I misunderstanding completely? :) – Morten Jensen Sep 29 '16 at 14:45
  • 1
    @MortenJensen I propose you simply have a quick glance on the shortcomings, glitches and peculiarities of a **native** gcc for HPUX 11i (The last version I know that has been ported is 4.2.x, BTW) - It's been a while that I last looked, but you'll probably find that gnu-ld would not be able to link against shared libraries, a number of non-supported features, requirements to use the native linker, and so on and so forth. Extrapolate from there what it takes to build a cross-compiler instead of a native one. Building an ARM cross-compiler is probably a piece of cake vs. a PA-RISC one. – tofro Sep 29 '16 at 14:53
  • Thanks for elaborating :) These are all issues I wasn't aware of... I'm mainly cross-compiling to mainstream architectures with well-supported ISAs (mostly ARM). Do you think it would be feasible to run the native gcc compiler under QEMU? It seems to support the PA-RISC ISA, but I've only tried QEMU with simple C programs, so don't know how much work it would take to make GCC run under QEMU. -- see http://hppaqemu.sourceforge.net/ – Morten Jensen Sep 29 '16 at 15:05
  • @MortenJensen Nice, didn't know QEMU has (some, according to the linked page) PA-RISC support, thanks for the link. The linked page doesn't look like the emulation is at a very sophisticated level yet, though. In order to have an HP compiler run on it, you'd need full HPUX 11 running - I doubt they're that far down the road yet. Even then you'd have to obtain a proper HPUX (and compiler, *acc*) license, and I don't think you still can get it from HP. – tofro Sep 29 '16 at 16:23