Using newlib (was: [Efi332] Building newlib/libgloss for MPC555)

Gunter Magin gm
Mon Aug 8 09:34:46 UTC 2005


Hello 

On Sun, Aug 07, 2005 at 08:16:00PM -0700, David Eicher wrote:
> 1) Apparently there is no libgloss.a, rather five libs:
> 
> Libmbx.a
> Libyk.a
> Libmvme.a
> Libnosys.a
> Libsim.a

libgloss is a library especially crafted for a particular target
board, like the MBX family (libmbx.a) or the MVME family of VME boards
(libmvme.a). The common part of libgloss (read(), write()) is generic, and
is duplicated in each lib. They rely on the outbyte()/inbyte() functions,
which are special parts to glue between the generic libgloss functions
and the available board ressources (monitor functions, HW ressources,
whatever). These special parts are different for each particular libgloss
library.

> It appears the Make install I did in the libgloss directory put these libs
> in my usr/local/powerpc-elf/lib directory, neat!

"make" actually built all variants, and "make install" put it into the
lib path. make also created all multilib variants (nof, le, and friends)
of the library, and installed it in the relevant subdirectory of the
library install tree.

> When I tried to build my target code I got unresolved references. So I added
> a -lyk to my command to link and all the  unresolved references disappeared

Is libyk.a the libgloss for your particular target board?

> except for one:
> 
> __errno
> 
> I found an example of an errno routine in rs6000, so added the code to one
> of the routines I modified for libgloss. But now I try to "make" libgloss
> again....., it says "no make file found", and "nothing to do". It appears
> that after I built it the first time, it renamed the makefile to makefile.in
> and now will no longer build. 

Hmmm. makefile.in is the input for the autoconf tool, which is called
with the configure call. If you haven't deleted the Makefile, chances
are, you are not in the right directory. Make sure you call make
somehwere in your
build tree, not in your source tree. For building libgloss, go to
<newlib-build-root>/powerpc-elf/libgloss and check for your makefile. 

Hint: If you have modified Makefile to add new files for building a (new)
libgloss for your particular target, in the addition to the stock versions
of libgloss, you better do these mods in the corresponding makefile.in in
the source tree, because the Makefile is considered as a derived file,
and subject to being clobbered by the build system. That effectively
destroys your modifications, and they are lost without traces...

> Can anyone suggest what is the correct way to make a change to libgloss?

check the makefile.in and the sources in the __source__ tree for a
particular available target, like the mbx board, duplicate these files,
if they are not common, and modify the makefile.in to make use of the
changes. (I think you did this step already if I am right with the
assumption with libyk)

The next step is to rerun configure. The most safe option (recommended)
is to run configure from the newlib build top directory. You may try to
run configure in some subdirectory of the newlib build tree, but you
have to supply a myriad of options. Check the config.status files in
every directory.

Then either rebuild all newlib (safe, but dumb), or go into the libgloss
subdir, and rebuild only libgloss (smart, and more time effective,
though a little trickier, as you might miss something - just check if
the relevant .o files got rebuilt). And finally do a make install in
the libgloss dir.

If you have any doubt or there are errors in the linking phase of your
app build process, play safe and do the whole build/install process.

But I guess you got it right, it's just that you fetch the wrong libs
for app build.

> Can anyone explain the differences between the five libs and suggest which
> one I'm suppose to be using?

Actually, I fear you should modify makefile.in in a way to create a 6th
library especially for your HW. Give gcc a -l<your libgloss name> for
linking, like it would be -lmbx if you wanted the mbx variant of libgloss.

> There errors I'm getting look like this:
> 
> Dave at Dell8400 /usr/local/zfi555FBMonitor
> $ make
> powerpc-elf-gcc -L/usr/local/powerpc-elf/lib
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You shouldn't need to explicitly state the lib path, if your installation
is sound. If the linker doesn't find the libs, something is wrong with
your installation. Use gcc's -v option to see what parameters the gcc
frontend gives to the ld call, and check the map file generated by the
linker.

> /usr/local/zfi555FBMonitor/bin/pcmaster.o
> /usr/local/zfi555FBMonitor/bin/main.o -o .x 
                                          ^^^

A funny (unusual) target file name.... 

> -melf32ppc -Wl -Tdebug.dld
  ^^^^^^^^^^

Are you sure what this option means? I'd suggest to try -mcpu=555 or
-mcpu=505. 

> -Wl,-Map=main.map 
      ^^^^^^^^^^^^^

This is the map file I have been talking about above.

> -nostartfiles -lc -lm
                    ^^^^^^^^^^^^^

Good. You supply your own startup code, and it is included in the list
of files to be linked...

The rest are errors to be expected if a library is missing....

> /usr/local/powerpc-elf/lib/libc.a(makebuf.o)(.text+0x130): In function
> `__smakebuf':
...
> `_read_r':
> ../../../../../newlib-1.13.0/newlib/libc/reent/readr.c:58: undefined
> reference to `read'
> collect2: ld returned 1 exit status
> make: *** [main.elf] Error 1




More information about the Efi332 mailing list