diff --git a/vm/cmake/mac_osx.cmake b/vm/cmake/mac_osx.cmake index b834bf27..067a8284 100644 --- a/vm/cmake/mac_osx.cmake +++ b/vm/cmake/mac_osx.cmake @@ -12,7 +12,7 @@ endif() set(SELF_OSX_INFO_PLIST Info) if(SELF_QUARTZ) - message(STATUS "Using Quartz plaform windows.") + message(STATUS "Using Quartz platform windows.") list(APPEND _defines -DQUARTZ_LIB) endif() @@ -23,7 +23,7 @@ if(SELF_OSX_COCOA) endif() set(SELF_PREFIX_PREFIX_THRESHOLD_INIT - "20" # DO NOT SET ABVOE 20. Breaks X-includes! + "20" # DO NOT SET ABOVE 20. Breaks X-includes! ) @@ -35,18 +35,28 @@ set(GUI_TYPE MACOSX_BUNDLE) if(NOT CONFIG_HAS_BEEN_RUN_BEFORE) # no x86_64 atm, # so forcibly overwrite - set(CMAKE_OSX_ARCHITECTURES i386 CACHE STRING - "Build architectures for OSX" - FORCE) - # we need to be 10.6 compliant. - # so forcibly overwrite - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE STRING - "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value." + set(CMAKE_OSX_ARCHITECTURES ${platform_processor} CACHE STRING + "Build architectures for OSX" FORCE) + + if(${platform_processor} STREQUAL "i386") + # we need to be 10.6 compliant. + # so forcibly overwrite + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE STRING + "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value." + FORCE) + set(_sdk_list "macosx10.10" "macosx10.9" "macosx10.8" "macosx10.7" "macosx10.6") + elseif(${platform_processor} STREQUAL "ppc") + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING + "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value." + FORCE) + set(_sdk_list "macosx10.5") + endif() + # see if we can get a matching SDK # first, unset this because it is probably set to the latest SDK unset(CMAKE_OSX_SYSROOT CACHE) - foreach(sdk "macosx10.9" "macosx10.8" "macosx10.7" "macosx10.6") + foreach(sdk ${_sdk_list}) execute_process( COMMAND xcodebuild -version -sdk "${sdk}" Path OUTPUT_VARIABLE _sdkpath @@ -200,7 +210,7 @@ macro(setup_target target) endif() endif() - # These are the XCode-equivalendts for the flags/warnings in setup. + # These are the XCode-equivalents for the flags/warnings in setup. # we hence remove the respective flag, it gets added anyways at compile time set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_CHECK_SWITCH_STATEMENTS "YES") remove_definitions(-Wswitch) @@ -237,7 +247,7 @@ macro(setup_target target) set(CMAKE_XCODE_ATTRIBUTE_COPY_PHASE_STRIP "NO") set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym") - # cmake adds warnings hardcoded which we dont want. + # cmake adds warnings hardcoded which we don't want. # mess with the warnings set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "") endif() diff --git a/vm/cmake/setup.cmake b/vm/cmake/setup.cmake index b3821d83..2caaa25d 100644 --- a/vm/cmake/setup.cmake +++ b/vm/cmake/setup.cmake @@ -51,30 +51,18 @@ endif() if (clang) list(APPEND _flags -Wabi) elseif(gcc) - list(APPEND _flags -Wabi=11) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + list(APPEND _flags -Wabi=11) + endif() endif() + +# These warning options are accepted by the latest xcode for MacOS X +# 10.5 with gcc 4.2. The compiler versions for the rest of them were +# picked from inspecting the gcc docs and should not be too wrong. list(APPEND _flags -Wall -Wextra - # probably ok, but needs auditing - -Wno-delete-non-virtual-dtor - - # old use of "volatile" in lieu of attribute((noreturn)) - -Wno-ignored-qualifiers - - # TODO: just add FALLTHROUGH annotation comments - -Wno-implicit-fallthrough - - # these are often hit or miss... - -Wno-maybe-uninitialized - - # complains about a few cases of existing idiomatic layout - -Wno-misleading-indentation - - # cf. -fno-delete-null-pointer-checks above - -Wno-nonnull - # these are a pain to fix properly... -Wno-sign-compare @@ -85,15 +73,46 @@ list(APPEND _flags # vm/src/any/parser/parser.cpp uses some literal chars not in enum -Wno-switch - # there are few, marked "for debugging", and they probably need to - # be marked volatile so that those assignments are not elided and - # the values are actually available to be inspected from the - # debugger - -Wno-unused-but-set-variable - # mostly spammy for C++, needs a rainy day cleanup round -Wno-unused-parameter # needs a rainy day cleanup round -Wno-unused-variable ) + +# NB: XXX: For now this only handles gcc. Recent clang cannot be used +# to compile Self b/c they insist on this != null. Older clang +# versions should probably be fine, but I currently don't have +# bandwidth spelunking throgh clang docs/rtfs in search of the right +# versions. +macro(VersionedFlag FirstVersion) + if (gcc) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL ${FirstVersion}) + list(APPEND _flags ${ARGN}) + endif() + endif() +endmacro() + +# probably ok, but needs auditing +VersionedFlag(4.7 -Wno-delete-non-virtual-dtor) + +# old use of "volatile" in lieu of attribute((noreturn)) +VersionedFlag(4.3 -Wno-ignored-qualifiers) + +# TODO: just add FALLTHROUGH annotation comments +VersionedFlag(7.0 -Wno-implicit-fallthrough) + +# these are often hit or miss... +VersionedFlag(4.7 -Wno-maybe-uninitialized) + +# complains about a few cases of existing idiomatic layout +VersionedFlag(6.0 -Wno-misleading-indentation) + +# cf. -fno-delete-null-pointer-checks above +# (it was supported in earlier gcc versions, but not for C++) +VersionedFlag(5.0 -Wno-nonnull) + +# there are few, marked "for debugging", and they probably need to be +# marked volatile so that those assignments are not elided and the +# values are actually available to be inspected from the debugger +VersionedFlag(4.6 -Wno-unused-but-set-variable) diff --git a/vm/src/i386/runtime/asmDefs_gcc_i386.hh b/vm/src/i386/runtime/asmDefs_gcc_i386.hh index 5da796f2..ab89b38a 100644 --- a/vm/src/i386/runtime/asmDefs_gcc_i386.hh +++ b/vm/src/i386/runtime/asmDefs_gcc_i386.hh @@ -77,8 +77,12 @@ .global C_SYM(name) ; \ C_SYM(name): +#ifdef __ELF__ #define end_exported_function(name) \ .size C_SYM(name), . - C_SYM(name) +#else +#define end_exported_function(name) /* no .size directive for macho */ +#endif // LinkageArea record: diff --git a/vm/src/ppc/memory/search_ppc.cpp b/vm/src/ppc/memory/search_ppc.cpp index 4586d2cc..08f9e3a5 100644 --- a/vm/src/ppc/memory/search_ppc.cpp +++ b/vm/src/ppc/memory/search_ppc.cpp @@ -7,7 +7,7 @@ # pragma implementation "search_ppc.hh" # include "_search_ppc.cpp.incl" -#if TARGET_OS_VERSION == NETBSD_VERSION +#if TARGET_OS_VERSION == MACOSX_VERSION || TARGET_OS_VERSION == NETBSD_VERSION #include #endif diff --git a/vm/src/ppc/prims/asmPrims_gcc_ppc.S b/vm/src/ppc/prims/asmPrims_gcc_ppc.S index 2bb03616..8229e740 100644 --- a/vm/src/ppc/prims/asmPrims_gcc_ppc.S +++ b/vm/src/ppc/prims/asmPrims_gcc_ppc.S @@ -9,29 +9,28 @@ // some integer primitives -// .include "../../src/ppc/runtime/asmDefs_gcc_ppc.hh" -# include "asmDefs_gcc_ppc.hh" +# include "_asmPrims_ppc.S.incl" -#define ret_prim_error(error_code) \ - import_data_address(r3, VMString) ; \ - lwz r3, error_code(r3) ; \ - addi r3, r3, Mark_Tag - Mem_Tag ; \ +#define ret_prim_error(error_code) \ + import_data_address(r3, VMString) __ \ + lwz r3, error_code(r3) __ \ + addi r3, r3, Mark_Tag - Mem_Tag __ \ blr -#define arith_prim(name, opcode) \ - start_exported_function(name) ; \ - or r0, rcv, arg ; \ - andi. r0, r0, Tag_Mask ; \ - beq name ## _OK ; \ - ret_prim_error(badTypeOffset) ; \ -name ## _OK: \ - /* clear sum ovfl bit */ \ - mcrxr 0 ; \ - opcode rcv, rcv, arg ; \ - bnslr ; \ +#define arith_prim(name, opcode) \ + start_exported_function(name) __ \ + or r0, rcv, arg __ \ + andi. r0, r0, Tag_Mask __ \ + beq name ## _OK __ \ + ret_prim_error(badTypeOffset) __ \ + name ## _OK: \ + /* clear sum ovfl bit */ \ + mcrxr 0 __ \ + opcode rcv, rcv, arg __ \ + bnslr __ \ ret_prim_error(overflowOffset) arith_prim(smi_add_prim, addo. ) @@ -51,14 +50,14 @@ smi_mul_prim_OK: ret_prim_error(overflowOffset) -#define log_prim(name, opcode) \ - start_exported_function(name) ; \ - or r0, rcv, arg ; \ - andi. r0, r0, Tag_Mask ; \ - beq name ## _OK ; \ - ret_prim_error(badTypeOffset) ; \ -name ## _OK: \ - opcode rcv, rcv, arg ; \ +#define log_prim(name, opcode) \ + start_exported_function(name) __ \ + or r0, rcv, arg __ \ + andi. r0, r0, Tag_Mask __ \ + beq name ## _OK __ \ + ret_prim_error(badTypeOffset) __ \ + name ## _OK: \ + opcode rcv, rcv, arg __ \ blr log_prim(smi_and_prim, and) @@ -90,15 +89,15 @@ smi_arithmetic_shift_left_prim_OK: ret_prim_error(overflowOffset) -#define simple_shift_prim(name, opcode) \ - start_exported_function(name) ; \ - or r0, rcv, arg ; \ - andi. r0, r0, Tag_Mask ; \ - beq 1f ; \ - ret_prim_error(badTypeOffset) ; \ -1: \ - /* shift out tag */ \ - srawi arg, arg, 2 ; \ +#define simple_shift_prim(name, opcode) \ + start_exported_function(name) __ \ + or r0, rcv, arg __ \ + andi. r0, r0, Tag_Mask __ \ + beq 1f __ \ + ret_prim_error(badTypeOffset) __ \ + 1: \ + /* shift out tag */ \ + srawi arg, arg, 2 __ \ opcode rcv, rcv, arg simple_shift_prim(smi_logical_shift_left_prim, slw) diff --git a/vm/src/ppc/runtime/asmDefs_gcc_ppc.hh b/vm/src/ppc/runtime/asmDefs_gcc_ppc.hh index 44a0cc95..e914290e 100644 --- a/vm/src/ppc/runtime/asmDefs_gcc_ppc.hh +++ b/vm/src/ppc/runtime/asmDefs_gcc_ppc.hh @@ -4,7 +4,8 @@ // Copyright 1992-9 Sun Microsystems, Inc. and Stanford University. // See the LICENSE file for license information. -#if TARGET_OS_VERSION == NETBSD_VERSION +// can't include config.hh in asm files, so FOO_VERSION are not defined +#if !defined(__APPLE__) // TARGET_OS_VERSION == NETBSD_VERSION #define r0 0 #define r1 1 #define r2 2 @@ -152,21 +153,23 @@ non_local_return_offset = 8 // offset of NLR instruction from call // --------------------------------------------------------- # if defined(__APPLE__) + # define __ @ # define C_SYM(name) _##name # elif defined(__ELF__) + # define __ ; # define C_SYM(name) name # else # error what? # endif -#define start_exported_function(name) \ - .globl C_SYM(name); \ +#define start_exported_function(name) \ + .globl C_SYM(name) __ \ C_SYM(name): -#define load_global_address(tmp_reg, data_sym) \ - .globl C_SYM(data_sym); \ +#define load_global_address(tmp_reg, data_sym) \ + .globl C_SYM(data_sym) __ \ load_addr(tmp_reg, C_SYM(data_sym)) #define import_data_address(tmp_reg, data_sym) \ @@ -194,35 +197,27 @@ badTypeOffset = 8 divisionByZeroOffset = 16 overflowOffset = 20 -// Warning: Duplicated in tag.hh -Int_Tag = 0 -Mem_Tag = 1 -Float_Tag = 2 -Mark_Tag = 3 - -Tag_Mask = 3 - // ===================================================== // call untested DOES NOT QUITE WORK -#define Untested(string, tmp) \ - b 3f ; \ -1: .asciz string ; \ -2: C_SYM(Untested_Stub) ; \ - \ -3: mflr r0 ; \ - import_function_address(tmp, C_SYM(Untested_stub)); \ - mtctr tmp ; \ - bctrl ; \ +#define Untested(string, tmp) \ + b 3f __ \ +1: .asciz string __ \ +2: C_SYM(Untested_Stub) __ \ + \ +3: mflr r0 __ \ + import_function_address(tmp, C_SYM(Untested_stub)) __ \ + mtctr tmp __ \ + bctrl __ \ mtlr r0 -#define load_addr(targ, val) \ - addis targ, 0, hi16(val) ; \ +#define load_addr(targ, val) \ + addis targ, 0, hi16(val) __ \ ori targ, targ, lo16(val) -#define load_val(targ, val) \ - addis targ, 0, ha16(val) ; \ +#define load_val(targ, val) \ + addis targ, 0, ha16(val) __ \ lwz targ, lo16(val) # endif // __ppc__ diff --git a/vm/src/ppc/runtime/runtime_asm_gcc_ppc.S b/vm/src/ppc/runtime/runtime_asm_gcc_ppc.S index d4a915df..5b7725d0 100644 --- a/vm/src/ppc/runtime/runtime_asm_gcc_ppc.S +++ b/vm/src/ppc/runtime/runtime_asm_gcc_ppc.S @@ -9,8 +9,8 @@ /* remove me from MW project when compiling under MW */ -# include "asmDefs_gcc_ppc.hh" - +# include "_runtime_asm_gcc_ppc.S.incl" + start_exported_function(currentFrame) mr r3, sp blr @@ -464,10 +464,10 @@ base_fr_size = LinkageArea_size/oopSize + NumRcvrAndArgRegisters + -SaveSelfNo # define vol_reg_count r30 -#define load_global_nonvol_regs \ - import_data_address(ByteMapBaseReg, byte_map_base) ; \ - import_data_address(SPLimitReg, SPLimit) ; \ - lwz ByteMapBaseReg, 0(ByteMapBaseReg) ; \ +#define load_global_nonvol_regs \ + import_data_address(ByteMapBaseReg, byte_map_base) __ \ + import_data_address(SPLimitReg, SPLimit) __ \ + lwz ByteMapBaseReg, 0(ByteMapBaseReg) __ \ lwz SPLimitReg, 0(SPLimitReg) diff --git a/vm/src/ppc/zone/allocZone_ppc.S b/vm/src/ppc/zone/allocZone_ppc.S index c1af1fed..f52b5259 100644 --- a/vm/src/ppc/zone/allocZone_ppc.S +++ b/vm/src/ppc/zone/allocZone_ppc.S @@ -7,7 +7,7 @@ # if TARGET_IS_PROFILED -# include "_allocZone_ppc.s.incl" +# include "_allocZone_ppc.S.incl" # include "asmDefs_gcc_ppc.hh" diff --git a/vm/src/unix/os/os_includes_unix.hh b/vm/src/unix/os/os_includes_unix.hh index ad0f7278..a9586ab6 100644 --- a/vm/src/unix/os/os_includes_unix.hh +++ b/vm/src/unix/os/os_includes_unix.hh @@ -179,6 +179,9 @@ extern "C" { # endif # include +# if !defined(MAP_ANONYMOUS) // old macosx +# define MAP_ANONYMOUS MAP_ANON +# endif # if TARGET_OS_VERSION == SUNOS_VERSION && COMPILER != GCC_COMPILER # define wait(x) __nonexistent_function_name_due_to_incorrect_header___