Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-4061

Race condition between Makefile.Debug and Makefile.Release when using debug_and_release on Mac

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 4.7.0
    • Build tools: qmake
    • None
    • macOS

    Description

      Take this example .pro file:

      1. dogwalk.pro
        TEMPLATE = lib
        TARGET = dogwalk
        CONFIG += debug_and_release build_all
        SOURCES += dogwalk.cpp
        CONFIG(debug, debug|release) {
        DESTDIR = Debug
        } else {
        DESTDIR = Release
        }

      This generates these rules in the separate debug and release makefiles:

      1. Makefile.Release
        Release/$(TARGET): $(OBJECTS) $(SUBLIBS) $(OBJCOMP)
        @$(CHK_DIR_EXISTS) Release/ || $(MKDIR) Release/
        -$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)
        $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) $(OBJCOMP)
        -ln -s $(TARGET) $(TARGET0)
        -ln -s $(TARGET) $(TARGET1)
        -ln -s $(TARGET) $(TARGET2)
        -$(DEL_FILE) Release/$(TARGET)
        -$(DEL_FILE) Release/$(TARGET0)
        -$(DEL_FILE) Release/$(TARGET1)
        -$(DEL_FILE) Release/$(TARGET2)
        -$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) Release/
      1. Makefile.Debug
        Debug/$(TARGET): $(OBJECTS) $(SUBLIBS) $(OBJCOMP)
        @$(CHK_DIR_EXISTS) Debug/ || $(MKDIR) Debug/
        -$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)
        $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) $(OBJCOMP)
        -ln -s $(TARGET) $(TARGET0)
        -ln -s $(TARGET) $(TARGET1)
        -ln -s $(TARGET) $(TARGET2)
        -$(DEL_FILE) Debug/$(TARGET)
        -$(DEL_FILE) Debug/$(TARGET0)
        -$(DEL_FILE) Debug/$(TARGET1)
        -$(DEL_FILE) Debug/$(TARGET2)
        -$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) Debug/

      Each rule ends up putting $(TARGET) under Release or Debug directories, as requested. However, at the line `$(LINK) $(LFLAGS) -o $(TARGET) ...' and following ln commands, both of the makefiles are using $(TARGET), $(TARGET0) etc in the current directory as intermediate files.

      Therefore, if a `make' is done on the top Makefile with any `-j', the two rules race with each other. Symptoms may include:

      • everything works OK
      • one of the Debug or Release directories ends up with broken symbolic links
      • the Debug directory ends up with the library built in release mode or vice versa

      The bug is compounded by the fact that errors in the ln, rm and mv commands are all ignored so the build claims to be successful.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              buddenha Oswald Buddenhagen
              rmcgover Rohan McGovern (Inactive)
              Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes