adc@cpsvax.cps.msu.edu (Alan Cabrera) (05/28/89)
I'm attempting to install g++ 1.35.0 on our Convex C-220 running Convex Unix release V7.0. The makefile barfs when compiling newld.c. An exerpt from the make output: gcc version 1.35 ../gcc/cpp -v -DTARGET=-1 -DSTANDARD_SEARCH_DIRS="/mnt/adc/lib", "/lib", "/usr lib", "/usr/local/lib" -DSOS -DESKIT -DSOS -DESKIT -undef -D__GNUC__ -Dconvex - parsec -Dunix -D__convex__ -D__parsec__ -D__unix__ newld.c /tmp/cc001716.cpp GNU CPP version 1.35 ../gcc/cc1 /tmp/cc001716.cpp -quiet -dumpbase newld.c -g -version -o /tmp/cc00 716.s GNU C version 1.35 (convex) compiled by GNU C version 1.35. newld.c: In function enter_file_symbols: newld.c:1807: invalid use of undefined type `struct nlist' and so on... Anybody have any idea what's going on? Alan D. Cabrera adc@cpsvax.cps.msu.edu
csmith@convex.UUCP (Chris Smith) (05/28/89)
No flavor of GNU ld will work easily on a Convex because the a.out
format isn't right. Here's an ld++ program that runs /bin/ld. If you
have Icon, you can just run it, otherwise I guess you have to write
something equivalent.
Touch newld.o and ld++ in the g++ build directory (to shut make up),
and install this as /usr/local/lib/ld++.
(PS: there is a gotcha in stream.cc -- convex _doprnt returns void,
not a status indication, so take out the "stat = " part of the
"stat = _doprnt ..." line, and add "stat = <the right thing>".
Let me know if you figure out what the right thing is... I'm using 0
for now.)
---------- ld++.icn ----------
procedure main (argv)
# Get scratch file names
pid := read (open ("echo $$", "p")) | stop ("can't read pid")
codefile := "/tmp/" || pid || ".out"
hookfile := "/tmp/" || pid || ".o"
# Scan args. Remove -C. Remove "-o name" and remember it.
ldargs := ""
args := create !argv
while arg := @args do
case arg of
{
"-o" : outfile := @args
"-C" : {}
default: ldargs ||:= " " || arg
}
/outfile := "a.out"
# load the program with -r, feed that to nm, open a pipe to the nm output.
inf :=
open ("ld -r -o " || codefile || ldargs || " && nm -p " || codefile, "rp")
# open a pipe to the assembler
outf := open ("/usr/local/lib/gcc-as -o " || hookfile, "wp")
# write the hooks file and assemble it
write_hooks (inf, outf)
# see if it all worked
if integer (close (inf)) ~= 0 | integer (close (outf)) ~= 0 then
{
system ("rm -f " || codefile || " " || hookfile)
stop ("load failed")
}
# now load in the hook file and write the real output file
system ("ld -o " || outfile || " " || codefile || " " || hookfile ||
" && rm " || codefile || " " || hookfile)
end
procedure write_hooks (inf, outf)
constructors := []
destructors := []
every !inf ?
if tab (find ("__GLOBAL_$I$")) then
put (constructors, tab (0))
else if tab (find ("__GLOBAL_$D$")) then
put (destructors, tab (0))
# in .text, list of constructor addresses, one per word, terminated by zero
write (outf, ".text")
write (outf, ".globl ___CTOR_LIST__")
write (outf, "___CTOR_LIST__:")
every write (outf, "\tds.w ", !constructors)
write (outf, "\tds.w 0")
# in .data, linked list of destructor addresses (link in first word,
# destructor address in second word), terminated by zero link,
# pointed to by ___DTOR_LIST__ .
write (outf, ".data")
write (outf, ".globl ___DTOR_LIST__")
if *destructors = 0 then
write (outf, "___DTOR_LIST__:\n\tds.w 0")
else
{
d := create !destructors
write (outf, "\tds.w 0\n\tds.w ", @d)
while
write (outf, "\tds.w .-8\n\tds.w ", @d)
write (outf, "___DTOR_LIST__:\n\tds.w .-8")
}
end