Review: fixing hotspot fastdebug+universal build

roger hoover rhoover at apple.com
Thu Jun 2 18:18:47 PDT 2011


The hotspot uses of printf formats have been problematic because of assumptions that one could always print a given bit-width quantity with a given format (for example, that %lx will print all 64-bit values on LP64).  However, macos compilers require %l for long and %ll for long long even though they are both 64-bit.

The move to C++ inttypes.h format macros is probably the right way to resolve this mess.  I say go for it if it is compiling without warning.  I'd like to see this fixed in the main trunk, but the big test will be to get it right for all the compilers out there building java.

roger

On Jun 2, 2011, at    6:20 PM, Alexander Strange wrote:

> This makes hotspot debug and fastdebug builds compile. Fastdebug works, but debug crashes on startup due to some other issue.
> 
> I posted it for review since I was unsure about the printf format changes - they work fine but might be a portability regression.
> 
> /:
> diff --git a/make/hotspot-rules.gmk b/make/hotspot-rules.gmk
> --- a/make/hotspot-rules.gmk
> +++ b/make/hotspot-rules.gmk
> @@ -66,13 +66,27 @@
> 
> HOTSPOT_TARGET = all_product
> ifeq ($(PLATFORM), macosx)
> +ifeq ($(ARCH), universal)
>   HOTSPOT_TARGET = universal_product
> endif
> +endif
> +
> ifeq ($(DEBUG_NAME), debug)
>   HOTSPOT_TARGET = all_debug
> +ifeq ($(PLATFORM), macosx)
> +ifeq ($(ARCH), universal)
> +  HOTSPOT_TARGET = universal_debug
> endif
> +endif
> +endif
> +
> ifeq ($(DEBUG_NAME), fastdebug)
>   HOTSPOT_TARGET = all_fastdebug
> +ifeq ($(PLATFORM), macosx)
> +ifeq ($(ARCH), universal)
> +  HOTSPOT_TARGET = universal_fastdebug
> +endif
> +endif
> endif
> 
> ifeq ($(ZERO_BUILD), true)
> 
> hotspot:
> diff --git a/make/Makefile b/make/Makefile
> --- a/make/Makefile
> +++ b/make/Makefile
> @@ -473,6 +473,17 @@
> 	$(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server}
> 	$(QUIETLY) $(MAKE) universalize
> 
> +universal_fastdebug:
> +	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 all_fastdebug
> +	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 all_fastdebug
> +	$(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server}
> +	$(QUIETLY) $(MAKE) universalize
> +
> +universal_debug:
> +	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 all_debug
> +	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 all_debug
> +	$(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server}
> +	$(QUIETLY) $(MAKE) universalize
> #
> # Check target
> #
> diff --git a/src/share/vm/utilities/globalDefinitions.hpp b/src/share/vm/utilities/globalDefinitions.hpp
> --- a/src/share/vm/utilities/globalDefinitions.hpp
> +++ b/src/share/vm/utilities/globalDefinitions.hpp
> @@ -1209,12 +1209,11 @@
> 
> // Format macros that allow the field width to be specified.  The width must be
> // a string literal (e.g., "8") or a macro that evaluates to one.
> +#define UINTX_FORMAT_W(width)   "%" #width PRIuPTR
> #ifdef _LP64
> -#define UINTX_FORMAT_W(width)   UINT64_FORMAT_W(width)
> #define SSIZE_FORMAT_W(width)   INT64_FORMAT_W(width)
> #define SIZE_FORMAT_W(width)    UINT64_FORMAT_W(width)
> #else
> -#define UINTX_FORMAT_W(width)   UINT32_FORMAT_W(width)
> #define SSIZE_FORMAT_W(width)   INT32_FORMAT_W(width)
> #define SIZE_FORMAT_W(width)    UINT32_FORMAT_W(width)
> #endif // _LP64
> @@ -1228,15 +1227,10 @@
> // 4.3.2. So we have to use "%016x" or "%08x" to simulate the printing format.
> // GCC 4.3.2, however requires the data to be converted to "intptr_t" when
> // using "%x".
> -#ifdef  _LP64
> -#define PTR_FORMAT    PTR64_FORMAT
> -#define SIZE_FORMAT   UINT64_FORMAT
> -#define SSIZE_FORMAT  INT64_FORMAT
> -#else   // !_LP64
> -#define PTR_FORMAT    PTR32_FORMAT
> -#define SIZE_FORMAT   UINT32_FORMAT
> -#define SSIZE_FORMAT  INT32_FORMAT
> -#endif  // _LP64
> +#define PTR_FORMAT    "%08" PRIxPTR
> +#define SIZE_FORMAT   "%" PRIuPTR
> +#define SSIZE_FORMAT  "%" PRIdPTR
> +
> #define UINTX_FORMAT  "%" PRIuPTR
> #define INTX_FORMAT   "%" PRIdPTR
> 
> 



More information about the macosx-port-dev mailing list