⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 build.sgml

📁 ecos实时嵌入式操作系统
💻 SGML
📖 第 1 页 / 共 5 页
字号:
    make_object -library=libSomePackage.a {        &hellip;    }</programlisting><para>Again this should be avoided because it makes application developmentmore difficult. There is one special library which can be used freely,<filename>libextras.a</filename>, which is used to generate the<filename>extras.o</filename> file as described below.</para><para>The order in which object files end up in a library is not defined.Typically each library will be created directly in the install tree,since there is little point in generating a file in the build tree andthen immediately copying it to the install tree.</para></sect2><!-- }}} --><!-- {{{ extras.o               --><sect2 id="build.extras"><title>The <filename>extras.o</filename> file</title><para>Package sources files normally get compiled and then added to alibrary, by default <filename>libtarget.a</filename>, which is thenlinked with the application code. Because of the usual rules forlinking with libraries, augmented by the use of link-time garbagecollection, this means that code will only end up in the finalexecutable if there is a direct or indirect reference to it in theapplication. Usually this is the desired behaviour: if the applicationdoes not make any use of say kernel message boxes, directly orindirectly, then that code should not end up in the final executabletaking up valuable memory space.</para><para>In a few cases it is desirable for package code to end up in the finalexecutable even if there are no direct or indirect references. Forexample, device driver functions are often not called directly.Instead the application will access the device via the string<literal>"/dev/xyzzy"</literal> and call the device functionsindirectly. This will be impossible if the functions have beenremoved at link-time.</para><para>Another example involves static C++ objects. It is possible to have astatic C++ object, preferably with a suitable constructor priority,where all of the interesting work happens as a side effect of runningthe constructor. For example a package might include a monitoringthread or a garbage collection thread created from inside such aconstructor. Without a reference by the application to the staticobject the latter will never get linked in, and the package will notfunction as expected.</para><para>A third example would be copyright messages. A package vendor may wantto insist that all products shipped using that package include aparticular message in memory, even though many users of that packagewill object to such a restriction.</para><para>To meet requirements such as these the build system provides supportfor a file <filename>extras.o</filename>, which always gets linkedwith the application code via the linker script. Because it is anobject file rather than a library everything in the file will belinked in. The <filename>extras.o</filename> file is generated at theend of a build from a library <filename>libextras.a</filename>, sopackages can put functions and variables in suitable source files andadd them to that library explicitly:</para><programlisting width=72>    compile -library=libextras.a xyzzy.c    compile xyzzy_support.c</programlisting><para>In this example <filename>xyzzy.o</filename> will end up in<filename>libextras.a</filename>, and hence in<filename>extras.o</filename> and in the final executable.<filename>xyzzy_support.o</filename> will end up in<filename>libtarget.a</filename> as usual, and is subject to linkergarbage collection.</para></sect2><!-- }}} --><!-- {{{ Compilers and flags    --><sect2 id="build.flags"><title>Compilers and Flags</title><caution><para>Some of the details of compiler selection and compiler flags describedbelow are subject to change in future revisions of the componentframework, although every reasonable attempt will be made to avoidbreaking backwards compatibility.</para></caution><para>The build system needs to know what compiler to use, what compilerflags should be used for different stages of the build and so on. Muchof this information will vary from target to target, although usersshould be able to override this when appropriate. There may also be aneed for some packages to modify the compiler flags. All platform HALpackages should define a number of options with well-known names,along the following lines (any existing platform HAL package can beconsulted for a complete example):</para><programlisting width=72>cdl_component CYGBLD_GLOBAL_OPTIONS {    flavor  none    parent  CYGPKG_NONE    &hellip;    cdl_option CYGBLD_GLOBAL_COMMAND_PREFIX {        flavor  data        default_value { "arm-elf" }        &hellip;    }    cdl_option CYGBLD_GLOBAL_CFLAGS {        flavor  data        default_value "-Wall -g -O2 &hellip;"        &hellip;    }    cdl_option CYGBLD_GLOBAL_LDFLAGS {        flavor  data        default_value "-g -nostdlib -Wl,--gc-sections &hellip;"        &hellip;    }}</programlisting><para>The <varname>CYGBLD_GLOBAL_OPTIONS</varname> component serves tocollect together all global build-related options. It has the flavor<literal>none</literal> since disabling all of these options wouldmake it impossible to build anything and hence is not useful. It isparented immediately below the root of the configuration hierarchy,thus making sure that it is readily accessible in the graphicalconfiguration tool and, for command line users, in the<filename>ecos.ecc</filename> save file.</para><note><para>Currently the &parent; property lists a parent of<varname>CYGPKG_NONE</varname>, rather than an empty string. Thiscould be unfortunate if there was ever a package with that name. Theissue will be addressed in a future release of the componentframework.</para></note><para>The option <varname>CYGBLD_GLOBAL_COMMAND_PREFIX</varname> defineswhich tools should be used for the current target. Typically this isdetermined by the processor on the target hardware. In some cases agiven target board may be able to support several differentprocessors, in which case the &default-value; expression could selecta different toolchain depending on some other option that is used tocontrol which particular processor.<varname>CYGBLD_GLOBAL_COMMAND_PREFIX</varname> is modifiable ratherthan calculated, so users can override this when necessary.</para><para>Given a command prefix such as <literal>arm-elf</literal>, all Csource files will be compiled with <literal>arm-elf-gcc</literal>, allC++ sources will be built using <literal>arm-elf-g++</literal>,and <literal>arm-elf-ar</literal> will be used to generate thelibrary. This is in accordance with the usual naming conventions forGNU cross-compilers and similar tools. For the purposes of custombuild steps, tokens such as <literal>$(CC)</literal> will be set to<literal>arm-elf-gcc</literal>.</para><para>The next option, <varname>CYGBLD_GLOBAL_CFLAGS</varname>, is used toprovide the initial value of <literal>$(CFLAGS)</literal>. Somecompiler flags such as <literal>-Wall</literal> and<literal>-g</literal> are likely to be used on all targets. Otherflags such as <literal>-mcpu=arm7tdmi</literal> will betarget-specific. Again this is a modifiable option, so the user canswitch from say <literal>-O2</literal> to <literal>-Os</literal> ifdesired. The option <varname>CYGBLD_GLOBAL_LDFLAGS</varname> servesthe same purpose for <literal>$(LDFLAGS)</literal> and linking. It isused primarily when building test cases or possibly for some custombuild steps, since building eCos itself generally involves buildingone or more libraries rather than executables.</para><para>Some packages may wish to add certain flags to the global set, orpossibly remove some flags. This can be achieved by havingappropriately named options in the package, for example:</para><programlisting width=72>cdl_component CYGPKG_KERNEL_OPTIONS {    display "Kernel build options"    flavor  none    &hellip;    cdl_option CYGPKG_KERNEL_CFLAGS_ADD {        display "Additional compiler flags"        flavor  data        default_value { "" }        &hellip;    }    cdl_option CYGPKG_KERNEL_CFLAGS_REMOVE {        display "Suppressed compiler flags"        flavor  data        default_value { "" }        &hellip;    }    cdl_option CYGPKG_KERNEL_LDFLAGS_ADD {        display "Additional linker flags"        flavor  data        default_value { "" }        &hellip;    }    cdl_option CYGPKG_KERNEL_LDFLAGS_REMOVE {        display "Suppressed linker flags"        flavor  data        default_value { "" }        &hellip;    }}</programlisting><para>In this example the kernel does not modify the global compiler flagsby default, but it is possible for the users to modify the options ifdesired. The value of <literal>$(CFLAGS)</literal> that is used forthe compilations and custom build steps in a given package isdetermined as follows:</para><orderedlist><listitem><para>Start with the global settings from<varname>CYGBLD_GLOBAL_CFLAGS</varname>, for example<literal>-g&nbsp;-O2</literal>.</para></listitem><listitem><para>Remove any flags specified in the per-package<literal>CFLAGS_REMOVE</literal> option, if any. For exampleif <literal>-O2</literal> should be removed for this package then<literal>$(CFLAGS)</literal> would now have a value of just<literal>-g</literal>.</para></listitem><listitem><para>Then concatenate the flags specified by the per-package<literal>CFLAGS_ADD</literal> option, if any. For example if<literal>-Os</literal> should be added for the current package thenthe final value of <literal>$(CFLAGS)</literal> will be<literal>-g&nbsp;-Os</literal>.</para></listitem></orderedlist><para><literal>$(LDFLAGS)</literal> is determined in much the same way.</para><note><para>The way compiler flags are handled at present has numerous limitationsthat need to be addressed in a future release, although it shouldsuffice for nearly all cases. For the time being custom build stepsand in particular the &make-object; property can be used to workaround the limitations.</para><para>Amongst the issues, there is a specific problem with packageencapsulation. For example the math library imposes some stringentrequirements on the compiler in order to guarantee exact IEEEbehavior, and may need special flags on a per-architecture basis. Oneway of handling this is to have<varname>CYGPKG_LIBM_CFLAGS_ADD</varname> and<varname>CYGPKG_LIBM_CFLAGS_REMOVE</varname> &default-value;expressions which depend on the target architecture, but suchexpressions may have to updated for each new architecture. Analternative approach would allow the architectural HAL package tomodify the &default-value; expressions for the math library, but thisbreaks encapsulation. A third approach would allow some architecturalHAL packages to define one or more special options with well-knownnames, and the math library could check if these options were definedand adjust the default values appropriately. Other packages withfloating point requirements could do the same. This approach also hasscalability issues, in particular how many such categories of optionswould be needed? It is not yet clear how best to resolve such issues.</para></note><note><para>When generating a build tree it would be desirable for the componentframework to output details of the tools and compiler flags in aformat that can be re-used for application builds, for example amakefile fragment. This would make it easier for applicationdevelopers to use the same set of flags as were used for building eCositself, thus avoiding some potential problems with incompatiblecompiler flags.</para></note></sect2><!-- }}} --><!-- {{{ Custom build steps     --><sect2 id="build.custom"><title>Custom Build Steps</title><caution><para>Some of the details of custom build steps as described below aresubject to change in future revisions of the component framework,although every reasonable attempt will be made to avoid breaking

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -