Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-45682

Ninja compiledb incorrect for some targets

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.3.3
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • Dev Platform 2020-01-27

      Repro steps:

      python3 ./buildscripts/scons.py \
        --dbg --variables-files=etc/scons/xcode_macosx.vars \
        --modules= \
        --ninja new.build.ninja
      ninja -f ./new.build.jinja compiledb
      

      Expected: No lines have file:<path_to_compiler>.

      Actual:

      Some lines look like the following:

          "file": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++",
      

      Mat and I looked into this. It seems related to the ordering of dependencies. E.g. in the new.build.ninja file, we see:

          build build/debug/mongo/dbtests/catalogtests.o: CMD_W_DEPS | src/mongo/dbtests/catalogtests.cpp $
              /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ $
              /Users/rtimmons/mongodb/mongo/new.build.ninja || _generated_sources
            cmd = PATH=/usr/local/bin:/opt/bin:/bin:/usr/bin $
      

      for a target that has the correct "file" attribute and

      build build/debug/mongo/dbtests/basictests.o: CMD_W_DEPS | $
          /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ $
          src/mongo/dbtests/basictests.cpp /Users/rtimmons/mongodb/mongo/new.build.ninja || $
      

      for a target that does not.

      It seems like the ordering of dependencies may vary run over run (python sets are hash-based) so sometimes the order of clang++ and {{.cpp} files changes.

      Scons gets the compiledb right fwiw:

          python3 ./buildscripts/scons.py \
            --dbg --variables-files=etc/scons/xcode_macosx.vars \
            --modules= \
            compiledb
      

            Assignee:
            mathew.robinson@mongodb.com Mathew Robinson (Inactive)
            Reporter:
            ryan.timmons@mongodb.com Ryan Timmons
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: