Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting a jnilib to Intel



Eric,

Many thanks.  I *AM* starting to feel more comfortable with it all now.

You're right, I did forget about the JVM invocation stub in my Java bundles. (And since I build everything manually, I put the stub there myself, so I *SHOULD* have remembered.) I guess you are saying that an Intel machine (or the OS's loader) will "program check" on the foreign code stub, but the program check handler (or loader) has been tweaked to "fix it up" by substituting the proper stub. Presumably, in future releases of my products I should replace that "thin" stub with the universal version, just to be a good citizen.

(Are universal binaries cleverly designed to be backward compatible with 10.2/10.3 on PPC, or will my products become "Tiger only" when I "go universal".)

I did "miss" the "-arch" flag stuff on page 19 (my eyes glazed over when I saw the Xcode build variable settings, just above).

From some other correspondence, I have figured out that to create a universal binary, you compile TWICE, once for each architecture, and then use a new tool called "lipo" to combine the two platform-specific binaries into a "universal" binary. (Presumably "lipo" is a pun on "liposuction".)

Not clear to me yet whether you use "ld" before or after "lipo" -- or neither (perhaps "lipo" incorporates a linkage editor).

I guess I would have expected all of this "low-level stuff" explained clearly somewhere. If not in the UBPG, then perhaps Apple could post a Web page with a simple "low-level overview" for non-IDE programmers. (There are many more of us "old-timers" out there than you might expect. Especially in the Unix and mainframe worlds! I myself have been writing software professionally since IBM hired me in 1969.)

Bill

Eric Albert wrote:
In article <email@hidden>,
 "William C. McCain" <email@hidden> wrote:

Before posting my questions, I *DID* download, print, and read the "Universal Binary Programming Guidelines". But it did not answer ANY of my questions!

I'm sorry to hear that. Please file bug reports on the questions that weren't answered so we can improve future revisions.


For instance, regarding Rosetta and JNI libraries, the "Guidelines" states:

Rosetta does not run the following:
...
* Bundled Java applications or Java applications with JNI libraries that can¹t be translated


I took that as a very ambiguous statement. Obviously, bundled Java applications, in general, WILL run on Mac OS X under Intel, because Apple will port (or has already ported) the JVM and all required, system level native libraries to Intel -- so no translation is required of Java applications, bundled or not, by Rosetta.

The "obviously" above actually isn't quite right. All bundled Java applications include a Mach-O stub that creates a JVM and kicks off the application. For all existing Java apps, that stub is a PowerPC binary.


Thanks to some terrific work on the part of the Java team, this is largely transparent to users of the Developer Transition Systems. Java applications with thin Mach-O stubs relaunch themselves with the system's universal version of the stub. But without that work, no existing bundled applications would have run at all on Intel because Java isn't supported in Rosetta. (For example, Java applets will not run in a web browser running under Rosetta.)

Of course, that applies to "pure Java" applications, not ones like mine that have their own native libraries. But the above statement also refers to "Java applications with JNI libraries that can¹t be translated" -- which CLEARLY (to me) says that "some JNI libraries can be translated, and some cannot". But which ones can and which ones can't?

None can be translated because Java doesn't run translated. I'll try to get the documentation clarified.


Secondly, the "Universal Binary Programming Guidelines" talks extensively about building an Xcode project to build a universal binary for a Cocoa application. Nothing at all about Java! Or JNI libraries!

Java files themselves are architecture-agnostic, so there's no such thing as a "universal Java binary". JNI libraries are the same as any other shared libraries. Because of that, we didn't feel a need to call either case out explicitly. If you'd like to see it in the documentation, please file a bug report.


No mention of the GCC options needed to build a universal binary, either -- the "Guidelines" are all written in terms of setting Xcode variables. There is no description of what compiler options are actually GENERATED by these variables! As I stated, I absolutely refuse to use an "IDE". I run compilers and all other tools from the command-line, as God intended. IDEs are VILE!

Then I point thee to Psalm (er, page) 19 in the King James version of the Universal Binary Programming Guidelines, which describes the -arch flags that you need to pass to the compiler to build a universal binary. See also the gcc-4.0 man page.


Hope this helps,
Eric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Converting a jnilib to Intel (From: Eric Albert <email@hidden>)
 >Re: Converting a jnilib to Intel (From: Eric Albert <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.