This last week or so has been a time to document things,
clean things up, and perhaps package up some things more
nicely.  Well, in the case of cross-building ld, it needs
all three.  It would be easier to clean things up and then
document things than it would be to just document the way
things are.

Since I have been using tools that have been installed on
a development machine at Sun, I am not the master of all
my tools.  I have written a message or two explaining how
precarious the situations is.

The issue actually has come up, recently.  I was asked
if the ld we are using now is what can be built from
usr/src/cmd/sgs in our workspace.  I guess so.

Let's see ... how is that built?

Ooops!  First of all, I did some damage by sprinkling
calls to kprintf() all over various source files that are
used for libraries that are reused both by ld and rtld,
and some other tools.  Not good.  It is definitely bad to
try to call kprintf() on ld running on x86.  The x86 libc.so
has never heard of kprintf().

OK, so I fixed things so that kprintf() is called
conditionally.  A call to kprintf() is emitted by the
preprocessor only if the symbol USE_KPRINTF is defined.
I define it only in the Makefile for rtld for PowerPC.

OK, that problem is out of the way.  Back to the original
question.

That's not pretty.  I dug up some old email messages.
The way it was done involves some manual overrides and
using 'make -k'.  Overrides of make macros I can live with.
But, 'make -k' is evil.  And, I don't want to be the one
stuck writing up documentation that involves 'make -k'.
It generates hundreds, perhaps thousands of lines of error
messages -- more than I care to keep track of.  Somehow,
it is hard for me to feel much confidence in the results,
even if I do see an 'ld' executable pop out after the
build is done.

Besides, I have this thing about how subsets should work.

So, I created a new makefile in usr/src/cmd/sgs,
'Makefile.cross', which builds the subset needed to
build ld.  That way '-k' is not needed.  If you get
any error, then it should be taken seriously.  To go
along with the new makefile, there is a new script,
usr/src/cmd/sgs/make-cross-ld, which modifies the
environment to force CC, LD, and AS to the values
appropriate for a cross-build, and fixes a few other
macros, and then runs:

  make -f Makefile.cross

That ought to be easier to document.  In fact, I hope that
the new script and Makefile.cross _is_ the documentation.

You should see the changes in sgs in the next update of
the svn repository.

-- Guy Shaw


Reply via email to