Share

ANT Contrib

Tracker: Bugs

5 VisualAge linker fails for shared libraries - ID: 1716271
Last Update: Settings changed ( darius42 )

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;
}


Nobody/Anonymous ( nobody ) - 2007-05-10 05:42

5

Closed

Fixed

David Haney

cpptasks

None

Public


Comments ( 5 )




Date: 2007-05-13 14:37
Sender: darius42


This was committed in revision 119.


Date: 2007-05-11 17:47
Sender: carnoldProject Admin


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


Date: 2007-05-10 06:03
Sender: darius42


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";
+ }

}



Date: 2007-05-10 05:54
Sender: darius42


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.



Date: 2007-05-10 05:46
Sender: darius42


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


Log in to comment.




Attached File

No Files Currently Attached

Changes ( 4 )

Field Old Value Date By
status_id Open 2007-08-22 23:52 darius42
resolution_id None 2007-08-22 23:52 darius42
assigned_to carnold 2007-08-22 23:52 darius42
close_date - 2007-08-22 23:52 darius42