Menu

#18 and/or defined unconditionally

v1.0_(example)
closed
None
1
2020-04-03
2018-10-21
No

The sense of the "filter" in the definitions of __gmsl_have_or and __gmsl_have_and is inverted, such that the condition is always false.

This causes the and/or macros to be defined unconditionally.

This is confusing for 2 reasons:

  1. Though one can see the definitions they can never be called.
  2. The return semantics of the GNU-make built-in functions are incompatible with the GMSL functions. The GMSL functions return $(true) on success. The GNU-make functions return an input argument. That makes the GMSL documentation misleading.

redefine-builtin.make - GNUmakefile to demonstrate the issues.
redefine-buildin.out - Output from run of redefine-builtin.make.
__gmsl.patch - Patch to fix flag heuristics

3 Attachments

Discussion

  • John Graham-Cumming

    Hmm.

    So I made a simple Makefile that contains the following:

    $(warning $(origin or))
    $(warning $(origin and))
    $(warning $(or A,A))
    $(warning $(and A,A))
    $(warning $(or A,))
    $(warning $(and A,))
    
    all:
    

    The output with GNU Make 3.81 (which has native and and or) is...

    Makefile:1: undefined
    Makefile:2: undefined
    Makefile:3: A
    Makefile:4: A
    Makefile:5: A
    Makefile:6:
    make: Nothing to be done for `all'.
    

    And with GNU Make 3.80 (which does not)...

    Makefile:1: undefined
    Makefile:2: undefined
    Makefile:3:
    Makefile:4:
    Makefile:5:
    Makefile:6:
    make: Nothing to be done for `all'.
    

    So, in both cases the $(origin) is returning undefined making my definitions useless. So I think a totally different approach is needed. How about detecting like this?

    true  := T
    false :=
    native_or = $(or $(true),$(false))
    native_and = $(and $(true), $(true))
    
    $(warning $(call native_or) $(call native_and))
    

    Thoughts?

     
  • John Graham-Cumming

    Or perhaps take a 'truth table' approach and do this:

    true  := T
    false :=
    
    __or_tt := /$(or $(true),$(true))/$(or $(true),$(false))/$(or $(false),$(true))/$(or $(false),$(false))/
    __and_tt := /$(and $(true),$(true))/$(and $(true),$(false))/$(and $(false),$(true))/$(and $(false),$(false))/
    
    native_or := $(if $(filter /T/T/T//,$(__or_tt)),$(true),$(false))
    native_and := $(if $(filter /T////,$(__and_tt)),$(true),$(false))
    
     
  • John Graham-Cumming

    • status: open --> closed
     
  • John Graham-Cumming

    Done

     

Log in to post a comment.

MongoDB Logo MongoDB