[ ant-contrib-Bugs-1716271 ] VisualAge linker fails for shared libraries

"SourceForge.net" <[email protected]> Wed, 22 Aug 2007 16:52:15 -0700
Newsgroups gmane.comp.java.ant-contrib.devel
Message-ID <[email protected]>
Bugs item #1716271, was opened at 2007-05-10 05:42
Message generated for change (Settings changed) made by darius42
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=416920&aid=1716271&group_id=36177

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: cpptasks
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: David Haney (darius42)
Summary: VisualAge linker fails for shared libraries

Initial Comment:
When compiling shared libraries on AIX (using the Visual Age compiler), the following error is produced when linking:

[aix] 62 % ant 
Buildfile: build.xml

build:
   [cpp:cc] 1 total files to be compiled.
   [cpp:cc] Starting link
   [cpp:cc] /usr/vacpp/bin/makeC++SharedLib: 1543-301 Priority must be specified

BUILD FAILED
/home/darius42/tmp2/build.xml:7: makeC++SharedLib failed with return code 3

Total time: 2 seconds
[aix] 63 % 


build.xml:
----
<project 
    name="foo" 
    default="build"
    xmlns:cpp="antlib:net.sf.antcontrib.cpptasks">

  <target name="build">
    <cpp:cc outfile="foo" outtype="shared">
      <cpp:compiler name="xlC"/>
      <cpp:linker name="xlC"/>
      <cpp:fileset dir=".">
        <include name="file.cpp"/>
      </cpp:fileset>
    </cpp:cc>
  </target>
</project>

file.cpp
----
int foo(void) {
  return 0;
}


----------------------------------------------------------------------

Comment By: David Haney (darius42)
Date: 2007-05-13 14:37

Message:
Logged In: YES 
user_id=1140024
Originator: NO

This was committed in revision 119.

----------------------------------------------------------------------

Comment By: Curt Arnold (carnold)
Date: 2007-05-11 17:47

Message:
Logged In: YES 
user_id=27193
Originator: NO

Patch looks reasonable.  Adding you as a developer to the project, feel
free to commit this one.

----------------------------------------------------------------------

Comment By: David Haney (darius42)
Date: 2007-05-10 06:03

Message:
Logged In: YES 
user_id=1140024
Originator: NO

The following is a diff with the associated changes to address this issue
(I'm unable to attach a file, presumably because I'm not listed in the
"Submitted By" or "Assigned To" lists).

Index: src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
===================================================================
--- src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java	(revision
118)
+++ src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java	(working
copy)
@@ -115,13 +115,13 @@
             //
             if (set.getType() != previousLibraryType) {
                     if (set.getType() != null &&
"static".equals(set.getType().getValue())) {
-                            endargs.addElement("-Bstatic");
+                            endargs.addElement(getStaticLibFlag());
                             previousLibraryType = set.getType();
                     } else {
                             if (set.getType() == null ||
                                            
!"framework".equals(set.getType().getValue()) ||
                                                         !isDarwin()) {
-                                    endargs.addElement("-Bdynamic");
+                                   
endargs.addElement(getDynamicLibFlag());
                                     previousLibraryType = set.getType();
                             }
                     }
@@ -322,4 +322,12 @@
         return super.prepareArguments(task, outputDir, outputFile,
                 finalSources, config);
     }
+
+    protected String getDynamicLibFlag() {
+        return "-Bdynamic";
+    }
+
+    protected String getStaticLibFlag() {
+        return "-Bstatic";
+    }
 }
Index: src/net/sf/antcontrib/cpptasks/ibm/VisualAgeLinker.java
===================================================================
--- src/net/sf/antcontrib/cpptasks/ibm/VisualAgeLinker.java	(revision
118)
+++ src/net/sf/antcontrib/cpptasks/ibm/VisualAgeLinker.java	(working
copy)
@@ -31,7 +31,7 @@

     private static final String[] objFiles = new String[]{".o", ".a",
".lib",
             ".dll", ".so", ".sl"};
     private static final VisualAgeLinker dllLinker = new
VisualAgeLinker(
-            "makeC++SharedLib", objFiles, discardFiles, "lib", ".so");
+            "xlC", objFiles, discardFiles, "lib", ".a");
     private static final VisualAgeLinker instance = new
VisualAgeLinker("xlC",
             objFiles, discardFiles, "", "");
     public static VisualAgeLinker getInstance() {
@@ -50,7 +50,7 @@

             //args.addElement("-g");
         }
         if (linkType.isSharedLibrary()) {
-            //args.addElement("-G");
+            args.addElement("-qmkshrobj");
         }
     }
     public Linker getLinker(LinkType type) {
@@ -69,7 +69,15 @@

      * would lock up.  Using a stock response.
      */
     public String getIdentifier() {
-    	return "VisualAge linker - unidentified version";
+        return "VisualAge linker - unidentified version";
     }
+
+    protected String getDynamicLibFlag() {
+        return "-bdynamic";  
+    }
+
+    protected String getStaticLibFlag() {
+        return "-bstatic";
+    }
     
 }


----------------------------------------------------------------------

Comment By: David Haney (darius42)
Date: 2007-05-10 05:54

Message:
Logged In: YES 
user_id=1140024
Originator: NO

As a part of investigating this failure, I ran across the following IBM
documentation indicating that makeC++SharedLib is no longer the recommended
method for creating shared libraries on AIX:

http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.xlcpp8a.doc/proguide/ref/rkmkslib.htm

Instead, users should use the xlC compiler with the -qmkshrobj flag.

After addressing that issue, the linker failed indicating that the
-Bdynamic and -Bstatic flags aren't valid with xlC, and instead users
should specify -bdynamic and -bstatic respectively.  Since these flags are
specified at a higher level (in gcc/AbstractLdLinker.java), it was
necessary to add hooks to that class that would allow overriding these
strings in derived classes.

Finally, I modified the suffix associated with generated libraries from
.so to .a.  While .so is supported on AIX, .a (shared archive) still
appears to be the dominant suffix for must of the projects I surveyed.  


----------------------------------------------------------------------

Comment By: David Haney (darius42)
Date: 2007-05-10 05:46

Message:
Logged In: YES 
user_id=1140024
Originator: NO

I accidentally submitted without verifying I was logged in.  Adding a
comment to associate this issue with my user account.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=416920&aid=1716271&group_id=36177

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/