Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-3992

Windows executables should not export symbols

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 2.1.0
    • Affects Version/s: 2.0.0
    • Component/s: Build
    • Labels:
    • Environment:
      Windows
    • Windows

      In Windows, Dynamic Link Libraries can contain an Export Address Table that enables the program loader component of Windows to find the addresses of routines that are "published" by the DLL. This enables a program (EXE) or one of its DLLs to call those routines. These "exports" are only useful in DLLs and should not be present in EXE files. Routines to be "exported" (listed in the Export Address Table) can be specified to the linker directly, or can be flagged in the source files by attaching the Microsoft-specific __declspec(dllexport) to a declaration.
      Several of the executables in the Windows version of MongoDB are exporting symbols. This is basically harmless, but it makes the EXE files a tiny bit larger and is generally poor form. This actually got a whole lot better in 2.0 as the number of (bogus) exported functions dropped in mongod.exe (x64) from 571 in v1.8.3 to 106 in v2.0.0. The symbols that were removed between 1.8.3 and 2.0.0 were all from SpiderMonkey (JavaScript engine). The symbols that remain are all from PCRE (Perl Compatible Regular Expressions). I am able to get rid of these symbols in my Visual Studio build by setting PRCECPP_STATIC in preprocessor symbols in MSVC for the affected projects. We are already managing to set PCRE_STATIC, but we have also hacked on the source code a bit. PCRE 7.4 in our build is almost exactly the published source code except for some hacking at the ever-annoying __declspec() stuff.
      The affected EXE files built by "scons all" for 2.1.0-pre- are: bsondump, mongod, mongodump, mongoexport, mongofiles, mongoimport, mongooplog, mongorestore, mongos, mongostat and mongotop. Every one of these files is exporting the same set of 106 PCRE functions. Setting PCRECPP_STATIC in the compile step should fix all of them. You can see how you are doing on eliminating exports by using the Microsoft program depends.exe (Dependency Walker), which can be downloaded for free if you don't already have a copy. When looking at the top of the tree for an EXE, there should be no symbols listed in the first two boxes in the upper right ... nothing imported, nothing exported.

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            tad Tad Marshall
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: