[patch, spu] More flexible --with-sysroot to enable "common" PPU/SPU sysroot
Trevor_Smigiel@playstation.sony.com
Trevor_Smigiel@playstation.sony.com
Fri Nov 14 22:41:00 GMT 2008
Ulrich,
Yes, this patch is OK for mainline and 4.3.
Trevor
* Ulrich Weigand <uweigand@de.ibm.com> [2008-11-14 13:50]:
> Hello,
>
> for the spu-elf target, there is no "native" system, and therefore GCC is
> always configured as a cross-compiler. This causes the compiler to look
> into the usual ${prefix}/${target}/include and ${prefix}/${target}/lib
> directories for SPU header and library files.
>
> However, this is sometimes not an ideal solution: For example, we are
> building a toolchain providing a pair of x86->powerpc and x86->spu
> cross compilers to enable cross-development of Cell/B.E. code from an
> x86 machine. For the x86->powerpc compiler, a natural choice is to
> use the --with-sysroot option and provide a "sysroot image" structured
> just like a native powerpc installation is.
>
> Now, if we already have a "sysroot image" from a Cell/B.E. system,
> this will also include the SPU header and library files, at locations
> like ${sysroot}/usr/spu/include and ${sysroot}/usr/spu/lib. It would
> be ideal if there were a way to build the x86->spu compiler in a way
> so it simply uses those paths into the sysroot.
>
> However, this is currently not really possible. If we just build the
> compiler with the default paths, it will not look into that sysroot
> at all. If we use --with-sysroot, however, it will attempt to use
> paths corresponding to a "native" installation for the SPU target.
>
> As mentioned above, there is no "native" SPU system, but GCC will still
> use the usual defaults (${sysroot}/lib and ${sysroot}/usr/lib for
> libraries, ${sysroot}/usr/local/include and ${sysroot}/usr/include
> for header files). There is no way to give a --with-sysroot argument
> that allows GCC to find the SPU files in a "common" sysroot as refered
> to above.
>
> Some time ago Ben posted a patch to this list that we were using to
> address this problem:
> http://gcc.gnu.org/ml/gcc-patches/2006-12/msg01093.html
>
> This patch reworked the SPU backend to use "/usr/spu/include" and
> "/usr/spu/lib" as the paths for a "native" system, which means that
> by pointing --with-sysroot to the same sysroot as the powerpc cross-
> compiler, we can support a common sysroot.
>
> However, this never got accepted because some valid objections were
> raised; in particular, this approach hard-codes an installation path
> of /usr/spu, which may not always be the case (e.g. if you use "spu-elf"
> instead of "spu" as target name, or use a different prefix for the
> spu cross-compiler on Cell).
>
> I'd like to take this issue up again and propose a modified version of
> the patch. This version changes the SPU back-end to simply define
> the "native" install paths as "/include" and "/lib" -- just like the
> GNU target does, for example.
>
> This allows to use a "common sysroot" as in the case above by building
> the SPU cross-compiler with --with-sysroot=${sysroot}/usr/spu, but it
> also allows users with a different filesystem layout to choose the
> path appropriate for them.
>
> Trevor, Andrew, would this patch be OK for mainline (and possibly 4.3)?
>
> Thanks,
> Ulrich
>
>
> ChangeLog:
>
> * config/spu/spu-elf.h (STANDARD_STARTFILE_PREFIX_2): Disable default.
> (STANDARD_INCLUDE_DIR): Redefine to "/include".
> (LOCAL_INCLUDE_DIR): Undefine.
> * config/spu/t-spu-elf (NATIVE_SYSTEM_HEADER_DIR): Define.
>
>
> diff -urNp gcc-4.3.2/gcc/config/spu-orig/spu-elf.h gcc-4.3.2/gcc/config/spu/spu-elf.h
> --- gcc-4.3.2/gcc/config/spu-orig/spu-elf.h 2008-11-05 22:04:23.000000000 +0100
> +++ gcc-4.3.2/gcc/config/spu/spu-elf.h 2008-11-05 22:07:19.000000000 +0100
> @@ -24,6 +24,23 @@
> asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
>
>
> +/* The following macros define "native" directory locations; on the SPU,
> + these are used only when building the compiler with --with-sysroot.
> + This can be used to build a pair of PPU and SPU cross-compilers with
> + a common sysroot; the SPU compiler will search for its files in
> + ${sysroot}/include and ${sysroot}/lib. */
> +
> +/* STANDARD_STARTFILE_PREFIX_1 is "/lib", which we keep.
> + STANDARD_STARTFILE_PREFIX_2 is "/usr/lib" -- we remove this. */
> +#undef STANDARD_STARTFILE_PREFIX_2
> +#define STANDARD_STARTFILE_PREFIX_2 ""
> +
> +/* Use "/include" instead of "/usr/include". */
> +#undef STANDARD_INCLUDE_DIR
> +#define STANDARD_INCLUDE_DIR "/include"
> +
> +/* We do not provide any "/usr/local/include" directory on SPU. */
> +#undef LOCAL_INCLUDE_DIR
>
> /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
> the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
> diff -urNp gcc-4.3.2/gcc/config/spu-orig/t-spu-elf gcc-4.3.2/gcc/config/spu/t-spu-elf
> --- gcc-4.3.2/gcc/config/spu-orig/t-spu-elf 2008-11-05 22:04:23.000000000 +0100
> +++ gcc-4.3.2/gcc/config/spu/t-spu-elf 2008-11-05 21:17:29.000000000 +0100
> @@ -14,6 +14,9 @@
> # along with GCC; see the file COPYING3. If not see
> # <http://www.gnu.org/licenses/>.
>
> +# Define system directory to match STANDARD_INCLUDE_DIR in spu-elf.h,
> +# allowing combined SPU/PPU sysroot builds.
> +NATIVE_SYSTEM_HEADER_DIR = /include
>
> # Suppress building libgcc1.a
> LIBGCC1 =
> --
> Dr. Ulrich Weigand
> GNU Toolchain for Linux on System z and Cell BE
> Ulrich.Weigand@de.ibm.com
More information about the Gcc-patches
mailing list