MPS issue job002148

TitleMPS: mps_lib_callback_register breaks .def file for re-exporting MPS functions
Statusclosed
Priorityessential
Assigned userRichard Kistruck
OrganizationRavenbrook
DescriptionMPS: mps_lib_callback_register breaks .def file for re-exporting MPS functions

Related jobs:
  job002171: "obsolete mpsdy.dll and mpslibcb mechanism is still present in builds and source" -- followup to remove Method 2

A link error occurs when the .def file specifies MPS functions that are not present. (The .def file is used to export (from DLL) or re-export (after static link) these functions).

In particular, w3gen.def includes "mps_lib_callback_register", but this is present only in MPS DLL, not the MPS static library. So using w3gen.def for re-export from static breaks the link.

The two current ways of making MPS functions available for DLLs to dynamically bind to are:
  1. client host code statically links MPS functions, and re-exports them (eg. specifying "/def:w3gen.def" to Windows linker);
  2. use mpsdy.dll, which contains only MPS code, and uses mpslibcb's mps_lib_callback_register to receive plinth callbacks.

(Aside: Method 1 is recommended. Method 2 is untested.)

The "mps_lib_callback_register" function is not present in the statically-linkable (Method 1) MPS library, so the attempt to re-export causes the link to fail with an error.

(But note that the "mps_lib_callback_register" function is required to produce a useable DLL for Method 2, which is why it is currently listed in the .def file).
AnalysisRHSK 2009-07-20
Fix: remove the "mps_lib_callback_register" function from the .def file. Either accept that this will produce an mpsdy.dll that is unusable, or investigate specifying an additonal /def: argument, to export the "mps_lib_callback_register" function, when building the DLL.
But it's probably time for Method 2 to be dropped, because it is not that useful -- Method 1 is simpler, has better performance, and is preferred by customers.

RHSK 2009-09-25
For this defect, fix minimally:

Remove "mps_lib_callback_register" from w3gen.def, because this file is provided to Configura for re-exporting after static link. Correct expgen.sh accordingly (even though it's not working; job001255) by removing mpslibcb.h from list of files searched for exports.

Put "mps_lib_callback_register" in new file mpslibcb.def, used only when building the MPS DLL (rule in commpost.nmk) which contains the mpslibcb stuff. So mps-fns.def (produced by w3build.bat by copying w3gen.def) is now correct for Configura to use to re-export MPS functions static linked into a larger executable, and mpsdy.dll still correctly exports the mps_lib_callback_register function. Check results by looking at mps-fns.def, and using dumpbin /exports to see the exports from mpsdy.dll.
How foundunknown
Evidencehttp://info.ravenbrook.com/mail/2009/06/02/16-15-22/0.txt
Observed in1.108.2
Introduced in1.108.2
Created byRichard Kistruck
Created on2009-07-20 17:39:50
Last modified byRichard Kistruck
Last modified on2010-03-02 13:19:32
History2009-07-20 RHSK Created.
2009-07-21 RHSK Removing mps_lib_callback_register will make mpsdy.dll unusable, but won't break builds.
2009-08-19 RHSK Aside: Method 1 is recommended
2009-09-25 RHSK Clarify symptom of defect; for now, fix minimally. Followup is job002171.
2010-03-02 RHSK Clarify again.

Fixes

Change Effect Date User Description
168763 closed 2009-09-25 15:08:55 Richard Kistruck MPS br/padding: job002148: drop mps_lib_callback_register from w3gen.def, and put it in new file mpslibcb.def, used only when building the MPS DLL (rule in commpost.nmk) which contains the mpslibcb stuff. Correct expgen.sh accordingly (even though it's not working). So mps-fns.def (produced by w3build.bat by copying w3gen.def) is now correct for Configura to use to re-export MPS functions static linked into a larger executable, and mpsdy.dll still correctly exports the mps_lib_callback_register function.