[ ant-contrib-Bugs-1313421 ] linker should pass "-arch xxx" argument directly to libtool

"SourceForge.net" <[email protected]> Sun, 08 Feb 2009 10:12:41 +0000
Newsgroups gmane.comp.java.ant-contrib.devel
Message-ID <[email protected]>
Bugs item #1313421, was opened at 2005-10-05 01:53
Message generated for change (Comment added) made by nobody
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=416920&aid=1313421&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: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Curt Arnold (carnold)
Summary: linker should pass "-arch xxx" argument directly to libtool

Initial Comment:
For building fat (ppc and i386) libs on Mac OS X, it would be nice if linker 
worked with the following definition:

      <linker id="linker" name="gcc">
		<linkerarg value="-arch" />
		<linkerarg value="ppc" />
		<linkerarg value="-arch" />
		<linkerarg value="i386" />
      </linker>

however, the above declaration outputs "libtool -Wl,-arch ppc -Wl,-arch 
i386 ..." which fails (at least on Mac OS X). It should output "libtool -arch ppc 
-arch i386 ..." instead.

decorateLinkerOption in GccLinker.java should pass the "-arch xxx" to GCC 
without adding "-Wl" in this case. Ex:

    public String decorateLinkerOption(StringBuffer buf, String arg) {
        String decoratedArg = arg;
        if (arg.length() > 1 && arg.charAt(0) == '-') {
            switch (arg.charAt(1)) {
                //
                //   passed automatically by GCC
                //
                case 'g' :
                case 'f' :
                case 'F' :
                /* Darwin */
                case 'a' :
                case 'm' :
                case 'O' :
                case 'W' :
                case 'l' :
                case 'L' :
                case 'u' :
                case 'v' :
                    break;
                default :
                    boolean known = false;
                    for (int i = 0; i < linkerOptions.length; i++) {
                        if (linkerOptions[i].equals(arg)) {
                            known = true;
                            break;
                        }
                    }
                    if (!known) {
                        buf.setLength(0);
                        buf.append("-Wl,");
                        buf.append(arg);
                        decoratedArg = buf.toString();
                    }
                    break;
            }
        }
        return decoratedArg;
    }


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

Comment By: Nobody/Anonymous (nobody)
Date: 2009-02-08 10:12

Message:
Adding "-arch", to the following files in the linkerOptions Array allows
compilation and linking to succeed.
src/main/java/net/sf/antcontrib/cpptasks/gcc/GccLinker.java
src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java

This is the necessary arguments added to the cc task.

            <!-- Making of the fat binaries -->
            <compilerarg value="-arch" if="osx"/>
            <compilerarg value="i386" if="osx"/>
            <compilerarg value="-arch" if="osx"/>
            <compilerarg value="ppc" if="osx"/>
            <linkerarg value="-arch" if="osx"/>
            <linkerarg value="i386" if="osx"/>
            <linkerarg value="-arch" if="osx"/>
            <linkerarg value="ppc" if="osx"/>

kc0dhb_at_gmail_dot_com

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

Comment By: David Hoffer (dhoffer)
Date: 2007-09-06 13:22

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

What is the status of this?  I would like to use cpptasks to build OSX
universal binary.

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

Comment By: Nobody/Anonymous (nobody)
Date: 2005-10-05 02:12

Message:
Logged In: NO 

I suppose a better solution would be to add "-arch" as one of the
recognized options to 
linkerOptions, ex:

    private static String[] linkerOptions = new String[]{"-arch",
"-bundle",
            "-dynamiclib", "-nostartfiles", "-nostdlib", "-prebind",
"-s",
            "-static", "-shared", "-symbolic", "-Xlinker",
            "--export-all-symbols", "-static-libgcc",};

Is it possible to extend the those options using build.xml as a
workaround?

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

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

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com