Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b282f348fdf2aaff5373bde607f705192bfeb747
Ticket: 8065d178229d8d335eee64d36ada37c4dedf2579
Duplicate -DNDEBUG in compiler command with --disable-symbols
User & Date: erikleunissen on 2015-04-14 20:50:40
Changes

  1. comment changed to:
    When a unix build is configured with --disable-symbols, the NDEBUG preprocessor directive occurs twice in the compiler command. This indicates cluttered logic somewhere upstream.
    
    This patch proposes to resolve the clutter through removal of a specific assignment of this directive in the file unix/tcl.m4.
    
    An analysis[*] of tcl.m4 and Makefile.in (fossil trunk) led to the following:
    - The preprocessor directive NDEBUG is assigned to two different variables, introducing two separate processing paths by which it propagates through the code.
    - These two assignments occur relatively far apart in the code, in different files (Makefile.in and tcl.m4)
    - (luckily) These two different processing paths are not (yet) intermingled. They are separately leading to a duplication in the compiler command. The reason is that the two assignments are done under the same conceptual conditions (optimization and --disable-symbols).
    
    Other considerations:
    - -DNDEBUG doesn't merit its place as a part of CFLAGS_OPTIMIZE. It's not an optimization flag for the C compiler; it's a preprocessor directive. The assignment to DEFS through AC_DEFINE() in tcl.m4 is the appropriate way.
    - The still separate propagation paths leave us with a promise of a simple remedy: eliminating one of these propagations, before more clutter is being introduced on top if it.
    
    The attached patch removes the assignment of the NDEBUG preprocessor directive from CFLAGS_OPTIMIZE (Makefile.in). This ticket is in line with patch ticket bc16203b0e.
    
    Sincerely,
    
    Erik Leunissen
    --
    [*] Analysis details:
    
    Commit history in fossil (trunk):
    1. artifact [00503f3b97] introduces -DNDEBUG as an assignment to CFLAGS_OPTIMIZE in unix/Makefile.in (2009-07-18)
    2. artifact [c0abbe2663] introduces -DNDEBUG as an assignment to DEFS through AC_DEFINE() in unix/tcl.m4 (2012-04-11)
    
    1. The code path w.r.t. assignment to CFLAGS_OPTIMIZE:
    - _DNDEBUG is assigned to CFLAGS_OPTIMIZE unconditionally
    - CFLAGS_DEFAULT equals CFLAGS_OPTIMIZE only if ./configured with --disable-symbols (tcl.m4)
    - CFLAGS_OPTIMIZE is never assigned to another variable than CFLAGS_DEFAULT (tcl.m4)
    - CFLAGS_DEFAULT is never assigned to another variable than CFLAGS (Makefile.in)
    
    2. The code path w.r.t. assignment to DEFS:
    - -DNDEBUG is assigned to DEFS only if ./configured with --disable-symbols (tcl.m4)
    - DEFS == AC_CFLAGS (Makefile.in)
    
    3. The two code paths join:
    The compiler commands composed by Makefile.in, use variables (like CC_SWITCHES) that are composed of both AC_FLAGS and CFLAGS, without exception. This makes that the compiler commands, if they contain -DNDEBUG, they always end up having it twice, supplied by two different code paths.
    
    -- end of message --
    
  2. login: "erikleunissen"
  3. mimetype: "text/plain"