Subject: Re: arm26 compiler fun
To: Ben Harris <bjh21@cam.ac.uk>
From: Richard Earnshaw <rearnsha@arm.com>
List: tech-toolchain
Date: 05/08/2000 13:17:48
> I built a more-or-less complete arm26 system with a compiler that didn't
> override STRUCTURE_SIZE_BOUNDARY over the weekend, and it managed to boot
> multi-user over NFS this morning without any unfamiliar bugs, so I think
> I shall keep the compiler like that.
> 
> Is there anything else in config/arm/netbsd.h I should get rid of?

Well...

Things to consider are:

  /* Since we always use GAS as our assembler we support stabs.  */
  #define DBX_DEBUGGING_INFO 1

If you are using ELF, then it would be better to switch to DWARF debugging.

  /* On the ARM `@' introduces a comment, so we must use something else
     for .type directives.  Most NetBSD platforms use %, but we use #
     because of some legacy assemblers.  */
  #undef TYPE_OPERAND_FMT
  #define TYPE_OPERAND_FMT "#%s"

I'd switch this to % as the comment suggests (the FSF version of gcc uses 
%).


  #undef FUNCTION_PROFILER
  #define FUNCTION_PROFILER(STREAM,LABELNO)                                
   \
  {                                                                        
   \
    fprintf(STREAM, "\tmov\t%sip, %slr\n", REGISTER_PREFIX, 
REGISTER_PREFIX); \
    fprintf(STREAM, "\tbl\tmcount\n");                                     
   \
  }

In ELF the default is normally to not prefix user symbols with '_', so 
this would put mcount in user space.  You should look at other targets and 
see what they do.

  /* NetBSD uses the old PCC style aggregate returning conventions. */
  #undef DEFAULT_PCC_STRUCT_RETURN
  #define DEFAULT_PCC_STRUCT_RETURN 1

  /* Although not normally relevant (since by default, all aggregates
     are returned in memory) compiling some parts of libc requires
     non-APCS style struct returns.  */
  #undef RETURN_IN_MEMORY

Get rid of both of these (backwards compatibility hacks).  There are some 
changes you will have to make to get the softfloat to compile (it makes 
some broken assumptions about structure returning), but it is better to be 
rid of this deviation from the standard compiler.

Finally, you want to override LINK_SPEC (after including the standard 
netbsd.h).  The definition in FSF distribution adds -X, which strips local 
symbols from linked programs (which means that they are 1) smaller; 2) 
easier to debug).  That is, add something like this after 
CPP_FLOAT_DEFAULT_SPEC:

  #undef LINK_SPEC
  #define LINK_SPEC \
   "-X \
    %{assert*} \
    %{shared:-shared} \
    %{!shared: \
      -dc -dp \
      %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
      %{!static: \
        %{rdynamic:-export-dynamic} \
        %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
      %{static:-static}}"

Richard.