Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-11128

Avoid appending duplicate flags in CMAKE

    • Storage Engines
    • 3
    • 2024-03-05 - Claronald, 2024-03-19 - PacificOcean, 2024-04-02 - GreatMugshot, 나비 (nabi) - 2024-04-16

      I ended up having the following output after compiling a few times in a row:

      FAILED: CMakeFiles/wt_objs.dir/src/session/session_dhandle.c.o 
      ccache /opt/mongodbtoolchain/v4/bin/gcc  -I/usr/include/python3.6m -Iinclude -Iconfig -I../src/include -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_X86INTRIN_H -fPIC   -Og -g3 -ggdb3 -gdwarf-4 -MD -MT CMakeFiles/wt_objs.dir/src/session/session_dhandle.c.o -MF CMakeFiles/wt_objs.dir/src/session/session_dhandle.c.o.d -o CMakeFiles/wt_objs.dir/src/session/session_dhandle.c.o   -c ../src/session/session_dhandle.c
      In file included from ../src/include/wt_internal.h:469,
                       from ../src/session/session_dhandle.c:9:
      ../src/session/session_dhandle.c: In function '__wt_session_get_btree_ckpt':
      ../src/session/session_dhandle.c:544:19: warning: implicit declaration of function 'S2B'; did you mean 'S2C'? [-Wimplicit-function-declaration]
        544 |                   S2B(session)->checkpoint_gen, __wt_gen(session, WT_GEN_CHECKPOINT)); 

      This shows our compilation flags are appended. It seems that it comes from our CMake files that use the set function, see an example below:

      if(has_x86intrin)
          set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_X86INTRIN_H" CACHE STRING "" FORCE)
      endif()
      

      The variable CMAKE_C_FLAGS is cached and the flag DHAVE_X86INTRIN_H will be appended to it every time we build.

      It seems that we could use add_compile_options instead to avoid duplicates.

            Assignee:
            jasmine.bi@mongodb.com Jasmine Bi
            Reporter:
            etienne.petrel@mongodb.com Etienne Petrel
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: