Menu

#4 Pass C++FLAGS and LDFLAGS to linker

closed
nobody
None
5
2012-10-11
2011-11-12
No

Pass C++FLAGS and LDFLAGS to linker

Discussion

  • Tristan Heaven

    Tristan Heaven - 2011-11-12
     
  • Ishmael

    Ishmael - 2011-11-15

    Thanks for the patch Tristan. It looks like it could be useful.

    The file unix.jam is part of Autojam (http://autojam.berlios.de/) so you might consider sending the patch there as well, if you have the time.

    It may take a few weeks to review and merge the patch, one reason is because the Autojam version in Trigger Rally should probably be updated first.

    Thanks again,
    Ishmael.

     
  • Ishmael

    Ishmael - 2012-01-04

    I have done a bit of investigation and I'm putting my notes about it here.

    This patch ensures that the C++FLAGS and LDFLAGS are passed to g++ at the link stage, previously the C++FLAGS were only passed to the compile stage and the LDFLAGS were not used at all. The patch applies to the unix build but the same changes should be made to the win32.jam and macosx.jam files. (But it is easy enough to do, no need for any reader of this note to provide a new patch.)

    Trigger has three build variants: debug, profile, and optimize with optimize being the default. To use a build variant other than optimize call jam with the -sVARIANT=debug or sVARIANT=profile option. I tried sVARIANT=profile without this patch applied and the profiling did not work. With this patch applied profiling did work, the reason being that the -pg option must be specified to both the compile and link stage.

    So fixing the profile build variant bug is reason enough to apply this patch

    The build variant options used by trigger are specified in the Jamrules file in the top level trigger-rally directory.

    An interesting possibility is to use custom flags by specifying values for C++FLAGS (and possibly LDFLAGS) to jam. For example, something like:

    jam -sC++FLAGS="-g -Os"

    or similar. However, the build variant flags are still appended to the custom flags so this may not give the desired result. For example, in this case the actual flags used will be "-g -Os -O3" because by default the optimize flags are appended. Making it possible to use custom flags without the standard build variant flags being appended would be a good extra enhancement to do at some point. I will add a Feature Request.

    As for progress on actually applying this patch, I think we should probably apply it now and remember to re-apply it when when we get around to updating to the latest AutoJam version.

     
  • Ishmael

    Ishmael - 2012-02-17

    I have checked this in, revision 66.

    I think that passing C++FLAGS to the linker is not the intended behavior of AutoJam. If we look at the Jamrules we can see that there are two sets of flags for each build variant COMPILER_CFLAGS and COMPILER_LFLAGS. In the variant.jam the flags for the chosen variant are added to C++FLAGS and LINKLIBS variable. However, the LINKLIBS is not passed to the linker. I believe that is a bug or missing functionality in AutoJam.

    But this patch does the trick for the variants we actually have defined. We can re-visit if AutoJam is ever fixed. It is not fixed in the latest version.

     
  • qubodup

    qubodup - 2012-07-19

    committed in r66

     

Log in to post a comment.