Operating System - HP-UX
1831403 Members
3011 Online
110025 Solutions
New Discussion

Converting an application that used cfront and gcc to compile to now use aCC

 
James Elliott
New Member

Converting an application that used cfront and gcc to compile to now use aCC

I have recently taken over the maintenance of an application that used both the cfront and gcc compilers in tandem. The cfront compiler was used to generate the *.o files and the gcc compiler was used to create the *.d files.

As a part of an upgrade project, we have been forced to switch to using the aCC compiler (v.01.21). As I am new to this compiler, I cannot get the application to compile and link. I have attempted to replace both compilers as well as the cfront compiler only. I am at a loss as to how to proceed. This is the original part of the makefile that contained cfront and gcc. The application is running HP-UX 10.20.

CC=CC
STDCCFLAGS= +eh +a1 +DAportable -Wl,+s -z
objects := $(patsubst %.cpp,%.o,$(wildcard *.cpp))

%.o: %.cpp
$(CC) -I. $(STDCCFLAGS) $(ALL_INCLUDES) -c $(CFLAGS) $< -o $@

%.o: %.cxx
$(CC) $(STDCCFLAGS) -DCLASS_NAME=$(CLASS_NAME) -I. -I../lib $(ALL_INCLUDES) -c $(CFLAGS) $< -o $@

%.d: %.cpp
$(SHELL) -ec 'g++ -MM -I. $(ALL_INCLUDES) $(CPPFLAGS) $< | sed '\''s/$*\\.o[ :]*/& $@/g'\'' > $@'

%.d: %.cxx
$(SHELL) -ec 'gcc -MM -I. $(ALL_INCLUDES) $(CPPFLAGS) $< | sed '\''s/$*\\.o[ :]*/& $@/g'\'' > $@'

%.d: %.cxx
$(SHELL) -ec 'gcc -MM -I. $(ALL_INCLUDES) $(CPPFLAGS) $< | sed '\''s/$*\\.o[ :]*/& $@/g'\'' > $@'


Any assistance on how I could get this to work with the aCC compiler would be greatly appreciated.
5 REPLIES 5
David Lodge
Trusted Contributor

Re: Converting an application that used cfront and gcc to compile to now use aCC

A couple of questions:
1) Why switch to aCC? gcc is free, fast, and probably the best C compiler in the world.
2) What is the actual compiler issue - I haven't used cfront - but do you get issues compiling the code, or just how to start?

dave
James Elliott
New Member

Re: Converting an application that used cfront and gcc to compile to now use aCC

In response to your questions:
1) We are using the RogueWave DBTools.h++ and Tools.h++ libraries. We also use Oracle and had upgraded our Oracle version from 7.2 to 7.3.4, which forced an upgrade to the RogueWave products. The upgraded RogueWave products require the aCC compiler version 01.21 to compile the RogueWave product. The, according to all the documentation I could find, in order to use the RogueWave libraries built with aCC, all applications have to be compiled with aCC.
2) The compiler issue is that I can get the portion of the application that uses templates to appear to compile and correctly create the user defined static library (it's called libmcr.a). The issue arises when attempting to compile the application executable. The compile appears to work, however when that application attempts to link, it throws an error stating "An unexpected end of file has been found in libtux.a" and the linking blows up. Libtux.a is fine because I have used that lib in a seperate application on the same box and that appication uses the aCC compiler.
A. Clay Stephenson
Acclaimed Contributor

Re: Converting an application that used cfront and gcc to compile to now use aCC

Hi James:

This shouldn't be too difficult. The good news is that aCC will recogize myfile.C as C++ source, myfile.cpp as C++ source, and myfile.c as C source. I assume that you have no K&R C source because aCC will not compile it; it does not speak K&R C. If you have K&R source you will need the ANSI/C compiler in addition to aCC. You main problem is the makefiles.

CC=CC
STDCCFLAGS= +eh +a1 +DAportable -Wl,+s -z
objects := $(patsubst %.cpp,%.o,$(wildcard *.cpp))

%.o: %.cpp
$(CC) -I. $(STDCCFLAGS) $(ALL_INCLUDES) -c $(CFLAGS) $< -o $@


I think the main thing you need to do is make sure that /opt/aCC/bin is in your PATH and then the CC=CC above should be CC=aCC. Study the man pages for aCC to see what compiler options you want. You almost certainly want the +DAportable unless you are only compiling for one architecture.

Important note: make is one of the few utilities that is VERY sensitive to whitespace.
To it, 8 spaces ain't the same as a tab. Make definitions should all resemble this:

$(PROG) : $(OBJECTS) $(LIBES1)
$(CC) $(OBJECTS) -L$(LDIR) $(LIBES) -o $(PROG)
strip $(PROG)

Don't worry about this particular rule just note that the commands are preceded by a single tab with no other spaces.

You should be able to really trim down your suffix rules to simply those that process
.cpp's, .C's, and .c's - all of those will invoke aCC.

You might consider renaming all the .cpp to .C since that is the more modern convention for C++ source and will mean 1 less rule. When you get your suffix rules like you want them, I would put them in a single file and let your make file include the file. By the way, the first thing to try is to remove the suffix rules and leave the CC=aCC define. I suspect that the default suffix rules will fix you unless you are also doing something like Oracle Pro/C and you need rules to deal with the invocation of the Pro/C compiler.

This should get you started, Clay
If it ain't broke, I can fix that.
James Elliott
New Member

Re: Converting an application that used cfront and gcc to compile to now use aCC

Thanks alot Clay. This helps alot.

However, I still have questions regarding the gcc portion. The gcc appears to create the definition files (*.d). Can I get aCC to perform this function? The current compilation mechanism does not work without the definition files.

The reason I am looking for a parallel to the current methods used is the application that this makefile is used for is very convoluted and in my opinion far more complex that it needs to be. Therefore, I am trying not to make alot of changes to the code or compilation mechanisms because as you know, you try and fix one thing and end up breaking 3 others.
A. Clay Stephenson
Acclaimed Contributor

Re: Converting an application that used cfront and gcc to compile to now use aCC

Hi again James,

You are going to have to rethink. You see, aC++ doesn't retain the old cfront concept of defmap files; it doesn't need them. Rather than me trying to explain, it's probably simpler to point you to the 'HP aC++ Transition Guide (HP C++ to hp aC++)'; it pretty much covers everything you need to know.

http://h21007.www2.hp.com/dspp/tech/tech_TechDocumentDetailPage_IDX/1,1701,1744,00.html


If it ain't broke, I can fix that.