Closed Bug 694499 Opened 13 years ago Closed 13 years ago

Android cross compile on OS X doesn't set IS_LITTLE_ENDIAN


(Core :: JavaScript Engine, defect)

Not set





(Reporter: cdleary, Assigned: ted)




(1 file)

It looks like the endianness is wrong for jsval_layout on the OS X cross compiles, which is guarded by IS_LITTLE_ENDIAN in jscpucfg.h. This causes it to die almost immediately, since setting a jsval to undefined does not alter the correct (tag) bits.

I'll take a quick crack at this tomorrow, but I'm a build system idiot, so I may turn it over to somebody else very quickly.
jscpucfg is really stupid and I hate it. Can we just give up and hardcode this stuff with platform-specific #ifdefs yet?
Awesome! I confirm that rebuilding with this patch:

diff -r d9e824e28209 js/src/jscpucfg.cpp
--- a/js/src/jscpucfg.cpp	Thu Oct 13 21:13:01 2011 -0700
+++ b/js/src/jscpucfg.cpp	Fri Oct 14 11:27:16 2011 -0400
@@ -64,13 +64,13 @@
      * processors, and determines which processor to configure for based
      * on compiler predefined macros.  We do the same thing here.
-    printf("#ifdef __LITTLE_ENDIAN__\n");
+    //printf("#ifdef __LITTLE_ENDIAN__\n");
     printf("#define IS_LITTLE_ENDIAN 1\n");
     printf("#undef  IS_BIG_ENDIAN\n");
-    printf("#else\n");
-    printf("#undef  IS_LITTLE_ENDIAN\n");
-    printf("#define IS_BIG_ENDIAN 1\n");
-    printf("#endif\n\n");
+    //printf("#else\n");
+    //printf("#undef  IS_LITTLE_ENDIAN\n");
+    //printf("#define IS_BIG_ENDIAN 1\n");
+    //printf("#endif\n\n");
 #elif defined(IS_LITTLE_ENDIAN) || defined(FORCE_LITTLE_ENDIAN)
     printf("#define IS_LITTLE_ENDIAN 1\n");
     printf("#undef  IS_BIG_ENDIAN\n\n");

makes a working android build cross-compiled from mac. Apparently FORCE_LITTLE_ENDIAN is the missing define, since on mac jscpucfg.cpp gets compiled into a binary and then run to generate jsautocfg.h, which is the actual include used by the js code. Or something like that.
Assignee: general → ted.mielczarek
So I ripped out the jscpucfg binary, since all it does is set this endianness define, but in a completely stupid way. I've got hardcoded definitions in the header file for (the existing) Win32/64, OS X, and anything with endian.h. I'm pretty sure this makes all of our Tier 1 platforms work, and should fix the issue this bug was reported for. It might break some other less-well-supported platforms, but it shouldn't be much effort to add support for those to jscpucfg.h.
Comment on attachment 568064 [details] [diff] [review]
get rid of jscpucfg binary

This is looking pretty reasonable on Try, although not all platforms have reported yet.

I think this is the best way to go. Trying to detect endianness by running a binary is a losing proposition. We should just hardcode the answer (or use what the compiler/system headers give us). There's bound to be a little pain here for oddball platforms, (I'm sure I broke Solaris and BSD here), but this improves our cross-compilation story.
Attachment #568064 - Flags: review?(jimb)
Comment on attachment 568064 [details] [diff] [review]
get rid of jscpucfg binary

Review of attachment 568064 [details] [diff] [review]:

Yeah, I think the autoconf dynamic test religion is not serving us well, here.
Attachment #568064 - Flags: review?(jimb) → review+
Depends on: 696957
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
Blocks: 696957
No longer depends on: 696957
Depends on: 699170
Blocks: 523964
Blocks: 523162
You need to log in before you can comment on or make changes to this bug.