Add the -fno-shared-implib flag
authorIan Lynagh <igloo@earth.li>
Tue, 14 Jul 2009 16:56:31 +0000 (16:56 +0000)
committerIan Lynagh <igloo@earth.li>
Tue, 14 Jul 2009 16:56:31 +0000 (16:56 +0000)
Patch from
    Max Bolingbroke <batterseapower@hotmail.com>
Rerecorded to avoid conflicts.

compiler/main/DriverPipeline.hs
compiler/main/DynFlags.hs
docs/users_guide/flags.xml
docs/users_guide/phases.xml

index 1849c6b..c4ac65f 100644 (file)
@@ -1590,7 +1590,9 @@ linkDynLib dflags o_files dep_packages = do
          , SysTools.Option "-o"
          , SysTools.FileOption "" output_fn
          , SysTools.Option "-shared"
-         , SysTools.FileOption "-Wl,--out-implib=" (output_fn ++ ".a")
+         ] ++
+         [ SysTools.FileOption "-Wl,--out-implib=" (output_fn ++ ".a")
+         | dopt Opt_SharedImplib dflags
          ]
         ++ map (SysTools.FileOption "") o_files
         ++ map SysTools.Option (
index bebea76..37f1171 100644 (file)
@@ -310,6 +310,7 @@ data DynFlag
    | Opt_GenManifest
    | Opt_EmbedManifest
    | Opt_EmitExternalCore
+   | Opt_SharedImplib
 
        -- temporary flags
    | Opt_RunCPS
@@ -694,6 +695,8 @@ defaultDynFlags =
 
             Opt_DoAsmMangling,
 
+            Opt_SharedImplib,
+
             Opt_GenManifest,
             Opt_EmbedManifest,
             Opt_PrintBindContents
@@ -1742,6 +1745,7 @@ fFlags = [
   ( "gen-manifest",                     Opt_GenManifest, const Supported ),
   ( "embed-manifest",                   Opt_EmbedManifest, const Supported ),
   ( "ext-core",                         Opt_EmitExternalCore, const Supported ),
+  ( "shared-implib",                    Opt_SharedImplib, const Supported ),
   ( "implicit-import-qualified",        Opt_ImplicitImportQualified, const Supported )
   ]
 
index bfffb09..0b22a39 100644 (file)
              <entry>dynamic</entry>
              <entry>-</entry>
            </row>
+           <row>
+             <entry><option>-no-shared-implib</option></entry>
+             <entry>Don't generate an import library for a DLL (Windows only)</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
          </tbody>
        </tgroup>
       </informaltable>
index 2026a34..ec14364 100644 (file)
@@ -1052,6 +1052,28 @@ $ cat foo.hspp</screen>
               />).</para>
         </listitem>
       </varlistentry>
+          
+      <varlistentry>
+        <term>
+          <option>-fno-shared-implib</option>
+          <indexterm><primary><option>-fno-shared-implib</option></primary>
+          </indexterm>
+        </term>
+        <listitem>
+          <para>DLLs on Windows are typically linked to by linking to a corresponding
+            <literal>.lib</literal> or <literal>.dll.a</literal> - the so-called import library.
+            GHC will typically generate such a file for every DLL you create by compiling in
+            <literal>-shared</literal> mode. However, sometimes you don't want to pay the
+            disk-space cost of creating this import library, which can be substantial - it
+            might require as much space as the code itself, as Haskell DLLs tend to export
+            lots of symbols.</para>
+            
+          <para>As long as you are happy to only be able to link to the DLL using
+            <literal>GetProcAddress</literal> and friends, you can supply the
+            <option>-fno-shared-implib</option> flag to disable the creation of the import
+            library entirely.</para>
+        </listitem>
+      </varlistentry>
     </variablelist>
   </sect2>