Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 7236c91c07d4f7d40eea67398524ce7601b426a3
Ticket: bc16203b0e1d11d0d6cee35d41a8218bd97364c1
Allow programmatically adjustable optimization and debug flags
User & Date: erikleunissen on 2015-04-06 17:54:50
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    Allow programmatically adjustable optimization and debug flags
    ==============================================================
    
    The build process based on autotools allows adjustment of the build configuration by providing custom values for some variables. Well-known examples are names for programs like CC, LD, AR, RANLIB, DLLTOOL, NM and RC, and program flags like: CPPFLAGS, CFLAGS, LDFLAGS. Regular methods to make such customizations programmatically, are the usage of a config.site script, or passing settings on the command-line for ./configure.
    
    What currently doesn't work using these methods, is adjusting debug and optimization flags (to the compiler and linker). Also, these adjustment cannot be cleanly done through the CFLAGS and LDFLAGS variables because Makefile.in handles these variables in append mode, resulting in multiple debugging or optimization settings within a single compiler command line.
    
    The attached patches enable the functionality for Tcl and Tk. They modify just the files tcl.m4 in the unix and win subdirectories. Macosx builds inherit the functionality from the patched unix directory.
    
    Because tcl.m4 is modified, the configure scripts need to be regenerated. A newly generated ./configure picks up custom settings for CFLAGS_OPTIMIZE and CFLAGS_DEBUG, either from a config.site script or directly from the command line. Example invocations are provided below for win, unix and macosx builds. In any case, the resulting Makefile takes care of invoking the compiler and linker, using the custom optimization and debug flags as intended (tested).
    
    Part of this patch removes some clutter and dirt related to the pertinent variables:
    a. remove redundant explicit substitution of precious variables
    b. for non-gcc win builds: assign preprocessor directives previously cluttering CFLAGS_OPTIMIZE and CFLAGS_DEBUG, to DEFS instead
    
    The motivation for this patch is a personal need for programmatical adjustment of (just) the optimization flags to the compiler. Though I don't need it myself, I expect arguments for adjusting debug flags to be similar to those for optimization flags. The main reason to apply this functionality also to the linker flags, is the entirely analoguous handling of compiler and linker flags throughout the build configuration. Hence the scope.
    
    The attached patches are based off the fossil trunk:
    Tcl: [6f8d422627], 2015-04-04 11:47
    Tk:  [22256943eb], 2015-03-24 19:13
    
    
    Sincerely,
    
    Erik Leunissen
    --
    
    Command line examples for customized build flags
    ================================================
    
    [1] using a config.site script (unix and win builds):
    
    > cat /wherever/you/stored/it/config.site
    CFLAGS_DEBUG=-ggdb3
    CFLAGS_OPTIMIZE=-O3
    
    > CONFIG_SITE=/wherever/you/stored/it/config.site ./configure --disable-symbols
    
         (or use --enable-symbols instead, to select the custom debug settings)
    
    
    [2] using command line arguments (unix and win builds):
    
    > ./configure --enable-symbols CFLAGS_DEBUG=-ggdb3
    
    or:
    
    > ./configure --disable-symbols CFLAGS_OPTIMIZE=-O3
    
    
    [3] macosx variant:
    
    The presented customization method also works with macosx builds, which use the unix ./configure script for their purpose (and the unix patch applies in this case). However, a macosx build doesn't call ../unix/configure directly. It uses make as a wrapper command. Therefore, the macosx command lines are different from those for the win and unix builds. To produce customized debug and optimized builds for macosx (macosx supports building both in one go), one can do:
    
    > make EXTRA_CONFIGURE_FLAGS="CONFIG_SITE=/wherever/you/stored/it/config.site"
    
    or:
    
    > make EXTRA_CONFIGURE_FLAGS="CFLAGS_DEBUG=-ggdb3 CFLAGS_OPTIMIZE=-O3"
    
    -- end --
    
  5. foundin changed to: "all"
  6. is_private changed to: "0"
  7. login: "erikleunissen"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "609f4c7ecf7dbb7a46acdc7eb164753d196088a6"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "erikleunissen"
  14. subsystem changed to: "53. Configure and Build Tools"
  15. title changed to:
    Allow programmatically adjustable optimization and debug flags
    
  16. type changed to: "Patch"