United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7153072 build fails for 32 bit JDK on 64 bit OS
7153072 : build fails for 32 bit JDK on 64 bit OS

Details
Type:
Enhancement
Submit Date:
2012-03-12
Status:
Open
Updated Date:
2012-07-05
Project Name:
JDK
Resolved Date:
Component:
infrastructure
OS:
generic
Sub-Component:
build
CPU:
generic
Priority:
P4
Resolution:
Unresolved
Affected Versions:
7u6
Targeted Versions:
8

Related Reports
Relates:

Sub Tasks

Description
When building using the JDK repository, the architecture of the build machine is used to decide the architecture of the JDK being built. At least on Linux. So if you build on a 64-bit machine it tries to build a 64-bit JDK.

As powerful 64-bit build servers becomes available we want to be able to do a 32-bit build on such systems.

Hotspot already supports this. If you set ARCH_DATA_MODEL=32 then it will set all the necessary build and compiler flags for a 32-bit build, even on a 64-bit system. (Of course your 64-bit system must have all the necessary 32-bit development libraries installed).

For a JDK build you can force it to 32-bit by setting mach=i586 on the make invocation. This replaces the value read via "uname -m" and will then set ARCH/SRCARCH/LIBARCH etc correctly. (You can't set ARCH directly as that would also be passed to hotspot during a full control build and hotspot wants ARCH=i686 where the JDK wants ARCH=i586 - so we change the mach setting instead.)

In addition the JDK build lets the compiler (gcc) output for its default platform - so on a 64-bit system gcc would output 64-bit binaries. To deal with this we need to pass -m32 as a gcc/ld flag. This can be done by setting the environment variables:
OTHER_CFLAGS, OTHER_CPPFLAGS, OTHER_CXXFLAGS and OTHER_LDFLAGS to contain "-m32".

Even then there are places in the build where this does not work (see suggested fix for details):
- the OTHER_XXXFLAGS are not used on the compile command
- the OTHER_XXXFLAGS are set directly in the Makefile ( = instead of +=) and replace the value from the environment
- recursive makes interact badly with conditional variables that are also set in the environment

These issues can all be worked around as per the suggested fix.

However a better fix would be for the JDK build to use ARCH_DATA_MODEL to set a 32-bit or 64-bit ARCH (etc) as requested and directly pass the right flags to the compiler.

There may also be other issues lurking if any lower level makefiles specifically check the build architecture.

                                    

Comments
PUBLIC COMMENTS

It is possible that the new build project will handle this correctly "out of the box" (at least once the box is complete).
                                     
2012-05-22
WORK AROUND

There is a simpler formulation that avoids the issues in the makefiles:

mach=i586 ARCH_DATA_MODEL=32 EXTRA_CFLAGS=-m32 OTHER_LDFLAGS=-m32

Correction: jdbc problem still remains as it only uses LDFLAGS_COMMON for the link phase:

/usr/bin/ld: warning: -z nodefs ignored.
/usr/bin/ld: i386 architecture of input file `/export/users/dh198349/jdk8/builds/b01/se8-linux-i586-ea/tmp/sun/sun.jdbc.odbc/JdbcOdbc/dummyodbc.o' is incompatible with i386:x86-64 output
collect2: ld returned 1 exit status

You can then rebuild jdbc as follows:

make mach=i586 ARCH_DATA_MODEL=32 EXTRA_CFLAGS=-m32 OTHER_LDFLAGS=-m32 LDFLAGS_DEFS_OPTION=-m32 -C jdk/make/sun/jdbc

then re-rum the original make command to complete the build
                                     
2012-03-22
SUGGESTED FIX

File modes below and comand line list below.. I still think we need to redo the make structure to handle of triplet compilers installed on a given machine. i.e. MULTIARCH

OTHER_CPPFLAGS=-m32 OTHER_CXXFLAGS=-m32 OTHER_LDFLAGS=-m32 OTHER_CFLAGS=-m32 make mach=i586 ARCH_DATA_MODEL=32 ...

Deploy repo will fail to build as well.. We need to add additional flag to use local
setenv ALT_GCC29_COMPILER_PATH /usr  If you don't use this path you will get weird error
in plugin build. I will file a seperate bug on that after I discuss options with Plguin team.

diff --git a/make/com/sun/java/pack/Makefile b/make/com/sun/java/pack/Makefile
--- a/make/com/sun/java/pack/Makefile
+++ b/make/com/sun/java/pack/Makefile
@@ -72,14 +72,14 @@
 	     $(ZIPOBJDIR)/inffast.$(OBJECT_SUFFIX)
 
   ZINCLUDE=-I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
-  OTHER_CXXFLAGS += $(ZINCLUDE)
+  CXXFLAGS_COMMON += $(ZINCLUDE)
   LDDFLAGS += $(ZIPOBJS)
  else
   LDDFLAGS += -lz
   OTHER_CXXFLAGS += -DSYSTEM_ZLIB
  endif
 else
-  OTHER_CXXFLAGS += -DNO_ZLIB -DUNPACK_JNI
+  CXXFLAGS_COMMON += -DNO_ZLIB -DUNPACK_JNI
   OTHER_LDLIBS += $(JVMLIB)
 endif
 
diff --git a/make/sun/jdbc/Makefile b/make/sun/jdbc/Makefile
--- a/make/sun/jdbc/Makefile
+++ b/make/sun/jdbc/Makefile
@@ -104,7 +104,7 @@
 	$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $<
 $(ODBC_FAKE_LIBRARIES): $(TEMPDIR)/dummyodbc.o
 	@$(prep-target)
-	$(CC) $(SHARED_LIBRARY_FLAG) $(LDFLAGS_COMMON) -o $@ $< $(EXTRA_LIBS)
+	$(CC) $(SHARED_LIBRARY_FLAG) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS) -o $@ $< $(EXTRA_LIBS)
 clean::
 	$(RM) -f $(ODBC_FAKE_LIBRARIES)
 	$(RM) -f $(TEMPDIR)/dummyodbc.c
diff --git a/make/sun/security/smartcardio/Makefile b/make/sun/security/smartcardio/Makefile
--- a/make/sun/security/smartcardio/Makefile
+++ b/make/sun/security/smartcardio/Makefile
@@ -75,6 +75,6 @@
 ifeq ($(PLATFORM), windows)
   OTHER_LDLIBS = $(JVMLIB) winscard.lib
 else
-  OTHER_LDLIBS = $(LIBDL) $(JVMLIB)
-  OTHER_CFLAGS = -D__sun_jdk
+  OTHER_LDLIBS += $(LIBDL) $(JVMLIB)
+  OTHER_CFLAGS += -D__sun_jdk
 endif
                                     
2012-03-12



Hardware and Software, Engineered to Work Together