#3250 new defect

Remove Use of bsp_specs

Reported by: Joel Sherrill Owned by:
Priority: normal Milestone: Indefinite
Component: build Version: 5
Severity: normal Keywords:
Cc: Blocked By:


The bsp_specs file in each BSP directory is GCC specific and a barrier to supporting other compilers including clang/llvm. The bsp_specs file is used in a variety of ways including some odd build system dependencies and this ticket is to track eliminating those uses and the direct use of bsp_specs themselves for extending GCC options.

The primary use of the bsp_specs file is to extend GCC's notion of what to link with. The bsp_specs itself commonly specifies:

  • start.o file
  • program entry point
  • crt[in].o or crtbegin.o/crtend.o
  • linker script
  • Frequently, arguments which are implicitly passed to ld.

This is typical and from a recently added BSP:

%rename endfile old_endfile
%rename startfile old_startfile
%rename link old_link

%{!qrtems: %(old_startfile)} \
%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s -e _start}}

%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}

%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

Note that it has the implicit "-dc -dp -N" arguments which are passed to ld.
The -dc and -dp options are equivalent and assign space to common symbols even with linking with -r. Why these two options are included is a mystery lost to time. Similarly the -N sets the .text and .data sections to be readable and writable and do NOT page align the data segment. This option is also a blast from the ancient past and likely should not be used.

The "-qrtems" option is used with this pattern when compiling and linking RTEMS programs:

-B${PREFIX}/${BSP}/lib/ -specs bsp_specs -qrtems

The -B says that the following directory is a system directory. It is treated as a "lib" directory and is also assumed to have an include/ subdirectory. They are added to the linker and include search paths, respectfully. The -specs option references the bsp_specs and adds the -qrtems options which are then tripped by specifying -qrtems. Every part of this must be eliminated and performed in a manner that is more amenable to using a compiler other than GCC.

In order to eliminate the bsp_specs, the arguments used in each BSP's version will have to be reviewed, made common, and then eliminated. A similar effort was performed when the BSP specific make-exe rules were eliminated from the "make/custom" files and a common pattern was put in place.

In addition to using the bsp_specs to specify details about linking and include files, the build system has quite a few odd dependencies on the presence of bsp_specs:

  • all BSP configure.ac use bsp_specs like this:

The idea was that this was a unique file to ensure the script was in the right directory. This can be changed to use a specfic make/custom/*.cfg file and not lose any integrity checking.

  • all BSP Makefile.am have this:
dist_project_lib_DATA = bsp_specs

That can just be removed when we don't use the file.

  • ./aclocal/check-bsps.m4 uses it to see if it is BSP directory
  • bootstrap uses it generate the list of BSP directories for the libbsp/*/acinclude.m4 files
  • Other references are either comments or obvious uses of it in

some invocation of GCC.

Change History (2)

comment:1 Changed on Dec 19, 2017 at 5:07:13 PM by Joel Sherrill <joel@…>

In b0b93c8a/rtems:

gensh4: Simplify bsp_specs

Updates #3250.

comment:2 Changed on Feb 5, 2018 at 11:37:24 PM by Chris Johns

Component: adminbuild
Note: See TracTickets for help on using tickets.