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
- 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
- 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.