Makefile.test bug when used in windows with cl compiler and perhaps intel.

Makefile.test bug when used in windows with cl compiler and perhaps intel.

Аватар пользователя Blas Rodriguez Somoza

Hello

There is a bug in Makefile.test when used with cl compiler. When Makefile.test is run and there is an up to date test_atomic.obj from a previous run, test_atomic.exe becomes equal to test_atomic_pic.exe Let me explain with the sequence of commands executed by make to build test_atomic and test_atomic_pic.exe

  1. First build against clean build directory:
    • cl /c ....... test_atomic.cpp --> compile only, builds test_atomic.obj
    • cl /Fetest_atomic.exe ...... test_atomic.obj --> link, builds test_atomic.exe
    • cl /Fetest_atomic_pic.exe ...... test_atomic.cpp --> compile and build. PROBLEM: cl build a test_atomic.obj (the name of the cpp) as an intermediate step which overwrite the previous test_atomic.obj
  2. Second build
    • compile step of test_atomic.obj is not executed since it is up to date.
    • cl /Fetest_atomic.exe .... test_atomic.obj -> executed because test_atomic.obj is newer than test_atomic.exe. But the test_atomic.obj used is the one generated when building test_atomic_pic.exe
    • build of test_atomic_pic.exe is not executed since it is up to date.
The problem comes from the cl intermediate file generation when linking and compiling in the same command. I don't know if the make with the intel compiler is also wrong, but since intel compiler is compatible with ms one, perhaps it is. To solve the problem in Makefile.test, it is enough to replace test_atomic_pic.$(TEST_EXT): test_atomic.cpp $(CPLUS) $(OUTPUT_KEY)$@ $(CPLUS_FLAGS) $(PIC_KEY) $(CXX_ONLY_FLAGS) $(CXX_WARN_SUPPRESS) $(INCLUDES) $(DEFINE_KEY)__TBB_TEST_PIC=1 $< $(LINK_TBB.LIB) $(LIBS) $(AUX_LIBS) $(LINK_FLAGS) With test_atomic_pic.$(OBJ): test_atomic.cpp $(CPLUS) $(COMPILE_ONLY) $(OUTPUTOBJ_KEY)$@ $(CPLUS_FLAGS) $(PIC_KEY) $(CXX_ONLY_FLAGS) $(CXX_WARN_SUPPRESS) $(INCLUDES) $(DEFINE_KEY)__TBB_TEST_PIC=1 $< With the change, the compile and link step are splitted, the intermediate obj is test_atomic_pic.obj and don't overwrite nothing. The link step will use the general rule for building tests ( %.$(TEST_EXT):%.$(OBJ) ..................) I tested the change in windows/cl and osx/clang. Hope it helps.
2 posts / 0 новое
Последнее сообщение
Пожалуйста, обратитесь к странице Уведомление об оптимизации для более подробной информации относительно производительности и оптимизации в программных продуктах компании Intel.
Аватар пользователя Alexey Kukanov (Intel)

Thanks for reporting the problem. We will take a look.

Зарегистрируйтесь, чтобы оставить комментарий.