Skip to content

Commit

Permalink
Fixes for errors encountered compiling for OSX
Browse files Browse the repository at this point in the history
* add OSX specific uma artifacts
* update uma artifacts with osx requirements

Signed-off-by: Joe deKoning <[email protected]>
  • Loading branch information
jdekonin authored and JamesKingdon committed Apr 18, 2019
1 parent a760cef commit 28210be
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 5 deletions.
1 change: 0 additions & 1 deletion buildspecs/osx_x86-64.spec
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
<property name="uma_make_cmd_cxx_exe_ld" value="$(CXX)"/>
<property name="uma_make_cmd_dll_ld" value="$(CC)"/>
<property name="uma_make_cmd_exe_ld" value="$(CC)"/>
<property name="uma_make_cmd_interp_gcc" value="gcc-4.6"/>
<property name="uma_make_cmd_ranlib" value="ranlib"/>
<property name="uma_processor" value="amd64"/>
<property name="uma_type" value="unix,osx"/>
Expand Down
60 changes: 60 additions & 0 deletions runtime/gc_glue_java/configure_includes/configure_osx.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
###############################################################################
# Copyright (c) 2017, 2017 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
# distribution and is available at http://eclipse.org/legal/epl-2.0
# or the Apache License, Version 2.0 which accompanies this distribution
# and is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# This Source Code may also be made available under the following Secondary
# Licenses when the conditions for such availability set forth in the
# Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
# version 2 with the GNU Classpath Exception [1] and GNU General Public
# License, version 2 with the OpenJDK Assembly Exception [2].
#
# [1] https://www.gnu.org/software/classpath/license.html
# [2] http://openjdk.java.net/legal/assembly-exception.html
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
###############################################################################

TEMP_TARGET_DATASIZE:=64

include $(CONFIG_INCL_DIR)/configure_common.mk

CONFIGURE_ARGS += \
--enable-OMR_EXAMPLE \
--enable-OMR_GC \
--enable-OMR_JITBUILDER \
--enable-OMR_PORT \
--enable-OMR_THREAD \
--enable-OMR_OMRSIG \
--enable-OMRTHREAD_LIB_UNIX \
--enable-OMR_ARCH_X86 \
--enable-OMR_ENV_DATA64 \
--enable-OMR_ENV_LITTLE_ENDIAN \
--enable-OMR_GC_TLH_PREFETCH_FTA \
--enable-OMR_PORT_CAN_RESERVE_SPECIFIC_ADDRESS \
--enable-OMR_TEST_COMPILER \
--enable-OMR_THR_FORK_SUPPORT \
--enable-OMR_THR_THREE_TIER_LOCKING \
--enable-OMR_THR_YIELD_ALG \
--enable-OMR_GC_ARRAYLETS \
--enable-OMR_THR_SPIN_WAKE_CONTROL


CONFIGURE_ARGS += libprefix=lib exeext= solibext=.dylib arlibext=.a objext=.o

CONFIGURE_ARGS += 'AS=as'
CONFIGURE_ARGS += 'CC=cc'
CONFIGURE_ARGS += 'CXX=c++'
CONFIGURE_ARGS += 'CCLINK=$$(CC)'
CONFIGURE_ARGS += 'CXXLINKSHARED=$$(CC)'
CONFIGURE_ARGS += 'CXXLINKEXE=$$(CXX)'
CONFIGURE_ARGS += 'AR=ar'

CONFIGURE_ARGS += 'OMR_HOST_OS=osx'
CONFIGURE_ARGS += 'OMR_HOST_ARCH=x86'
CONFIGURE_ARGS += 'OMR_TARGET_DATASIZE=$(TEMP_TARGET_DATASIZE)'
CONFIGURE_ARGS += 'OMR_TOOLCHAIN=gcc'
4 changes: 2 additions & 2 deletions runtime/jilgen/jilconsts.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ createConstant(OMRPortLibrary *OMRPORTLIB, char const *name, UDATA value)
}
#if defined(J9VM_ARCH_POWER) || defined(J9VM_ARCH_ARM)
return omrstr_printf(line, sizeof(line), "#define %s %zu\n", name, value);
#elif defined(LINUX) /* J9VM_ARCH_POWER || J9VM_ARCH_ARM */
#elif defined(LINUX) || defined(OSX) /* J9VM_ARCH_POWER || J9VM_ARCH_ARM */
return omrstr_printf(line, sizeof(line), "%s = %zu\n", name, value);
#elif defined(WIN32) /* LINUX */
#elif defined(WIN32) /* LINUX || OSX */
return omrstr_printf(line, sizeof(line), "%s equ %zu\n", name, value);
#elif defined(J9ZOS390) /* WIN32 */
return omrstr_printf(line, sizeof(line), "%s EQU %zu\n", name, value);
Expand Down
1 change: 1 addition & 0 deletions runtime/jilgen/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<library name="socket" type="macro"/>
<library name="iconv" type="system">
<include-if condition="spec.aix_.*"/>
<include-if condition="spec.osx_.*"/>
</library>
<library name="perfstat" type="system">
<include-if condition="spec.aix_.*"/>
Expand Down
6 changes: 4 additions & 2 deletions runtime/makelib/targets.mk.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ all: $(TARGETS)
<#include "targets.mk.ztpf.inc.ftl">
<#elseif uma.spec.type.linux>
<#include "targets.mk.linux.inc.ftl">
<#elseif uma.spec.type.osx>
<#include "targets.mk.osx.inc.ftl">
</#if>

# Add OMR include paths
Expand Down Expand Up @@ -430,7 +432,7 @@ UMA_PASM_INCLUDES:=$(addprefix -I ,$(UMA_INCLUDES))
-mv -f $*.s $*.hold
</#if>

<#if uma.spec.type.linux>
<#if uma.spec.type.linux || uma.spec.type.osx>
# compilation rule for .spp files - translate ! to newline and ^ to #
%$(UMA_DOT_O): %.spp
$(CPP) $(CPPFLAGS) -o $*.i $*.spp
Expand Down Expand Up @@ -584,7 +586,7 @@ endif

.PHONY : all clean ddrgen

<#if uma.spec.type.windows || uma.spec.type.linux>
<#if uma.spec.type.windows || uma.spec.type.linux || uma.spec.type.osx>
# GNU make magic, replace the .o in UMA_OBJECTS with .d's
UMA_DEPS := $(filter-out %.res,$(UMA_OBJECTS))
UMA_DEPS := $(UMA_DEPS:$(UMA_DOT_O)=.d)
Expand Down
158 changes: 158 additions & 0 deletions runtime/makelib/targets.mk.osx.inc.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<#--
Copyright (c) 1998, 2017 IBM Corp. and others
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
distribution and is available at https://www.eclipse.org/legal/epl-2.0/
or the Apache License, Version 2.0 which accompanies this distribution and
is available at https://www.apache.org/licenses/LICENSE-2.0
This Source Code may also be made available under the following
Secondary Licenses when the conditions for such availability set
forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
General Public License, version 2 with the GNU Classpath
Exception [1] and GNU General Public License, version 2 with the
OpenJDK Assembly Exception [2].
[1] https://www.gnu.org/software/classpath/license.html
[2] http://openjdk.java.net/legal/assembly-exception.html
SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
-->

<#assign lib_target_rule>
$(UMA_LIBTARGET): $(UMA_OBJECTS)
$(AR) rcv $(UMA_LIBTARGET) $(UMA_OBJECTS)
</#assign>

<#assign dll_target_rule>
$(UMA_DLLTARGET): $(UMA_OBJECTS) $(UMA_TARGET_LIBRARIES)
$(UMA_DLL_LD) $(UMA_DLL_LINK_FLAGS) \
$(VMLINK) $(UMA_LINK_PATH) -o $(UMA_DLLTARGET)\
$(UMA_OBJECTS) \
$(UMA_DLL_LINK_POSTFLAGS)
</#assign>

<#assign exe_target_rule>
$(UMA_EXETARGET): $(UMA_OBJECTS) $(UMA_TARGET_LIBRARIES)
$(UMA_EXE_LD) $(UMA_EXE_PREFIX_FLAGS) $(UMA_LINK_PATH) $(VMLINK) \
$(UMA_OBJECTS) \
$(UMA_BEGIN_DASH_L) \
$(UMA_LINK_STATIC_LIBRARIES) \
$(UMA_END_DASH_L) \
$(UMA_LINK_SHARED_LIBRARIES) \
-o $@ $(UMA_EXE_POSTFIX_FLAGS)
</#assign>

UMA_BEGIN_DASH_L=
UMA_END_DASH_L=

UMA_EXE_POSTFIX_FLAGS+=-lm -liconv -lc -ldl -lutil -Wl,-rpath,\$$ORIGIN

<#if uma.spec.processor.amd64>
UMA_MASM2GAS_FLAGS+=--64
</#if>

ifndef UMA_DO_NOT_OPTIMIZE_CCODE
<#if uma.spec.properties.uma_optimization_cflags.defined>
UMA_OPTIMIZATION_CFLAGS+=${uma.spec.properties.uma_optimization_cflags.value}
<#else>
<#if uma.spec.processor.amd64>
UMA_OPTIMIZATION_CFLAGS+=-O3 -fno-strict-aliasing
<#else>
UMA_OPTIMIZATION_CFLAGS+=-O
</#if>
</#if>
<#if uma.spec.properties.uma_optimization_cxxflags.defined>
UMA_OPTIMIZATION_CXXFLAGS+=${uma.spec.properties.uma_optimization_cxxflags.value}
<#else>
<#if uma.spec.processor.amd64>
UMA_OPTIMIZATION_CXXFLAGS+=-O3 -fno-strict-aliasing
<#if uma.spec.flags.env_littleEndian.enabled && uma.spec.type.linux>
UMA_OPTIMIZATION_CXXFLAGS+=-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
</#if>
<#else>
UMA_OPTIMIZATION_CXXFLAGS+=-O
</#if>
</#if>
else
UMA_OPTIMIZATION_CFLAGS+=-O0
UMA_OPTIMIZATION_CXXFLAGS+=-O0
endif


CFLAGS+=$(UMA_OPTIMIZATION_CFLAGS)
CXXFLAGS+=$(UMA_OPTIMIZATION_CXXFLAGS)

<#if uma.spec.flags.env_gcc.enabled>
CXXFLAGS+=-fno-exceptions -fno-threadsafe-statics
</#if>

ifdef j9vm_uma_gnuDebugSymbols
CFLAGS+=-g
CXXFLAGS+=-g
endif

<#if uma.spec.processor.amd64 >
<#-- GCC compilers support dependency generation -->
CFLAGS+=-MMD
CPPFLAGS+=-MMD
CXXFLAGS+=-MMD
</#if>

CFLAGS+=-DOSX -D_REENTRANT -D_FILE_OFFSET_BITS=64
CXXFLAGS+=-DOSX -D_REENTRANT -D_FILE_OFFSET_BITS=64
CPPFLAGS+=-DOSX -D_REENTRANT

<#-- Add Position Indepdent compile flag -->
CFLAGS+=-fPIC
CXXFLAGS+=-fPIC

ifdef j9vm_uma_supportsIpv6
CFLAGS+=-DIPv6_FUNCTION_SUPPORT
CXXFLAGS+=-DIPv6_FUNCTION_SUPPORT
CPPFLAGS+=-DIPv6_FUNCTION_SUPPORT
endif

<#if uma.spec.processor.amd64>
CFLAGS+=-DJ9HAMMER -m64
CXXFLAGS+=-DJ9HAMMER -m64
CPPFLAGS+=-DJ9HAMMER -m64
</#if>

UMA_DLL_LINK_FLAGS+=-shared -install_name lib$(UMA_TARGET_NAME).dylib
ifdef UMA_USING_LD_TO_LINK
UMA_DLL_LINK_FLAGS+=origin -rpath \$$ORIGIN --disable-new-dtags
else
UMA_DLL_LINK_FLAGS+=-Xlinker -rpath -Xlinker \$$ORIGIN
endif

UMA_DLL_LINK_POSTFLAGS+=$(UMA_LINK_STATIC_LIBRARIES)
UMA_DLL_LINK_POSTFLAGS+=$(UMA_LINK_SHARED_LIBRARIES)

ifdef j9vm_uma_gnuDebugSymbols
UMA_DLL_LINK_POSTFLAGS+=-g
endif

<#if uma.spec.processor.amd64>
UMA_DLL_LINK_FLAGS+=-m64
</#if>

ifdef UMA_IS_C_PLUS_PLUS
UMA_DLL_LINK_POSTFLAGS+=-lc
endif
UMA_DLL_LINK_POSTFLAGS+=-lm

ifdef UMA_TREAT_WARNINGS_AS_ERRORS
ifndef UMA_SUPPRESS_WARNINGS_AS_ERRORS
CFLAGS+=-Wimplicit -Wreturn-type -Werror
CXXFLAGS+=-Wreturn-type -Werror
endif
endif

ifdef UMA_ENABLE_ALL_WARNINGS
ifndef UMA_SUPPRESS_ALL_WARNINGS
CFLAGS+=-Wall
CXXFLAGS+=-Wall -Wno-non-virtual-dtor
endif
endif
1 change: 1 addition & 0 deletions runtime/port/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@
<library name="omrglue" type="external"/>
<library name="iconv" type="system">
<include-if condition="spec.aix_.*"/>
<include-if condition="spec.osx_.*"/>
</library>
<library name="perfstat" type="system">
<include-if condition="spec.aix_.*"/>
Expand Down
4 changes: 4 additions & 0 deletions runtime/thread/threadshared.mk.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ MODULE_SHARED_LIBS += rt
MODULE_SHARED_LIBS += pthread
endif

ifeq (osx,$(OMR_HOST_OS))
GLOBAL_LDFLAGS+=-install_name lib$(MODULE_NAME).dylib
endif

include $(top_srcdir)/omrmakefiles/rules.mk

ifeq (win,$(OMR_HOST_OS))
Expand Down

0 comments on commit 28210be

Please sign in to comment.