提交 19534f32 编写于 作者: D dcubed

6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers

Summary: (for Serguei) Allow for Linux builds with Sun Studio Linux compilers
Reviewed-by: sspitsyn, ohair
上级 094539c4
...@@ -518,10 +518,10 @@ static bool core_get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id, ...@@ -518,10 +518,10 @@ static bool core_get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id,
} }
static ps_prochandle_ops core_ops = { static ps_prochandle_ops core_ops = {
release: core_release, .release= core_release,
p_pread: core_read_data, .p_pread= core_read_data,
p_pwrite: core_write_data, .p_pwrite= core_write_data,
get_lwp_regs: core_get_lwp_regs .get_lwp_regs= core_get_lwp_regs
}; };
// read regs and create thread from NT_PRSTATUS entries from core file // read regs and create thread from NT_PRSTATUS entries from core file
......
...@@ -291,10 +291,10 @@ static void process_cleanup(struct ps_prochandle* ph) { ...@@ -291,10 +291,10 @@ static void process_cleanup(struct ps_prochandle* ph) {
} }
static ps_prochandle_ops process_ops = { static ps_prochandle_ops process_ops = {
release: process_cleanup, .release= process_cleanup,
p_pread: process_read_data, .p_pread= process_read_data,
p_pwrite: process_write_data, .p_pwrite= process_write_data,
get_lwp_regs: process_get_lwp_regs .get_lwp_regs= process_get_lwp_regs
}; };
// attach to the process. One and only one exposed stuff // attach to the process. One and only one exposed stuff
......
...@@ -80,6 +80,11 @@ ifneq ("$(filter $(LP64_ARCH),$(BUILDARCH))","") ...@@ -80,6 +80,11 @@ ifneq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
MFLAGS += " LP64=1 " MFLAGS += " LP64=1 "
endif endif
# pass USE_SUNCC further, through MFLAGS
ifdef USE_SUNCC
MFLAGS += " USE_SUNCC=1 "
endif
# The following renders pathnames in generated Makefiles valid on # The following renders pathnames in generated Makefiles valid on
# machines other than the machine containing the build tree. # machines other than the machine containing the build tree.
# #
......
...@@ -35,6 +35,8 @@ CFLAGS += -DVM_LITTLE_ENDIAN ...@@ -35,6 +35,8 @@ CFLAGS += -DVM_LITTLE_ENDIAN
CFLAGS += -D_LP64=1 CFLAGS += -D_LP64=1
# The serviceability agent relies on frame pointer (%rbp) to walk thread stack # The serviceability agent relies on frame pointer (%rbp) to walk thread stack
CFLAGS += -fno-omit-frame-pointer ifndef USE_SUNCC
CFLAGS += -fno-omit-frame-pointer
endif
OPT_CFLAGS/compactingPermGenGen.o = -O1 OPT_CFLAGS/compactingPermGenGen.o = -O1
...@@ -63,7 +63,11 @@ QUIETLY$(MAKE_VERBOSE) = @ ...@@ -63,7 +63,11 @@ QUIETLY$(MAKE_VERBOSE) = @
# For now, until the compiler is less wobbly: # For now, until the compiler is less wobbly:
TESTFLAGS = -Xbatch -showversion TESTFLAGS = -Xbatch -showversion
ifdef USE_SUNCC
PLATFORM_FILE = $(GAMMADIR)/build/$(OS_FAMILY)/platform_$(BUILDARCH).suncc
else
PLATFORM_FILE = $(GAMMADIR)/build/$(OS_FAMILY)/platform_$(BUILDARCH) PLATFORM_FILE = $(GAMMADIR)/build/$(OS_FAMILY)/platform_$(BUILDARCH)
endif
ifdef FORCE_TIERED ifdef FORCE_TIERED
ifeq ($(VARIANT),tiered) ifeq ($(VARIANT),tiered)
......
#
# Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
#
#------------------------------------------------------------------------
# CC, CPP & AS
CPP = CC
CC = cc
AS = $(CC) -c
ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
ARCHFLAG/i486 = -m32
ARCHFLAG/amd64 = -m64
CFLAGS += $(ARCHFLAG)
AOUT_FLAGS += $(ARCHFLAG)
LFLAGS += $(ARCHFLAG)
ASFLAGS += $(ARCHFLAG)
#------------------------------------------------------------------------
# Compiler flags
# position-independent code
PICFLAG = -KPIC
CFLAGS += $(PICFLAG)
# no more exceptions
CFLAGS += -features=no%except
# Reduce code bloat by reverting back to 5.0 behavior for static initializers
CFLAGS += -features=no%split_init
# allow zero sized arrays
CFLAGS += -features=zla
# Use C++ Interpreter
ifdef CC_INTERP
CFLAGS += -DCC_INTERP
endif
# We don't need libCstd.so and librwtools7.so, only libCrun.so
CFLAGS += -library=Crun
LIBS += -lCrun
CFLAGS += -mt
LFLAGS += -mt
# Compiler warnings are treated as errors
#WARNINGS_ARE_ERRORS = -errwarn=%all
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS)
# Special cases
CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
# The flags to use for an Optimized build
OPT_CFLAGS+=-xO4
OPT_CFLAGS/NOOPT=-xO0
#------------------------------------------------------------------------
# Linker flags
# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
MAPFLAG = -Wl,--version-script=FILENAME
# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
SONAMEFLAG = -h SONAME
# Build shared library
SHARED_FLAG = -G
#------------------------------------------------------------------------
# Debug flags
DEBUG_CFLAGS += -g
FASTDEBUG_CFLAGS = -g0
os_family = linux
arch = x86
arch_model = x86_64
os_arch = linux_x86
os_arch_model = linux_x86_64
lib_arch = amd64
compiler = sparcWorks
gnu_dis_arch = amd64
sysdefs = -DLINUX -DSPARC_WORKS -D_GNU_SOURCE -DAMD64
os_family = linux
arch = x86
arch_model = x86_32
os_arch = linux_x86
os_arch_model = linux_x86_32
lib_arch = i386
compiler = sparcWorks
gnu_dis_arch = i386
sysdefs = -DLINUX -DSPARC_WORKS -D_GNU_SOURCE -DIA32
...@@ -1304,7 +1304,7 @@ void Assembler::movl(Address dst, Register src) { ...@@ -1304,7 +1304,7 @@ void Assembler::movl(Address dst, Register src) {
emit_operand(src, dst); emit_operand(src, dst);
} }
void Assembler::mov64(Register dst, int64_t imm64) { void Assembler::mov64(Register dst, intptr_t imm64) {
InstructionMark im(this); InstructionMark im(this);
int encode = prefixq_and_encode(dst->encoding()); int encode = prefixq_and_encode(dst->encoding());
emit_byte(0xB8 | encode); emit_byte(0xB8 | encode);
...@@ -1331,7 +1331,7 @@ void Assembler::movq(Register dst, Address src) { ...@@ -1331,7 +1331,7 @@ void Assembler::movq(Register dst, Address src) {
emit_operand(dst, src); emit_operand(dst, src);
} }
void Assembler::mov64(Address dst, int64_t imm32) { void Assembler::mov64(Address dst, intptr_t imm32) {
assert(is_simm32(imm32), "lost bits"); assert(is_simm32(imm32), "lost bits");
InstructionMark im(this); InstructionMark im(this);
prefixq(dst); prefixq(dst);
......
...@@ -232,7 +232,7 @@ LinuxAttachOperation* LinuxAttachListener::read_request(int s) { ...@@ -232,7 +232,7 @@ LinuxAttachOperation* LinuxAttachListener::read_request(int s) {
// where <ver> is the protocol version (1), <cmd> is the command // where <ver> is the protocol version (1), <cmd> is the command
// name ("load", "datadump", ...), and <arg> is an argument // name ("load", "datadump", ...), and <arg> is an argument
int expected_str_count = 2 + AttachOperation::arg_count_max; int expected_str_count = 2 + AttachOperation::arg_count_max;
int max_len = (strlen(ver_str) + 1) + (AttachOperation::name_length_max + 1) + const int max_len = (sizeof(ver_str) + 1) + (AttachOperation::name_length_max + 1) +
AttachOperation::arg_count_max*(AttachOperation::arg_length_max + 1); AttachOperation::arg_count_max*(AttachOperation::arg_length_max + 1);
char buf[max_len]; char buf[max_len];
......
...@@ -60,7 +60,18 @@ inline u4 Bytes::swap_u4(u4 x) { ...@@ -60,7 +60,18 @@ inline u4 Bytes::swap_u4(u4 x) {
#ifdef AMD64 #ifdef AMD64
inline u8 Bytes::swap_u8(u8 x) { inline u8 Bytes::swap_u8(u8 x) {
#ifdef SPARC_WORKS
// workaround for SunStudio12 CR6615391
__asm__ __volatile__ (
"bswapq %0"
:"=r" (x) // output : register 0 => x
:"0" (x) // input : x => register 0
:"0" // clobbered register
);
return x;
#else
return bswap_64(x); return bswap_64(x);
#endif
} }
#else #else
// Helper function for swap_u8 // Helper function for swap_u8
......
...@@ -62,8 +62,14 @@ ...@@ -62,8 +62,14 @@
#endif // AMD64 #endif // AMD64
address os::current_stack_pointer() { address os::current_stack_pointer() {
#ifdef SPARC_WORKS
register void *esp;
__asm__("mov %%"SPELL_REG_SP", %0":"=r"(esp));
return (address) ((char*)esp + sizeof(long)*2);
#else
register void *esp __asm__ (SPELL_REG_SP); register void *esp __asm__ (SPELL_REG_SP);
return (address) esp; return (address) esp;
#endif
} }
char* os::non_memory_address_word() { char* os::non_memory_address_word() {
...@@ -139,7 +145,12 @@ frame os::get_sender_for_C_frame(frame* fr) { ...@@ -139,7 +145,12 @@ frame os::get_sender_for_C_frame(frame* fr) {
} }
intptr_t* _get_previous_fp() { intptr_t* _get_previous_fp() {
#ifdef SPARC_WORKS
register intptr_t **ebp;
__asm__("mov %%"SPELL_REG_FP", %0":"=r"(ebp));
#else
register intptr_t **ebp __asm__ (SPELL_REG_FP); register intptr_t **ebp __asm__ (SPELL_REG_FP);
#endif
return (intptr_t*) *ebp; // we want what it points to. return (intptr_t*) *ebp; // we want what it points to.
} }
...@@ -575,7 +586,9 @@ bool os::Linux::supports_variable_stack_size() { return true; } ...@@ -575,7 +586,9 @@ bool os::Linux::supports_variable_stack_size() { return true; }
#else #else
size_t os::Linux::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; size_t os::Linux::min_stack_allowed = (48 DEBUG_ONLY(+4))*K;
#ifdef __GNUC__
#define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;}) #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;})
#endif
// Test if pthread library can support variable thread stack size. LinuxThreads // Test if pthread library can support variable thread stack size. LinuxThreads
// in fixed stack mode allocates 2M fixed slot for each thread. LinuxThreads // in fixed stack mode allocates 2M fixed slot for each thread. LinuxThreads
...@@ -606,7 +619,11 @@ bool os::Linux::supports_variable_stack_size() { ...@@ -606,7 +619,11 @@ bool os::Linux::supports_variable_stack_size() {
// return true and skip _thread_safety_check(), so we may not be able to // return true and skip _thread_safety_check(), so we may not be able to
// detect stack-heap collisions. But otherwise it's harmless. // detect stack-heap collisions. But otherwise it's harmless.
// //
#ifdef __GNUC__
return (GET_GS() != 0); return (GET_GS() != 0);
#else
return false;
#endif
} }
} }
#endif // AMD64 #endif // AMD64
......
...@@ -37,23 +37,45 @@ ...@@ -37,23 +37,45 @@
# include <stdlib.h> # include <stdlib.h>
# include <wchar.h> # include <wchar.h>
# include <stdarg.h> # include <stdarg.h>
#ifdef SOLARIS
# include <ieeefp.h> # include <ieeefp.h>
#endif
# include <math.h> # include <math.h>
#ifdef LINUX
#ifndef FP_PZERO
// Linux doesn't have positive/negative zero
#define FP_PZERO FP_ZERO
#endif
#ifndef fpclass
#define fpclass fpclassify
#endif
#endif
# include <time.h> # include <time.h>
# include <fcntl.h> # include <fcntl.h>
# include <dlfcn.h> # include <dlfcn.h>
# include <pthread.h> # include <pthread.h>
#ifdef SOLARIS
# include <thread.h> # include <thread.h>
#endif
# include <limits.h> # include <limits.h>
# include <errno.h> # include <errno.h>
#ifdef SOLARIS
# include <sys/trap.h> # include <sys/trap.h>
# include <sys/regset.h> # include <sys/regset.h>
# include <sys/procset.h> # include <sys/procset.h>
# include <ucontext.h> # include <ucontext.h>
# include <setjmp.h> # include <setjmp.h>
#endif
# ifdef SOLARIS_MUTATOR_LIBTHREAD # ifdef SOLARIS_MUTATOR_LIBTHREAD
# include <sys/procfs.h> # include <sys/procfs.h>
# endif # endif
#ifdef LINUX
# include <inttypes.h>
# include <signal.h>
# include <ucontext.h>
# include <sys/time.h>
#endif
// 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
// When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
...@@ -68,6 +90,11 @@ ...@@ -68,6 +90,11 @@
// pointer when it extracts the argument, then we have a problem. // pointer when it extracts the argument, then we have a problem.
// //
// Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0. // Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.
//
// Note: this fix doesn't work well on Linux because NULL will be overwritten
// whenever a system header file is included. Linux handles NULL correctly
// through a special type '__null'.
#ifdef SOLARIS
#ifdef _LP64 #ifdef _LP64
#undef NULL #undef NULL
#define NULL 0L #define NULL 0L
...@@ -76,13 +103,25 @@ ...@@ -76,13 +103,25 @@
#define NULL 0 #define NULL 0
#endif #endif
#endif #endif
#endif
// NULL vs NULL_WORD: // NULL vs NULL_WORD:
// On Linux NULL is defined as a special type '__null'. Assigning __null to // On Linux NULL is defined as a special type '__null'. Assigning __null to
// integer variable will cause gcc warning. Use NULL_WORD in places where a // integer variable will cause gcc warning. Use NULL_WORD in places where a
// pointer is stored as integer value. // pointer is stored as integer value. On some platforms, sizeof(intptr_t) >
#define NULL_WORD NULL // sizeof(void*), so here we want something which is integer type, but has the
// same size as a pointer.
#ifdef LINUX
#ifdef _LP64
#define NULL_WORD 0L
#else
#define NULL_WORD 0
#endif
#else
#define NULL_WORD NULL
#endif
#ifndef LINUX
// Compiler-specific primitive types // Compiler-specific primitive types
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
#ifndef _UINT32_T #ifndef _UINT32_T
...@@ -100,6 +139,7 @@ typedef unsigned int uintptr_t; ...@@ -100,6 +139,7 @@ typedef unsigned int uintptr_t;
// If this gets an error, figure out a symbol XXX that implies the // If this gets an error, figure out a symbol XXX that implies the
// prior definition of intptr_t, and add "&& !defined(XXX)" above. // prior definition of intptr_t, and add "&& !defined(XXX)" above.
#endif #endif
#endif
// Additional Java basic types // Additional Java basic types
...@@ -128,7 +168,7 @@ inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; } ...@@ -128,7 +168,7 @@ inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; }
const jlong min_jlong = CONST64(0x8000000000000000); const jlong min_jlong = CONST64(0x8000000000000000);
const jlong max_jlong = CONST64(0x7fffffffffffffff); const jlong max_jlong = CONST64(0x7fffffffffffffff);
#ifdef SOLARIS
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// ANSI C++ fixes // ANSI C++ fixes
// NOTE:In the ANSI committee's continuing attempt to make each version // NOTE:In the ANSI committee's continuing attempt to make each version
...@@ -162,7 +202,7 @@ extern "C" { ...@@ -162,7 +202,7 @@ extern "C" {
typedef int (*int_fnP_cond_tP_i_vP)(cond_t *cv, int scope, void *arg); typedef int (*int_fnP_cond_tP_i_vP)(cond_t *cv, int scope, void *arg);
typedef int (*int_fnP_cond_tP)(cond_t *cv); typedef int (*int_fnP_cond_tP)(cond_t *cv);
}; };
#endif
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Debugging // Debugging
...@@ -173,7 +213,7 @@ extern "C" void breakpoint(); ...@@ -173,7 +213,7 @@ extern "C" void breakpoint();
#define BREAKPOINT ::breakpoint() #define BREAKPOINT ::breakpoint()
// checking for nanness // checking for nanness
#ifdef SOLARIS
#ifdef SPARC #ifdef SPARC
inline int g_isnan(float f) { return isnanf(f); } inline int g_isnan(float f) { return isnanf(f); }
#else #else
...@@ -182,6 +222,12 @@ inline int g_isnan(float f) { return isnand(f); } ...@@ -182,6 +222,12 @@ inline int g_isnan(float f) { return isnand(f); }
#endif #endif
inline int g_isnan(double f) { return isnand(f); } inline int g_isnan(double f) { return isnand(f); }
#elif LINUX
inline int g_isnan(float f) { return isnanf(f); }
inline int g_isnan(double f) { return isnan(f); }
#else
#error "missing platform-specific definition here"
#endif
// Checking for finiteness // Checking for finiteness
...@@ -195,9 +241,11 @@ inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); } ...@@ -195,9 +241,11 @@ inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); }
// Misc // Misc
// NOTE: This one leads to an infinite recursion on Linux
#ifndef LINUX
int local_vsnprintf(char* buf, size_t count, const char* fmt, va_list argptr); int local_vsnprintf(char* buf, size_t count, const char* fmt, va_list argptr);
#define vsnprintf local_vsnprintf #define vsnprintf local_vsnprintf
#endif
// Portability macros // Portability macros
#define PRAGMA_INTERFACE #define PRAGMA_INTERFACE
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册