delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/08/07/12:46:57

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:reply-to:mime-version:to
:subject:content-type; q=dns; s=default; b=InK4UxjqUYHwYIRDroDiR
aeyqQoKYYmAgk0ohMjyXKSZ0fASQfrScqWycbP0tfytzR6oawtr+jBvgrwVJQf/C
8g8G8won8fB29MTdnnjNq0HPnb/1R2Kjw+hF8MldOI5SCl2kRxQ9QWPREFmwOH+r
nlpkg0Y0aoZwze9G59tHnM=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:reply-to:mime-version:to
:subject:content-type; s=default; bh=afbpD6XogoIaIgAkgY+PxC/0Cms
=; b=fTzrt1v2GAwCO9PQS8/82DlZ2oo0jtYHYfC2OesTM+Pf9xcb5LMyKGCVo/q
CWtCYpImx4V8Iu9oNsL0O14iTTkhjqGy5x+E3LrBN3tWFoL1QSG0vqlahbeMrlMI
7Sy+N6NdOynOs6tY85+vzmmn2XSasmHUFXAVvuOLuV6uwmYo=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Spam-SWARE-Status: No, score=2.4 required=5.0 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.3.1
Message-ID: <520279DE.7060300@123gen.com>
Date: Wed, 07 Aug 2013 18:46:22 +0200
From: Zouzou <internet AT 123gen DOT com>
Reply-To: internet AT 123gen DOT com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: [SCons] Fix for the cyglink tool
X-Virus-Found: No

--------------030700030600070009080101
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

The cyglink tool in Cygwin's distrib of SCons has a typo that prevents 
it from generating .a import files when building shared libraries with 
the SharedLibrary method.

In cyglink.py, shlib_emitter creates a target file named with 
IMPLIBPREFIX and IMPLIBSUFFIX but shlib_generator checks for LIBPREFIX 
and LIBSUFFIX, which fails. The fix is to have shlib_generator check for 
IMPLIBPREFIX and IMPLIBSUFFIX.

I am attaching a modified cyglink.patch with the correction; and a 
"patch of the patch" that shows which line of cyglink.patch I have changed.

Zouzou

--------------030700030600070009080101
Content-Type: text/plain; charset=windows-1252;
 name="cyglink.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="cyglink.patch"

Add a cyglink Tool to handle linking of shared libraries under

From: David Rothenberger <daveroth AT acm DOT org>

Cygwin. The tool handles creating the DLL import library as well as
replacing the initial "lib" with "cyg".
---
 MANIFEST                      |    1 
 engine/SCons/Tool/__init__.py |    8 +++
 engine/SCons/Tool/cyglink.py  |   96 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+), 0 deletions(-)
 create mode 100644 engine/SCons/Tool/cyglink.py

diff --git a/MANIFEST b/MANIFEST
index e652610..8ed840c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -83,6 +83,7 @@ engine/SCons/Tool/as.py
 engine/SCons/Tool/bcc32.py
 engine/SCons/Tool/c++.py
 engine/SCons/Tool/cc.py
+engine/SCons/Tool/cyglink.py
 engine/SCons/Tool/cvf.py
 engine/SCons/Tool/default.py
 engine/SCons/Tool/dmd.py
diff --git a/engine/SCons/Tool/__init__.py b/engine/SCons/Tool/__init__.py
index b12095f..a15526e 100644
--- a/engine/SCons/Tool/__init__.py
+++ b/engine/SCons/Tool/__init__.py
@@ -733,6 +733,14 @@ def tool_list(platform, env):
         assemblers = ['as']
         fortran_compilers = ['gfortran', 'f95', 'f90', 'g77']
         ars = ['ar']
+    elif str(platform) == 'cygwin':
+        "prefer GNU tools on Cygwin, except for a platform-specific linker"
+        linkers = ['cyglink', 'mslink', 'ilink']
+        c_compilers = ['gcc', 'msvc', 'intelc', 'icc', 'cc']
+        cxx_compilers = ['g++', 'msvc', 'intelc', 'icc', 'c++']
+        assemblers = ['gas', 'nasm', 'masm']
+        fortran_compilers = ['gfortran', 'g77', 'ifort', 'ifl', 'f95', 'f90', 'f77']
+        ars = ['ar', 'mslib']
     else:
         "prefer GNU tools on all other platforms"
         linkers = ['gnulink', 'mslink', 'ilink']
diff --git a/engine/SCons/Tool/cyglink.py b/engine/SCons/Tool/cyglink.py
new file mode 100644
index 0000000..768c1ac
--- /dev/null
+++ b/engine/SCons/Tool/cyglink.py
@@ -0,0 +1,96 @@
+"""SCons.Tool.cyglink
+
+Customization of gnulink for Cygwin (http://www.cygwin.com/)
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+import SCons.Action
+import SCons.Util
+
+import gnulink
+
+def shlib_generator(target, source, env, for_signature):
+    cmd = SCons.Util.CLVar(['$SHLINK']) 
+
+    dll = env.FindIxes(target, 'CYGDLLPREFIX', 'CYGDLLSUFFIX')
+    if dll: cmd.extend(['-o', dll])
+
+    cmd.extend(['$SHLINKFLAGS', '$__RPATH'])
+
+    implib = env.FindIxes(target, 'IMPLIBPREFIX', 'IMPLIBSUFFIX')
+    if implib:
+        cmd.extend([
+            '-Wl,--out-implib='+implib.get_string(for_signature),
+            '-Wl,--export-all-symbols',
+            '-Wl,--enable-auto-import',
+            '-Wl,--whole-archive', '$SOURCES',
+            '-Wl,--no-whole-archive', '$_LIBDIRFLAGS', '$_LIBFLAGS'
+            ])
+    
+    return [cmd]
+
+def shlib_emitter(target, source, env):
+    dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+    no_import_lib = env.get('no_import_lib', 0)
+
+    if not dll:
+        raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX"))
+    
+    # Remove any "lib" after the prefix
+    pre = env.subst('$SHLIBPREFIX')
+    dllName = str(dll)
+    if dllName[len(pre):len(pre)+3] == 'lib':
+        dllName = dllName[len(pre)+3:]
+        dll = env.fs.File(dllName)
+
+    dll = env.ReplaceIxes(dll,
+                          'SHLIBPREFIX', 'SHLIBSUFFIX',
+                          'CYGDLLPREFIX', 'CYGDLLSUFFIX')
+
+    origTarget = target
+    target = [env.fs.File(dll)]
+
+    # Append an import lib target
+    if not no_import_lib and \
+       not env.FindIxes(origTarget, 'IMPLIBPREFIX', 'IMPLIBSUFFIX'):
+
+        # Create list of target libraries as strings
+        targetStrings = env.ReplaceIxes(origTarget[0],
+                                        'SHLIBPREFIX', 'SHLIBSUFFIX',
+                                        'IMPLIBPREFIX', 'IMPLIBSUFFIX')
+        
+        # Now add file nodes to target list
+        target.append(env.fs.File(targetStrings))
+
+    return (target, source)
+                         
+
+shlib_action = SCons.Action.Action(shlib_generator, generator=1)
+
+def generate(env):
+    """Add Builders and construction variables for cyglink to an Environment."""
+    gnulink.generate(env)
+
+    env['SHLINKCOM'] = shlib_action
+    env['LDMODULECOM'] = shlib_action
+    env.Append(SHLIBEMITTER = [shlib_emitter])
+
+    env['CYGDLLPREFIX']        = 'cyg'
+    env['CYGDLLSUFFIX']        = '.dll'
+
+    env['IMPLIBPREFIX']        = ''
+    env['IMPLIBSUFFIX']        = '.dll.a'
+
+def exists(env):
+    return gnulink.exists(env)
+
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

--------------030700030600070009080101
Content-Type: text/plain; charset=windows-1252;
 name="cyglinkimplib.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="cyglinkimplib.patch"

--- cyglink.patch	2013-07-05 10:28:40.000000000 +0200
+++ cyglink2.patch	2013-08-07 18:34:42.785377200 +0200
@@ -71,7 +71,7 @@
 +
 +    cmd.extend(['$SHLINKFLAGS', '$__RPATH'])
 +
-+    implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX')
++    implib = env.FindIxes(target, 'IMPLIBPREFIX', 'IMPLIBSUFFIX')
 +    if implib:
 +        cmd.extend([
 +            '-Wl,--out-implib='+implib.get_string(for_signature),


--------------030700030600070009080101
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--------------030700030600070009080101--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019