GCC vs vendor-native compilers - porting tips
#1
GCC vs vendor-native compilers - porting tips
Hello everyone,
I hit a sore point here.

I couldn't get hold of aCC and aC+ (once upon a time, HP offered it for free. If anyone could hook me up, I'd appreciate).
So I went the GCC way.

I'm trying to build my benchmark tool on HP-UX and I hit the following error:

Code:
/opt/graphics/OpenGL/include/GL/gpHpInt.h:31: error: thread-local storage not supported for this target

After researching further, I found out that GCC is not compatible with some of the HP libraries. This is sad. I found the following online in a forum:
Code:
The gl.h header file includes glHpInt.h, which uses macros to make faster calls to OpenGL functions. The macros call through an array of function pointers that is declared as thread local storage.

gcc can't cope with the __thread storage type. You can avoid the entire macro mechanism and use normal function calls by using "-D__glHpInt_h__" to ifdef away the body of
glHpInt.h.

I managed to bypass that by using -D"__glHpInt_h__" on gcc, but then, I may be missing some of the performance enhancements, and that's the whole point of our workstations. =)))
I want to use HP's older GLUT exactly because of the performance enhancements.

But anyway, my main goal is just to get ANYTHING running at this point.

I hit a second sore point. On the Mac and on Linux, I don't need to use -lX11 and -lXext to build. I think all requirements are part of the native GL, GLU and GLUT libraries.
However, the functionality seems to be missing on HP-UX. I get the whole list of unsatisfied symbols:

XInternAtom
XPeekEvent
XDrawSTring
etc etc etc

However, I can't find x11 and xext:

Code:
# /usr/local/bin/gcc ./bench.c -o ./bench -D"__glHpInt_h__" -I/opt/graphics/OpenGL/include -I/usr/include/X -I/opt/graphics/OpenGL/contrib/libglut -I/opt/graphics/OpenGL/include -L/opt/graphics/OpenGL/lib -lGL -lGLU -lm -L/usr/lib/X11R6 -L/usr/lib -L/opt/graphics/OpenGL/lib -L/opt/graphics/OpenGL/contrib/libglut -lglut
collect2: ld terminated with signal 10 [Bus error], core dumped
/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (/var/tmp//ccrW4xG5.o) was detected. The linked output may not run on a PA 1.x system.
/usr/ccs/bin/ld: Unsatisfied symbols:
   XInternAtom (code)
   XPeekEvent (code)
   XVisualIDFromVisual (code)
   XFillRectangle (code)
   XDrawString (code)
   XInstallColormap (code)
   XCreateFontCursor (code)
   XSynchronize (code)
   XStoreColors (code)
   XSetWMProperties (code)
   XFreeColormap (code)
   XUngrabServer (code)
   XConfigureWindow (code)
   XSetCloseDownMode (code)
   XLoadQueryFont (code)
   XCloseDisplay (code)
   XOpenDisplay (code)
   XTranslateCoordinates (code)
   XUngrabPointer (code)
   XNextEvent (code)
   XResizeWindow (code)
   XCreatePixmap (code)
   XFlush (code)
   XGetVisualInfo (code)
   XEventsQueued (code)
   XKillClient (code)
   XSetWMProtocols (code)
   XGrabServer (code)
   XWithdrawWindow (code)
   XGetWindowProperty (code)
   XCreateColormap (code)
   XQueryExtension (code)
   XSync (code)
   XGetRGBColormaps (code)
   XDisplayString (code)
   XParseGeometry (code)
   XDestroyWindow (code)
   XAllocStandardColormap (code)
   XPending (code)
   XStoreColor (code)
   XDestroySubwindows (code)
   XRaiseWindow (code)
   XSelectInput (code)
   XCreateGC (code)
   XLookupKeysym (code)
   XSetWindowColormap (code)
   XFreeColors (code)
   XFillPolygon (code)
   XQueryColors (code)
   XDeleteProperty (code)
   XGrabPointer (code)
   XUnmapWindow (code)
   XIconifyWindow (code)
   XAllocColorCells (code)
   XMapWindow (code)
   XCreateWindow (code)
   XSetWMColormapWindows (code)
   XDrawLines (code)
   XChangeProperty (code)
   XRefreshKeyboardMapping (code)
   XFree (code)
   XChangeWindowAttributes (code)
   XSetRGBColormaps (code)
   XAllocColor (code)
   XDisplayName (code)
   XTextWidth (code)
   XAllocWMHints (code)
   XFreePixmap (code)
   XLookupString (code)
 
and with x11 and xext

Code:
# /usr/local/bin/gcc ./pandemic.c -o ./pandemic -D_HPUX_SOURCE -D"__glHpInt_h__" -I/opt/graphics/OpenGL/include -I/usr/include/X -I/opt/graphics/OpenGL/contrib/libglut -I/opt/graphics/OpenGL/include -L/opt/graphics/OpenGL/lib -lGL -lGLU -lm -L/usr/lib/X11R6 -L/usr/lib -L/opt/graphics/OpenGL/lib -L/opt/graphics/OpenGL/contrib/libglut -lglut -lXext     
/usr/ccs/bin/ld: Can't find library for -lXext
collect2: ld returned 1 exit status

Tips?

Thanks, as always.

Some investigation:

GCC complains that I am missing things like XCreateWindow, but the local libGLw.a provides XtCreateWindow. When GCC complains of missing XCreateColormap, I have on the system createColormap.

I'm beyond confused. =\
(This post was last modified: 04-30-2021, 03:31 PM by Shiunbird.)
Shiunbird
Administrator

Trade Count: (1)
Posts: 553
Threads: 45
Joined: Mar 2021
Location: Czech Republic
Find Reply
04-30-2021, 02:59 PM
#2
RE: GCC vs vendor-native compilers - porting tips
You might be missing some of the developer stuff that is included in the application CDs / DVD. I think even if you don't have the HP C/C++ compiler, you have to install some developer package to get basic functionality, even when you want to use gcc.
Additionally, you might have some PA-RISC revision problem 1.1 vs. 2.0 / 32 bit vs. 64 bit.
lunatic
insane in the mainframe

Trade Count: (0)
Posts: 150
Threads: 1
Joined: Apr 2019
Find Reply
04-30-2021, 03:42 PM
#3
RE: GCC vs vendor-native compilers - porting tips
Go on freenode irc and message "alver". He probably knows some leads on the HPE compilers.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,239
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
04-30-2021, 03:43 PM
#4
RE: GCC vs vendor-native compilers - porting tips
You need to look in the Applications CD's/DVD's for HP's compilers. Beware there are two types of media: code locked and unlocked ones. Of course, you want the unlocked ones.

X libraries should be installable directly from the OS core media, take a look at your media and load anything you missed during OS installation.

What version of HP-UX did you finally install?
TruHobbyist
Developer

Trade Count: (0)
Posts: 195
Threads: 21
Joined: May 2018
Find Reply
04-30-2021, 06:00 PM
#5
RE: GCC vs vendor-native compilers - porting tips
Hi everyone,

I went through every single directory and yes, the libraries are missing.
I think it's part of the HP C/C++ compiler bundle. I thought they were part of the TCOE package, which would make sense. Funnily enough, I found the libraries for X11 in the /usr/lib folder but ancient ones (R4), and this crashes during build.

I thought of going for freeglut, as I think it includes the X11 libraries, but I am really interested in the HP optimisations here (although I am bypassing them at the moment).

I ended up installing 11.11, as I heard this is the best version for the C8000. If I understood right, subsequent versions are aimed for servers and only happen to be compatible with the C8000.

64 bit is COMPLETELY broken. Even the pre-built binaries out of the box demos fail to run. The default GCC options correctly detect 2.0 32 bit as target architecture and text-only (lm and stdio) applications build just fine.

My Linux installation on the same workstation is 64 bit kernel and 32 bit userland, targeting 2.0, so I know the combo works. Linux has an old issue with hardware acceleration that I may even consider to find some bounty hunter to fix it. It's way beyond my coding skills but well documented. I digress. On Linux (hppa and Intel) and on Mac, -lGL -lGLU -lm -lglut are enough.

So my next steps are:
- Browse every single HP-UX image for the HP compilers. Try to find an unlocked one.
- Introduce myself to alver and kindly ask for his assistance.

In the meantime, I will focus on the text-only parts of my benchmark suite.

Edit:
I found this, so yes, you all were right. I am missing libraries.

CONVENTIONS      GLUT window and screen coordinates are expressed in pixels. The upper      left hand corner of the screen or a window is (0,0). X coordinates      increase in a rightward direction; Y coordinates increase in a      downward direction. Note: This is inconsistent with OpenGL's      coordinate scheme that generally considers the lower left hand      coordinate of a window to be at (0,0) but is consistent with most      popular window systems.      Integer identifiers in GLUT begin with one, not zero. So window      identifiers, menu identifiers, and menu item indexes are based from      one, not zero.      In GLUT's ANSI C binding, for most routines, basic types (int, char*)      are used as parameters. In routines where the parameters are directly      passed to OpenGL routines, OpenGL types (GLfloat) are used.      The header files for GLUT should be included in GLUT programs with the      following include directive:      #include <GL/glut.h>      Because a very large window system software vendor (who will remain      nameless) has an apparent inability to appreciate that OpenGL's API is      independent of their window system API, portable ANSI C GLUT programs      should not directly include <GL/gl.h> or <GL/glu.h>. Instead, ANSI C      GLUT programs should rely on <GL/glut.h> to include the necessary      OpenGL and GLU related header files.      The ANSI C GLUT library archive is typically named libglut.a on Unix                                    - 4 -        Formatted:  March 25, 2021 glut(3GLUT)                        GLUT                        glut(3GLUT) GLUT                                                                  GLUT                                    3.7      systems. GLUT programs need to link with the system's OpenGL and GLUT      libraries (and any libraries these libraries potentially depend on). A      set of window system dependent libraries may also be necessary for      linking GLUT programs. For example, programs using the X11 GLUT      implementation typically need to link with Xlib, the X extension      library, possibly the X Input extension library, the X miscellaneous      utilities library, and the math library. An example X11/Unix compile      line would look like:      cc -o foo foo.c -lglut -lGLU -lGL -lXmu -lXi -lXext -lX11 -lm

Edit 2:
I think I am looking for this:
bundle name, bundle short description, bundle revision, supported architecture, vendorB3899BA, C/ANSI C Dev Wkstns, r=B.11.11.01, a=HP-UX_B.11.11_32/64, v=

Does it make sense?
(This post was last modified: 04-30-2021, 11:10 PM by Raion.)
Shiunbird
Administrator

Trade Count: (1)
Posts: 553
Threads: 45
Joined: Mar 2021
Location: Czech Republic
Find Reply
04-30-2021, 10:17 PM
#6
RE: GCC vs vendor-native compilers - porting tips
Check with Alver, he would know better than anyone I know

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,239
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
04-30-2021, 11:11 PM
#7
RE: GCC vs vendor-native compilers - porting tips
I will contact him, thank you.

I'm trying to figure out as much as I can before coming to a stranger. I believe you should only ask for help when you exhaust your own resources.

But I think I got lucky. =))))

I went through my CDs here and I installed:
HP9000 Series 9000/700/800
                          HP-UX Application Software
                          CD Part Number - B3920-10497

But I found I have:
HP-UX Application Software
                      CD Part Number - 24998-12993
                            1 of 5 CDs
                        CD-ROM CONTENT LIST

And a very pretty sight:
CPL Product: B3899BA
Codeword Req.: No
        Size: 203734605
  Description:
HP C/ANSI C Developer's Bundle for HP-UX (S700)

I think this is what I need.

Edit:
Also found this beauty:
CPL Product: B3394BA
Codeword Req.: No
        Size: 58233585
  Description:
HP-UX Developer's Toolkit for 11.11
(This post was last modified: 05-01-2021, 09:08 AM by Shiunbird.)
Shiunbird
Administrator

Trade Count: (1)
Posts: 553
Threads: 45
Joined: Mar 2021
Location: Czech Republic
Find Reply
05-01-2021, 09:03 AM
#8
RE: GCC vs vendor-native compilers - porting tips
I made it!

Exactly the two packages listed above did the trick. (I also installed C++ while I was at it).
The X11 libraries are part of it.

While I was researching, I ended up finding someone on Stack Exchange who is willing to port Quake II to HP-UX. I hope he replies back to me!
I'm not sure where to document this, so here are the steps:

C8000 specific, to enable hardware acceleration (with thanks to jpstewart):

1. PHSS_34389
2. HWEnable11i_B.11.11.0612.458.depot
After that, the pesky message that comes up every time X loads complaining about the drivers stops appearing, replaced by a lovely HP logo.

Then:
3. B9007AA - HP C/aCC++ Developer's Bundle (including B3899AA - HP C/ANSI C Developer's Bundle and B3911DB - HP aC++ Compiler)
4. B3394BA - HP-UX Developer's Toolkit for 11.11
5. B6268AA - Graphics and Technical Computing Software (TCOE), including all the OpenGL libraries.

From here, HP documentation helped. To use their compiler, I followed their "OpenGL Implementation Guide for HP-UX 11.x" and came with the following build line:

cc -g -Aa +e -D_HPUX_SOURCE -z -I/opt/graphics/OpenGL/include -I/usr/include/X11R6 -I/opt/graphics/OpenGL/contrib/libglut ./bench.c -o ./bench -L/opt/graphics/OpenGL/lib -L/usr/lib/X11R6 -L/opt/graphics/OpenGL/contrib/libglut -ldld -lglut -lGLU -lGL -lXext -lX11 -lm
GLUT is, naturally, optional. If you use GLUT, you don't need to explicitly include GL and GLU. GLUT includes them.
I had to change only one line out of 800 from my original code that I built on Mac Mojave.

For the ones who wish to use GCC, I installed the following:
autoconf
bison
db
flex
gcc
gettext
libgcc
libincov
m4
gmake
zlib

With the following build command:
/usr/local/bin/gcc ./bench.c -o ./bench -D_HPUX_SOURCE -D_HPUX_SOURCE -I/opt/graphics/OpenGL/include -I/usr/include/X11R6 -I/opt/graphics/OpenGL/contrib/libglut -L/opt/graphics/OpenGL/lib -L/usr/lib/X11R6 -L/opt/graphics/OpenGL/contrib/libglut -ldld -lglut -lGLU -lGL -lXext -lX11 -lm
-D"__glHpInt_h__" bypasses HP's optimisations that require local thread storage, unsupported by GCC. Maybe -z is required, not sure now (too many things, details are going away).

Performance:

Using HP's compiler, it uses 17% of CPU. Using GCC, it uses 20% GPU.
My Xeon X5675 (3.06 GHz) needs 10% CPU.
(everything is single threaded hardcoded to refresh at 60fps)


I took the opportunity to compare the performance of my lazy prime calculator:
On GCC, it does it in 125 seconds.
HP's compiler binary does it in 108 seconds.

Thanks for all your help! Now I have everything I need to make sure all I write is portable.


Attached Files Image(s)
   
(This post was last modified: 05-01-2021, 04:37 PM by Raion.)
Shiunbird
Administrator

Trade Count: (1)
Posts: 553
Threads: 45
Joined: Mar 2021
Location: Czech Republic
Find Reply
05-01-2021, 11:14 AM
#9
RE: GCC vs vendor-native compilers - porting tips
Congrats and enjoy.
TruHobbyist
Developer

Trade Count: (0)
Posts: 195
Threads: 21
Joined: May 2018
Find Reply
05-01-2021, 03:39 PM
#10
RE: GCC vs vendor-native compilers - porting tips
Shiunbird, when you copy/paste text into the box don't select text colors, and hit "Paste as plain text" otherwise you'll break it for dark theme users.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,239
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
05-01-2021, 04:38 PM


Forum Jump:


Users browsing this thread: 1 Guest(s)