OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [doc/] [html/] [user-guide/] [compiler-and-linker-options.html] - Rev 706

Go to most recent revision | Compare with Previous | Blame | View Log

<!-- Copyright (C) 2003 Red Hat, Inc.                                -->
<!-- This material may be distributed only subject to the terms      -->
<!-- and conditions set forth in the Open Publication License, v1.0  -->
<!-- or later (the latest version is presently available at          -->
<!-- http://www.opencontent.org/openpub/).                           -->
<!-- Distribution of the work or derivative of the work in any       -->
<!-- standard (paper) book form is prohibited unless prior           -->
<!-- permission is obtained from the copyright holder.               -->
<HTML
><HEAD
><TITLE
>Compiler and Linker Options</TITLE
><meta name="MSSmartTagsPreventParsing" content="TRUE">
<META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="eCos User Guide"
HREF="ecos-user-guide.html"><LINK
REL="UP"
TITLE="eCos Programming Concepts and Techniques"
HREF="ecos-programming-concepts-and-techniques.html"><LINK
REL="PREVIOUS"
TITLE="Application Build Tree"
HREF="repository-app-build-tree.html"><LINK
REL="NEXT"
TITLE="Compiling a C++ Application"
HREF="compiling-cpp-app.html"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>eCos User Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="repository-app-build-tree.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="compiling-cpp-app.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="COMPILER-AND-LINKER-OPTIONS">Chapter 26. Compiler and Linker Options</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="compiler-and-linker-options.html#COMPILING-C-APP"
>Compiling a C Application</A
></DT
><DT
><A
HREF="compiling-cpp-app.html"
>Compiling a C++ Application</A
></DT
></DL
></DIV
><P
><SPAN
CLASS="PRODUCTNAME"
>eCos</SPAN
> is built using
      the GNU C and C++ compilers. <SPAN
CLASS="PRODUCTNAME"
>eCos</SPAN
> relies on certain features of these
      tools such as constructor priority ordering and selective linking
      which are not part of other toolchains.
    </P
><P
>Some <SPAN
CLASS="APPLICATION"
>GCC</SPAN
> options are required for <SPAN
CLASS="PRODUCTNAME"
>eCos</SPAN
>,
and others can be useful. This chapter gives a brief description
of the required options as well as some recommended <SPAN
CLASS="PRODUCTNAME"
>eCos</SPAN
>-specific options.
All other <SPAN
CLASS="APPLICATION"
>GCC</SPAN
> options (described in the <SPAN
CLASS="APPLICATION"
>GCC</SPAN
> manuals)
are available. </P
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="COMPILING-C-APP">Compiling a C Application</H1
><P
>The following command lines demonstrate the
	  <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>minimum</I
></SPAN
> set of options required to
	  compile and link an <SPAN
CLASS="PRODUCTNAME"
>eCos</SPAN
> program written in C. </P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>Remember that when this manual shows
	    <B
CLASS="COMMAND"
><TT
CLASS="REPLACEABLE"
><I
>TARGET-</I
></TT
>gcc</B
>
	    you should use the full name of the cross compiler,
	    e.g. <B
CLASS="COMMAND"
>i386-elf-gcc</B
>,
	    <B
CLASS="COMMAND"
>arm-elf-gcc</B
>, or
	    <B
CLASS="COMMAND"
>sh-elf-gcc</B
>. When compiling for the
	    synthetic Linux target, use the native
	    <B
CLASS="COMMAND"
>gcc</B
> which must have the features
	    required by <SPAN
CLASS="PRODUCTNAME"
>eCos</SPAN
>.</P
></BLOCKQUOTE
></DIV
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="SCREEN"
>$ <TT
CLASS="REPLACEABLE"
><I
>TARGET-</I
></TT
>gcc -c  -I<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>INSTALL_DIR</I
></SPAN
>/include file.c
$ <TT
CLASS="REPLACEABLE"
><I
>TARGET-</I
></TT
>gcc -o program file.o -L<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>INSTALL_DIR</I
></SPAN
>/lib -Ttarget.ld -nostdlib</PRE
></TD
></TR
></TABLE
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>Certain targets may require extra options, for example
	    the SPARClite architectures require the option
	    <TT
CLASS="OPTION"
>-mcpu=sparclite</TT
>. Examine the
	    <TT
CLASS="FILENAME"
><TT
CLASS="REPLACEABLE"
><I
>BASE_DIR</I
></TT
>/examples/Makefile</TT
> 
	    or the &#8220;Global compiler flags&#8221; option
	    (CYGBLD_GLOBAL_CFLAGS) in your generated
	    <SPAN
CLASS="PRODUCTNAME"
>eCos</SPAN
> configuration) to see if any extra options are
	    required, and if so, what they are. </P
><P
>The following command lines use some other options
	    which are recommended because they use the
	selective linking feature:</P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="SCREEN"
>$ <TT
CLASS="REPLACEABLE"
><I
>TARGET-</I
></TT
>gcc -c  -I<TT
CLASS="REPLACEABLE"
><I
>INSTALL_DIR</I
></TT
>/include -I. -ffunction-sections -fdata-sections -g -O2 file.c
$ <TT
CLASS="REPLACEABLE"
><I
>TARGET-</I
></TT
>gcc -o program file.o -ffunction-sections -fdata-sections -Wl,--gc-sections -g -O2 \
          -L<TT
CLASS="REPLACEABLE"
><I
>INSTALL_DIR</I
></TT
>/lib -Ttarget.ld -nostdlib</PRE
></TD
></TR
></TABLE
></BLOCKQUOTE
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="repository-app-build-tree.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ecos-user-guide.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="compiling-cpp-app.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Application Build Tree</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ecos-programming-concepts-and-techniques.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Compiling a C++ Application</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.