TDBC

View Ticket
Login
Ticket Hash: d6c4db25560b1a8c3a26f9369e57cf00327cb9b4
Title: makefile.vc: compile tdbcStubLib.c with -DTCL_USE_STUBS to not make tdbcodbc.dll dependent on tcl86t.dll
Status: Open Type: Build_Problem
Severity: Critical Priority: Immediate
Subsystem: tdbc Resolution: Open
Last Modified: 2019-08-30 08:19:16
Version Found In: 1.1.0
User Comments:
oehhar added on 2019-08-28 20:21:17: (text/x-fossil-wiki)
<H1>Issue</H1>

"tdbcodbc1.1.0.dll" will refuse to load with an error "a depend library may not be found" under the following conditions:

   *   makefile.vc build method
   *   the only visible tcl is included in a starkit (no tcl86t.dll available as single file)

<H1>Problem reason</H1>

"tdbcstublib.c" is compiled without "-DUSE_TCL_STUBS" and build into the library "tdbcstub110.lib".
This library has a dependency to tcl86t.dll.

This library is then linked into tdbcodbc.1.1.0.dll with the source file "tcl86t.lib".

This results in a dependency on tcl86t.dll.
This is not a problem when there is a tcl86t.dll available (no starkit).

The dependency may be verified using the tool Dependency Walker. Just drop the dll into the window and look to the middle pane. It lists "tcl86t.dll".

As a side note, supplying beside the starkit a "tcl86t.dll" stopped my application without any notice when tdbcodbc1.1.0.dll is loaded.

<H1>Manual solution</H1>

Here is my modified build line broken into multiple lines for readability:

<verbatim>
cl -nologo -c /D_ATL_XP_TARGETING  -W3
  -FpC:\test\tcl8.6.9_tdbcodbc\pkgs\tdbc1.1.0\win\Release\tdbc_ThreadedDynamic\ -Op -QI0f -O2 -YX
  -DPACKAGE_NAME="\"tdbc\""  -DPACKAGE_TCLNAME="\"tdbc\""  -DPACKAGE_VERSION="\"1.1.0\""
  -DMODULE_SCOPE=extern  -DTCL_CFGVAL_ENCODING=\"cp1252\" -DSTDC_HEADERS -DTCL_THREADS=1
  -DUSE_THREAD_ALLOC=1 -DNDEBUG -DTCL_CFG_OPTIMIZED -DNO_STRTOI64 -DUSE_TCL_STUBS -Zl
  -DSTATIC_BUILD -I"C:\test\tcl8.6.9_tdbcodbc\win\..\generic"
  -I"C:\test\tcl8.6.9_tdbcodbc\win\..\win"
  -I"C:\test\tcl8.6.9_tdbcodbc\pkgs\tdbc1.1.0\win\..\generic"
  -I"C:\test\tcl8.6.9_tdbcodbc\pkgs\tdbc1.1.0\win\..\win"
  -I"C:\test\tcl8.6.9_tdbcodbc\pkgs\tdbc1.1.0\win\..\compat"
  -FoC:\test\tcl8.6.9_tdbcodbc\pkgs\tdbc1.1.0\win\Release\tdbc_ThreadedDynamic\
  C:\test\tcl8.6.9_tdbcodbc\pkgs\tdbc1.1.0\win\..\generic\tdbcStubLib.c
</verbatim>

(this is ms-vc6 PSDK 2003SP1 32 bit build on a 64 bit windows 10).

oehhar added on 2019-08-28 20:36:40: (text/x-fossil-wiki)
I forgot the following information:

   *   In the link line of tdbcodbc.dll, there is tcl86stubs.lib *and* tcl86t.lib. IMHO, the last one should be removed. But apparently, it does not harm, if there are no references (like in the link of tdbc.dll)
   *   The client module tdbc::sqlite3 is not affected as it does not link with tdbcstubs.lib.
   *   The client modules for postgres ad mysql should also be affected, as they also link with tdbcstubs.lib.

apnadkarni added on 2019-08-29 02:24:39: (text/x-fossil-plain)
This is a problem with rules.vc (mea culpa) which does not include those flags for the stubs objects. Might have been oversight or I might have mistakenly assumed stubs for extensions never call into Tcl.

Will look into fixing.

apnadkarni added on 2019-08-29 05:41:02: (text/x-fossil-plain)
Fix is under test.

oehhar added on 2019-08-29 07:11:03: (text/x-fossil-wiki)
Ashok,

you did a big work and cleaned-up a big mess and made it all easy.
And it is normal that there are cases where additional work is required.

Thank you for careing.

I also suppose, that stub library should use stubs itself, excluding themselfs, which might cause circular issues ;-).

Thank you for your contnuous great work,
Harald

oehhar added on 2019-08-30 08:19:16: (text/x-fossil-wiki)
Ashok,

thank you for your continuous work.
The fix adds "-DUSE_TCL_STUBS" tk the tdbc stibs compilation and fixes the issue.

I would also propose to not link anything with stubs enabled with "tcl86t.lib".

The makefile uses libraries "tclstubs86t.lib" and "tcl86t.lib".
Only the stubs lib is sufficient.

The result is that symbols not found in the stubs lib are linked from tcl and shadowed the issue.

I might be wrong here and may not have the full picture...

Emphasis is, that the issue is solved with the present patch and the ticket might be closed.

Thank you,
Harald