Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2470 Discussions

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


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
test_atomic_pic.$(OBJ): test_atomic.cpp
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.

0 Kudos
1 Reply
Thanks for reporting the problem. We will take a look.
0 Kudos