cons-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patch for static linking


From: Brad Garcia
Subject: patch for static linking
Date: Fri, 31 Aug 2001 07:58:46 -0400 (EDT)

Attached is a patch that allows cons to recognize static linking
directives placed in LIBS.  Cons will then correctly search only
for static versions of libraries, instead of first (incorrectly)
searching for a dynamic version.

This patch is against a slightly changed version of 2.3.0.
It should apply cleanly.

Also, this adds some gnu-tool-specific stuff to cons.  If
someone can think of a better way to generalize it, please
post to the list.

Brad Garcia

------------------------------------------------------------
==== //depot/proj/cons/cons#19 - /u/bgarcia/work/cons/cons ====
--- /tmp/tmp.9345.0     Fri Aug 31 07:50:57 2001
+++ /u/bgarcia/work/cons/cons   Fri Aug 31 07:50:54 2001
@@ -1508,18 +1508,30 @@
     # Pass %LIBS symbol through %-substituition
     # <address@hidden> 1998-06-18
     @names = split(' ', $env->_subst($env->{LIBS} || ''));
+
+    my($static_only) = 0;
     my $name;
     for $name (@names) {
         my ($lpath, @allnames);
-        if ($name =~ /^-l(.*)/) {
+        if ($name =~ /^-Wl,-Bdynamic$/ ||
+            $name =~ /^-Wl,-dy$/ ||
+            $name =~ /^-Wl,-call_shared$/) {
+            $static_only = 0;
+        } elsif ($name =~ /^-Wl,-Bstatic$/ ||
+                 $name =~ /^-Wl,-static$/ ||
+                 $name =~ /^-Wl,-dn$/ ||
+                 $name =~ /^-Wl,-non_shared$/) {
+            $static_only = 1;
+        } elsif ($name =~ /^-l(.*)/) {
             # -l style names are looked up on LIBPATH, using all
             # possible lib suffixes in the same search order the
             # linker uses (according to SUFLIBS).
             # Recognize new PREFLIB symbol, which should be 'lib' on
             # Unix, and empty on Win32. TODO: What about shared
             # library suffixes?  <address@hidden> 1998-05-13
-           @allnames = map("$env->{PREFLIB}$1$_",
-                           split(/:/, $env->{SUFLIBS}));
+            @allnames = map("$env->{PREFLIB}$1$_",
+                           split(/:/, $static_only ? $env->{SUFLIB}
+                                                   : $env->{SUFLIBS}));
             $lpath = address@hidden;
         } else {
             @allnames = ($name);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]