[IOT-1986] Windows: Work around SCons race condition
authorDan Mihai <Daniel.Mihai@microsoft.com>
Fri, 7 Apr 2017 04:39:48 +0000 (21:39 -0700)
committerMike Fenelon <mike.fenelon@microsoft.com>
Thu, 13 Apr 2017 17:07:07 +0000 (17:07 +0000)
These sporadic linker errors become even more frequent when adding
more static LIBs into a single target DLL.

Change-Id: I44d2cfeda61a08cbc29cb3d7f685b87ea1cb8b9e
Signed-off-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18767
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Omar Maabreh <omarm@microsoft.com>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Reviewed-by: Mike Fenelon <mike.fenelon@microsoft.com>
build_common/windows/SConscript

index 74735e2..55af23c 100644 (file)
@@ -38,7 +38,17 @@ if env['CC'] == 'cl':
     else:
         env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/RTC1'])
         env.AppendUnique(LINKFLAGS = ['/debug'])
+
     env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+
+    # Work around [IOT-1986]
+    # During some Windows multi-threaded builds, SCons/Python/Pywin32 appear to try
+    # linking with oc.lib while another SCons thread started executing InstallTarget()
+    # for this static LIB, but didn't finish yet. That behavior results in linker errors.
+    # Work around this issue by linking with the source of InstallTarget(), rather
+    # than the target.
+    env.PrependUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource', 'src')])
+
     env.AppendUnique(PATH = os.environ['PATH'])
     env['PDB'] = '${TARGET.base}.pdb'
     env.Append(LINKFLAGS=['/PDB:${TARGET.base}.pdb'])