diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000000..37f98d87820 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,36 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +platform: x64 +configuration: Debug +shallow_clone: true +clone_depth: 1 + +environment: + GTEST_FILTER: '*dump_test_create_dump_*:*NumaSetAffinity:*NumaSetAffinitySuspended' + GTEST_COLOR: '1' + +before_build: + - ps: cmake -Wdev -G "Visual Studio 14 2015 Win64" . + +build: + project: omr.sln + parallel: true + +test_script: + - ps: ctest -V -C Debug diff --git a/.gitignore b/.gitignore index f2dabc79ab0..fe5433dd44c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ ############################################################################### # -# (c) Copyright IBM Corp. 2014, 2016 +# (c) Copyright IBM Corp. 2014, 2017 # # This program and the accompanying materials are made available # under the terms of the Eclipse Public License v1.0 and @@ -16,6 +16,15 @@ # Multiple authors (IBM Corp.) - initial implementation and documentation ############################################################################### +build/ +CMakeFiles/ +CMakeCache.txt +omrcfg.h +omrversionstrings.h +CTestTestfile.cmake +Makefile +cmake_install.cmake + # configure artifacts autom4te.cache config.cache diff --git a/.travis.yml b/.travis.yml index feb205df2ce..74b8dd09f66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,45 +15,53 @@ # Contributors: # Multiple authors (IBM Corp.) - initial implementation and documentation ############################################################################### - -language: c++ +os: + - linux + - osx +language: cpp sudo: false - -# https://docs.travis-ci.com/user/caching/ -cache: ccache - +cache: ccache # https://docs.travis-ci.com/user/caching/ +dist: trusty addons: apt: sources: - - ubuntu-toolchain-r-test + - ubuntu-toolchain-r-test packages: - - libnuma-dev - - bison - - gcc-multilib - - g++-multilib - - clang-3.4 - - libclang-3.4-dev - - llvm-3.4 - -before_script: - - ulimit -c unlimited - - export GTEST_FILTER=-*dump_test_create_dump_*:*NumaSetAffinity:*NumaSetAffinitySuspended -# Disable the core dump tests as container based builds don't allow setting -# core_pattern and don't have apport installed. This can be removed when -# apport is available in apt whitelist - + - libnuma-dev + - bison + - clang-3.4 + - libclang-3.4-dev + - llvm-3.4 + - gcc-multilib + - g++-multilib +env: + matrix: + - BUILD_WITH_CMAKE=yes + global: + - GTEST_COLOR=1 + - GTEST_FILTER=-*dump_test_create_dump_*:*NumaSetAffinity:*NumaSetAffinitySuspended + # Disable the core dump tests as container based builds don't allow setting + # core_pattern and don't have apport installed. This can be removed when + # apport is available in apt whitelist matrix: + allow_failures: + - env: BUILD_WITH_CMAKE=yes + exclude: + - os: osx + env: BUILD_WITH_CMAKE=yes include: - os: linux - env: SPEC=linux_x86 PLATFORM=amd64-linux-gcc - - os: linux - env: SPEC=linux_x86-64 PLATFORM=amd64-linux64-gcc + env: SPEC=linux_x86-64 PLATFORM=amd64-linux64-gcc - os: linux env: SPEC=linux_x86-64_cmprssptrs PLATFORM=amd64-linux64-gcc + - os: linux + env: RUN_LINT=yes RUN_BUILD=no SPEC=linux_x86-64 PLATFORM=amd64-linux64-gcc + dist: precise + - os: linux + env: SPEC=linux_x86 PLATFORM=amd64-linux-gcc - os: osx env: SPEC=osx_x86-64 - +before_script: + - ulimit -c unlimited script: - - make -f run_configure.mk OMRGLUE=./example/glue - - make && make test && ([ "$SPEC" != "linux_x86-64" ] || make lint) - + - bash ./scripts/build-on-travis.sh diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000000..2be8b7c0ba6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,113 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +cmake_minimum_required(VERSION 3.2 FATAL_ERROR) + +#TODO figure out method of sharing version info with makefile build +set(OMR_VERSION_MAJOR 0) +set(OMR_VERSION_MINOR 0) +set(OMR_VERSION_PATCH 1) +set(OMR_VERSION ${OMR_VERSION_MAJOR}.${OMR_VERSION_MINOR}.${OMR_VERSION_PATCH}) + +project(omr VERSION ${OMR_VERSION} LANGUAGES CXX C) + +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) + +### +### Getting the glue directory +### + +set(OMR_GLUE "./example/glue" CACHE PATH "The glue directory") + +# TODO: OMR_EXAMPLE flag +# TODO: OMR_RTTI flag + +# TODO: Version things + +set(OMR_VERSION_STRING "" CACHE STRING "") # TODO: Set the version +set(OMR_JIT_VERSION_STRING "" CACHE STRING "") # TODO: Set the version + +### +### Versions and stuff +### + +include(cmake/platform.cmake) +include(cmake/config.cmake) + +enable_testing() + +#include current source dir and current bin dir automatically +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +function(VPathResolve inlist dirlist outlist) + set(output "") + foreach(currentFile ${${inlist}}) + set(fileFound False) + foreach(currentDir ${${dirlist}}) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${currentDir}/${currentFile}") + list(APPEND output "${currentDir}/${currentFile}") + set(fileFound True) + break() + endif() + endforeach() + if(NOT fileFound) + message(FATAL_ERROR "Could not find file ${currentFile}") + endif() + endforeach() + set(${outlist} ${output} PARENT_SCOPE) +endfunction() + +include_directories( + ${PROJECT_BINARY_DIR} + ./include/ + ./include_core/ + ./third_party/ +) + +add_definitions( + -DUT_DIRECT_TRACE_REGISTRATION # TODO: Deal with that stupid jni issue in tracegen +) + +configure_file(./omrcfg.CMakeTemplate.h omrcfg.h) +configure_file(./omrversionstrings.CMakeTemplate.h omrversionstrings.h) + +add_subdirectory(tools) +# Yeah, its dumb doing this here. Read note in tools/CMakeLists.txt +if(CMAKE_CROSSCOMPILING) + include(${OMR_TOOLS_IMPORTFILE}) +endif() +add_subdirectory(thread) +add_subdirectory(port) +add_subdirectory(util) +add_subdirectory(omrtrace) +add_subdirectory(omr) +add_subdirectory(third_party) +add_subdirectory(omrsigcompat) + +#TODO should be wrapped in if() +add_subdirectory(fvtest) + +if(OMR_GC) + add_subdirectory(gc) + add_subdirectory("${OMR_GLUE}") +endif(OMR_GC) + +if(OMR_COMPILER) + # TODO: Actually support the compiler + add_subdirectory(compiler) +endif(OMR_COMPILER) diff --git a/cmake/caches/Travis.cmake b/cmake/caches/Travis.cmake new file mode 100644 index 00000000000..38ca8070a1e --- /dev/null +++ b/cmake/caches/Travis.cmake @@ -0,0 +1,15 @@ +set(OMR_EXAMPLE ON CACHE BOOL "") +set(OMR_JIT ON CACHE BOOL "") +set(OMR_GC ON CACHE BOOL "") +set(OMR_PORT ON CACHE BOOL "") +set(OMR_THREAD ON CACHE BOOL "") +set(OMR_OMRSIG ON CACHE BOOL "") +set(OMR_FVTEST ON CACHE BOOL "") +set(OMR_GLUE ${CMAKE_SOURCE_DIR}/example/glue) +set(OMR_GC_SEGREGATED_HEAP ON CACHE BOOL "") +set(OMR_GC_MODRON_SCAVENGER ON CACHE BOOL "") +set(OMR_GC_MODRON_CONCURRENT_MARK ON CACHE BOOL "") +set(OMR_THR_CUSTOM_SPIN_OPTIONS ON CACHE BOOL "") +set(OMR_NOTIFY_POLICY_CONTROL ON CACHE BOOL "") +set(OMR_THR_SPIN_WAKE_CONTROL ON CACHE BOOL "") +set(OMR_THR_SPIN_CODE_REFACTOR ON CACHE BOOL "") diff --git a/cmake/config.cmake b/cmake/config.cmake new file mode 100644 index 00000000000..7c45a099ef4 --- /dev/null +++ b/cmake/config.cmake @@ -0,0 +1,119 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +### +### Major Feature Flags +### + +set(OMR_GC ON CACHE BOOL "Enable the GC") +set(OMR_COMPILER OFF CACHE BOOL "Enable the compiler") +set(OMR_JITBUILDER OFF CACHE BOOL "Enable building JitBuilder") +set(OMR_TEST_COMPILER OFF CACHE BOOL "Enable building the test compiler") +set(OMR_PORT ON CACHE BOOL "Enable portability library") +set(OMR_THREAD ON CACHE BOOL "Enable thread library") +set(OMR_OMRSIG ON CACHE BOOL "Enable the OMR signal compatibility library") +# set(OMR_TOOLS On CACHE BOOL "Enable the build tools") +# TODO: Support building only tools for cross-compilation build + + + +### +### Boolean Feature Flags +### + +# TODO: This is a pretty crazy list, can we move it to their subprojects? + +set(OMR_GC_ALLOCATION_TAX ON CACHE BOOL "TODO: Document") +set(OMR_GC_ARRAYLETS ON CACHE BOOL "TODO: Document") +set(OMR_GC_BATCH_CLEAR_TLH ON CACHE BOOL "TODO: Document") +set(OMR_GC_COMBINATION_SPEC ON CACHE BOOL "TODO: Document") +set(OMR_GC_DEBUG_ASSERTS ON CACHE BOOL "TODO: Document") +set(OMR_GC_HEAP_CARD_TABLE ON CACHE BOOL "TODO: Document") +set(OMR_GC_LARGE_OBJECT_AREA ON CACHE BOOL "TODO: Document") +set(OMR_GC_MINIMUM_OBJECT_SIZE ON CACHE BOOL "TODO: Document") +set(OMR_GC_MODRON_STANDARD ON CACHE BOOL "TODO: Document") +set(OMR_GC_NON_ZERO_TLH ON CACHE BOOL "TODO: Document") +set(OMR_GC_THREAD_LOCAL_HEAP ON CACHE BOOL "TODO: Document") +set(OMR_GC_COMPRESSED_POINTERS OFF CACHE BOOL "TODO: Document") +set(OMR_GC_TLH_PREFETCH_FTA OFF CACHE BOOL "TODO: Document") +set(OMR_GC_OBJECT_MAP OFF CACHE BOOL "TODO: Document") +set(OMR_GC_DYNAMIC_CLASS_UNLOADING OFF CACHE BOOL "TODO: Document") +set(OMR_GC_MODRON_COMPACTION OFF CACHE BOOL "TODO: Document") +set(OMR_GC_MODRON_CONCURRENT_MARK OFF CACHE BOOL "TODO: Document") +set(OMR_GC_MODRON_SCAVENGER OFF CACHE BOOL "TODO: Document") +set(OMR_GC_CONCURRENT_SCAVENGER OFF CACHE BOOL "TODO: Document") +set(OMR_GC_CONCURRENT_SWEEP OFF CACHE BOOL "TODO: Document") +set(OMR_GC_HYBRID_ARRAYLETS OFF CACHE BOOL "TODO: Document") +set(OMR_GC_OBJECT_ALLOCATION_NOTIFY OFF CACHE BOOL "TODO: Document") +set(OMR_GC_REALTIME OFF CACHE BOOL "TODO: Document") +set(OMR_GC_SEGREGATED_HEAP OFF CACHE BOOL "TODO: Document") +set(OMR_GC_STACCATO OFF CACHE BOOL "TODO: Document") +set(OMR_GC_VLHGC OFF CACHE BOOL "TODO: Document") + +set(OMR_INTERP_HAS_SEMAPHORES ON CACHE BOOL "TODO: Document") +set(OMR_INTERP_COMPRESSED_OBJECT_HEADER OFF CACHE BOOL "TODO: Document") +set(OMR_INTERP_SMALL_MONITOR_SLOT OFF CACHE BOOL "TODO: Document") + +set(OMR_RAS_TDF_TRACE ON CACHE BOOL "TODO: Document") + +set(OMR_THR_ADAPTIVE_SPIN ON CACHE BOOL "TODO: Document") +set(OMR_THR_JLM_HOLD_TIMES ON CACHE BOOL "TODO: Document") +set(OMR_THR_LOCK_NURSERY ON CACHE BOOL "TODO: Document") +set(OMR_THR_FORK_SUPPORT OFF CACHE BOOL "TODO: Document") +set(OMR_THR_THREE_TIER_LOCKING OFF CACHE BOOL "TODO: Document") +set(OMR_THR_CUSTOM_SPIN_OPTIONS OFF CACHE BOOL "TODO: Document") +set(OMR_THR_SPIN_WAKE_CONTROL OFF CACHE BOOL "TODO: Document") +set(OMR_THR_YIELD_ALG OFF CACHE BOOL "TODO: Document") +#TODO set to disabled. Stuff fails to compile when its on +set(OMR_THR_TRACING OFF CACHE BOOL "TODO: Document") + +#TODO this should maybe be a OMRTHREAD_LIB string variable? +set(OMRTHREAD_WIN32_DEFAULT OFF) +set(OMRTHREAD_UNIX_DEFAULT OFF) +set(OMRTHREAD_AIX_DEFAULT OFF) +set(OMRTHREAD_ZOS_DEFAULT OFF) + +if(OMR_HOST_OS STREQUAL "win") + set(OMRTHREAD_WIN32_DEFAULT ON) +elseif(OMR_HOST_OS STREQUAL "aix") + set(OMRTHREAD_AIX_DEFAULT ON) +elseif(OMR_HOST_OS STREQUAL "zos") + set(OMRTHREAD_ZOS_DEFAULT ON) +else() + set(OMRTHREAD_UNIX_DEFAULT ON) +endif() + +set(OMRTHREAD_LIB_AIX ${OMRTHREAD_AIX_DEFAULT} CACHE BOOL "TODO: Document") +set(OMRTHREAD_LIB_ZOS ${OMRTHREAD_ZOS_DEFAULT} CACHE BOOL "TODO: Document") +set(OMRTHREAD_LIB_WIN32 ${OMRTHREAD_WIN32_DEFAULT} CACHE BOOL "TODO: Document") +set(OMRTHREAD_LIB_UNIX ${OMRTHREAD_UNIX_DEFAULT} CACHE BOOL "TODO: Document") + +set(OMR_PORT_CAN_RESERVE_SPECIFIC_ADDRESS ON CACHE BOOL "TODO: Document") +set(OMR_PORT_NUMA_SUPPORT OFF CACHE BOOL "TODO: Document") +set(OMR_PORT_ALLOCATE_TOP_DOWN OFF CACHE BOOL "TODO: Document") +set(OMR_PORT_ZOS_CEEHDLRSUPPORT OFF CACHE BOOL "TODO: Document") +set(OMR_PORT_ASYNC_HANDLER OFF CACHE BOOL "TODO: Document") + + +set(OMR_NOTIFY_POLICY_CONTROL OFF CACHE BOOL "TODO: Document") + +set(OMR_ENV_LITTLE_ENDIAN OFF CACHE BOOL "TODO: Document") +set(OMR_ENV_GCC OFF CACHE BOOL "TODO: Document") + + +set(OMR_OPT_CUDA OFF CACHE BOOL "TODO: Document") diff --git a/cmake/modules/CMakeASM-ZOSInformation.cmake b/cmake/modules/CMakeASM-ZOSInformation.cmake new file mode 100644 index 00000000000..f2d0d37c61d --- /dev/null +++ b/cmake/modules/CMakeASM-ZOSInformation.cmake @@ -0,0 +1,27 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +set(CMAKE_ASM-ZOS_SOURCE_FILE_EXTENSIONS s) + + +set(CMAKE_ASM-ZOS_COMPILE_OBJECT " -o ") + +# Load the generic ASMInformation file: +set(ASM_DIALECT "-ZOS") +include(CMakeASMInformation) +set(ASM_DIALECT) diff --git a/cmake/modules/CMakeDetermineASM-ZOSCompiler.cmake b/cmake/modules/CMakeDetermineASM-ZOSCompiler.cmake new file mode 100644 index 00000000000..583ce89c11e --- /dev/null +++ b/cmake/modules/CMakeDetermineASM-ZOSCompiler.cmake @@ -0,0 +1,22 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +set(ASM_DIALECT "-ZOS") +set(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST xlc) +include(CMakeDetermineASMCompiler) +set(ASM_DIALECT) diff --git a/cmake/modules/CMakeTestASM-ZOSCompiler.cmake b/cmake/modules/CMakeTestASM-ZOSCompiler.cmake new file mode 100644 index 00000000000..a3e44bebd93 --- /dev/null +++ b/cmake/modules/CMakeTestASM-ZOSCompiler.cmake @@ -0,0 +1,21 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +set(ASM_DIALECT "-ZOS") +include(CMakeTestASMCompiler) +set(ASM_DIALECT) diff --git a/cmake/platform.cmake b/cmake/platform.cmake new file mode 100644 index 00000000000..095cd85454d --- /dev/null +++ b/cmake/platform.cmake @@ -0,0 +1,271 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + + +### +### Platform flags +### TODO: arch flags. Defaulting to x86-64 + +message(STATUS "CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM}") +message(STATUS "CMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}") +message(STATUS "CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}") +message(STATUS "CMAKE_CROSSCOMPILING=${CMAKE_CROSSCOMPILING}") + +# TODO: Support all system types known in OMR +# TODO: Is there a better way to do system flags? + +if((CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")) + set(OMR_ARCH_X86 ON) + set(OMR_ENV_DATA64 ON) + set(OMR_TARGET_DATASIZE 64) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86") + set(OMR_ARCH_X86 ON) + set(OMR_ENV_DATA32 ON) + set(OMR_TARGET_DATASIZE 32) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm") + set(OMR_ARCH_ARM ON) + set(OMR_ENV_DATA32 ON) + set(OMR_TARGET_DATASIZE 32) +elseif(CMAKE_SYSTEM_NAME MATCHES "OS390") + set(OMR_ARCH_S390 ON) + set(OMR_ENV_DATA32 ON) + set(OMR_TARGET_DATASIZE 32) + set(OMR_HOST_OS "zos") +else() + message(FATAL_ERROR "Unknown processor: ${CMAKE_PROCESSOR}") +endif() + +#TODO: detect other Operating systems (aix, and zos) +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(OMR_HOST_OS "linux") +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(OMR_HOST_OS "osx") +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(OMR_HOST_OS "win") +elseif(OMR_HOST_OS STREQUAL "zos") + # we already set up OS stuff above +else() + message(FATAL_ERROR "Unsupported OS: ${CMAKE_SYSTEM_NAME}") +endif() + + +if(OMR_HOST_OS STREQUAL "linux") + add_definitions( + -DLINUX + -D_REENTRANT + -D_FILE_OFFSET_BITS=64 + ) +endif() + + +if(OMR_ARCH_X86) + set(OMR_ENV_LITTLE_ENDIAN ON CACHE BOOL "TODO: Document") + if(OMR_ENV_DATA64) + add_definitions(-DJ9HAMMER) + else() + add_definitions(-DJ9X86) + endif() +endif() + +if(OMR_ARCH_ARM) + set(OMR_ENV_LITTLE_ENDIAN ON CACHE BOOL "todo: Document") + add_definitions( + -DJ9ARM + -DARMGNU + -DFIXUP_UNALIGNED + ) +endif() + +if(OMR_HOST_OS STREQUAL "osx") + add_definitions( + -DOSX + -D_REENTRANT + -D_FILE_OFFSET_BITS=64 + ) +endif() + +# interface library for exporting symbols from dynamic library +# currently does nothing except on zos +add_library(omr_shared INTERFACE) + +if(OMR_HOST_OS STREQUAL "win") + #TODO: should probably check for MSVC + set(OMR_WINVER "0x501") + + add_definitions( + -DWIN32 + -D_CRT_SECURE_NO_WARNINGS + -DCRTAPI1=_cdecl + -DCRTAPI2=_cdecl + -D_WIN_95 + -D_WIN32_WINDOWS=0x0500 + -D_WIN32_DCOM + -D_MT + -D_WINSOCKAPI_ + -D_WIN32_WINVER=${OMR_WINVER} + -D_WIN32_WINNT=${OMR_WINVER} + -D_DLL + ) + if(OMR_ENV_DATA64) + add_definitions( + -DWIN64 + -D_AMD64_=1 + ) + set(TARGET_MACHINE AMD64) + else() + add_definitions( + -D_X86_ + ) + set(TARGET_MACHINE i386) + endif() + set(opt_flags "/GS-") + set(common_flags "-MD -Zm400") + + set(linker_common "-subsystem:console -machine:${TARGET_MACHINE}") + if(NOT OMR_ENV_DATA64) + set(linker_common "${linker_common} /SAFESEH") + endif() + + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${linker_common} /INCREMENTAL:NO /NOLOGO /LARGEADDRESSAWARE wsetargv.obj") + if(OMR_ENV_DATA64) + #TODO: makefile has this but it seems to break linker + #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRTD") + endif() + + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /INCREMENTAL:NO /NOLOGO") + if(OMR_ENV_DATA64) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -entry:_DllMainCRTStartup") + else() + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -entry:_DllMainCRTStartup@12") + endif() + + #strip out exception handling flags (added by default by cmake) + string(REPLACE "/EHsc" "" filtered_cxx_flags ${CMAKE_CXX_FLAGS}) + string(REPLACE "/GR" "" filtered_cxx_flags ${filtered_cxx_flags}) + set(CMAKE_CXX_FLAGS "${filtered_cxx_flags} ${common_flags}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${common_flags}") + + message(STATUS "CFLAGS = ${CMAKE_C_FLAGS}") + message(STATUS "CXXFLAGS = ${CMAKE_CXX_FLAGS}") + + #Hack up output dir to fix dll dependency issues on windows + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") +endif() + +if(OMR_HOST_OS STREQUAL "zos") + + enable_language(ASM-ZOS) + + include_directories(util/a2e/headers) + + add_definitions( + -DJ9ZOS390 + -DLONGLONG + -DJ9VM_TIERED_CODE_CACHE + -D_ALL_SOURCE + -D_XOPEN_SOURCE_EXTENDED + -DIBM_ATOE + -D_POSIX_SOURCE + ) + + #NOTE: character escaping on compiler args seems broken + + # Global Flags + # xplink Link with the xplink calling convention + # convlit Convert all string literals to a codepage + # rostring Place string literals in read only storage + # FLOAT Use IEEE (instead of IBM Hex Format) style floats + # enum Specifies how many bytes of storage enums occupy + # a,goff Assemble into GOFF object files + # NOANSIALIAS Do not generate ALIAS binder control statements + # TARGET Generate code for the target operating system + # list Generate assembly listing + # offset In assembly listing, show addresses as offsets of function entry points + #set(OMR_GLOBAL_FLAGS "-Wc,xplink,convlit\\\(ISO8859-1\\\),rostring,FLOAT\\\(IEEE,FOLD,AFP\\\),enum\\\(4\\\) -Wa,goff -Wc,NOANSIALIAS -Wc,TARGET\\\(zOSV1R13\\\) -W \"c,list,offset\"") + set(OMR_GLOBAL_FLAGS "-Wc,xplink,convlit\\\(ISO8859-1\\\),rostring,FLOAT\\\(IEEE,FOLD,AFP\\\),enum\\\(4\\\) -Wa,goff -Wc,NOANSIALIAS -Wc,TARGET\\\(zOSV1R13\\\)") + + if(OMR_ENV_DATA64) + add_definitions(-DJ9ZOS39064) + set(OMR_GLOBAL_FLAGS "${OMR_GLOBAL_FLAGS} -Wc,lp64 -Wa,SYSPARM\\\(BIT64\\\)") + else() + add_definitions(-D_LARGE_FILES) + endif() + + + set(CMAKE_ASM-ZOS_FLAGS "${OMR_GLOBAL_FLAGS}") + set(OMR_GLOBAL_FLAGS "${OMR_GLOBAL_FLAGS} -qnosearch -I${CMAKE_SOURCE_DIR}/util/a2e/headers -I/usr/include") + # Specify the minimum arch for 64-bit programs + #TODO this is a gross hack + + set(CMAKE_C_FLAGS "-Wc,ARCH\\\(7\\\) -Wc,\"langlvl(extc99)\" ${OMR_GLOBAL_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wc,ARCH\\\(7\\\) -Wc,\"langlvl(extended)\" ${OMR_GLOBAL_FLAGS} -I/usr/lpp/cbclib/include") + + + + target_compile_options(omr_shared INTERFACE "-Wc,DLL,EXPORTALL") + + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,xplink,dll") + + #TODO below is a chunk of the original makefile which still needs to be ported + # # This is the first option applied to the C++ linking command. + # # It is not applied to the C linking command. + # OMR_MK_CXXLINKFLAGS=-Wc,"langlvl(extended)" -+ + + # ifneq (,$(findstring shared,$(ARTIFACT_TYPE))) + # GLOBAL_LDFLAGS+=-Wl,xplink,dll + # else + # # Assume we're linking an executable + # GLOBAL_LDFLAGS+=-Wl,xplink + # endif + # ifeq (1,$(OMR_ENV_DATA64)) + # OMR_MK_CXXLINKFLAGS+=-Wc,lp64 + # GLOBAL_LDFLAGS+=-Wl,lp64 + # endif + + # # always link a2e last, unless we are creating the a2e library + # ifneq (j9a2e,$(MODULE_NAME)) + # GLOBAL_SHARED_LIBS+=j9a2e + # endif + + #dump DLLs and exes in same dir like on windows + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") + #apparently above doesnt work like it does on windows. Attempt to work arround + set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}") + set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}") + + + + message(STATUS "DEBUG: RUNTIME_OUTPUT_DIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + message(STATUS "DEBUG: CFLAGS=${CMAKE_C_FLAGS}") + message(STATUS "DEBUG: EXE LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}") + message(STATUS "DEBUG: so LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS}") + +endif() + +### +### Flags we aren't using +### + +# TODO: SPEC + +# TODO: OMR_HOST_ARCH +# TODO: OMR_TARGET_DATASIZE +# TODO: OMR_TOOLCHAIN +# TODO: OMR_CROSS_CONFIGURE +# TODO: OMR_RTTI + diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 00000000000..fff5240f35d --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,30 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_executable(example + main.cpp +) + +target_link_libraries(example + PRIVATE + omrgc +) + +add_test(example example) + +add_subdirectory(glue) diff --git a/example/glue/CMakeLists.txt b/example/glue/CMakeLists.txt new file mode 100644 index 00000000000..81d1aa17047 --- /dev/null +++ b/example/glue/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_library(omrglue STATIC + CollectorLanguageInterfaceImpl.cpp + CompactSchemeFixupObject.cpp + EnvironmentDelegate.cpp + FrequentObjectsStats.cpp + LanguageVMGlue.c + ObjectIterator.cpp + ObjectModelDelegate.cpp + omrExampleVM.cpp + Profiling.c + StartupManagerImpl.cpp + UtilGlue.c + VerboseManagerImpl.cpp + omrExampleVM.cpp +) + +target_include_directories(omrglue PUBLIC . ..) +target_link_libraries(omrglue PRIVATE omrgc) diff --git a/fvtest/CMakeLists.txt b/fvtest/CMakeLists.txt new file mode 100644 index 00000000000..0e9f234ee1e --- /dev/null +++ b/fvtest/CMakeLists.txt @@ -0,0 +1,32 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_subdirectory(util) + +add_subdirectory(omrGtestGlue) +add_subdirectory(algotest) +# add_subdirectory(compilertest) +add_subdirectory(gctest) +# add_subdirectory(jitbuildertest) +add_subdirectory(porttest) +# add_subdirectory(rastest) +add_subdirectory(sigtest) +# add_subdirectory(threadextendedtest) +add_subdirectory(threadtest) +add_subdirectory(utiltest) +# add_subdirectory(vmtest) diff --git a/fvtest/algotest/CMakeLists.txt b/fvtest/algotest/CMakeLists.txt new file mode 100644 index 00000000000..0d6737bb93f --- /dev/null +++ b/fvtest/algotest/CMakeLists.txt @@ -0,0 +1,75 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_hookgen(hooksample.hdf + ${CMAKE_CURRENT_SOURCE_DIR}/hooksample.h + ${CMAKE_CURRENT_SOURCE_DIR}/hooksample_internal.h +) + +add_executable(omralgotest + algoTest.cpp + algorithm_test_internal.h + avltest.c + avltest.lst + hashtabletest.c + hooksample.h + hooksample_internal.h + #hooksample.hdf + #hooksample.sentinel + #hooksample_internal.h + hooktest.c + main.cpp + pooltest.c +) + +target_link_libraries(omralgotest + j9avl + j9hashtable + j9pool + omrGtestGlue + #omrGtest + omrcore + omrport + omrtestutil +) + +#TODO hack to get building +if(OMR_HOST_OS STREQUAL "linux") + target_link_libraries(omralgotest + rt + ) +elseif(OMR_HOST_OS STREQUAL "win") + target_link_libraries(omralgotest + ws2_32 + shell32 + Iphlpapi + psapi + pdh + omrglue + ) +endif() + +target_link_libraries(omralgotest + j9hookstatic +) + +if(OMR_HOST_OS STREQUAL "zos") + target_link_libraries(omralgotest j9a2e) +endif() + +add_test(NAME algotest COMMAND omralgotest -avltest:${CMAKE_CURRENT_SOURCE_DIR}/avltest.lst) diff --git a/fvtest/gctest/CMakeLists.txt b/fvtest/gctest/CMakeLists.txt new file mode 100644 index 00000000000..bf47b0cecb1 --- /dev/null +++ b/fvtest/gctest/CMakeLists.txt @@ -0,0 +1,66 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_executable(omrgctest + GCConfigObjectTable.cpp + GCConfigTest.cpp + gcTestHelpers.cpp + main.cpp + StartupManagerTestExample.cpp +) + +#TODO this is a real gross, tangled mess +target_link_libraries(omrgctest + omrGtestGlue + pugixml + omrtestutil + omrcore + omrglue + omrgc + omrglue + omrcore + omrtrace + j9hookstatic + omrport + j9thrstatic + j9hashtable + omrutil + omrglue +) + +# TODO check linker flags from makefile are ported properly. +# Relevant section from makefile below +#ifeq (linux,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += rt pthread +#endif +#ifeq (osx,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += iconv pthread +#endif +#ifeq (aix,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += iconv perfstat +#endif +#ifeq (win,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += ws2_32 shell32 Iphlpapi psapi pdh +#endif + +if(OMR_HOST_OS STREQUAL "zos") + target_link_libraries(omrgctest j9a2e) +endif() + +#TODO Currently disabled as gctest has dependecies on certain build options that need to be figured out +#add_test(NAME gctest COMMAND omrgctest "-configListFile=${CMAKE_SOURCE_DIR}/fvtest/gctest/configuration/fvConfigListFile.txt") diff --git a/fvtest/omrGtestGlue/CMakeLists.txt b/fvtest/omrGtestGlue/CMakeLists.txt new file mode 100644 index 00000000000..b08412db16d --- /dev/null +++ b/fvtest/omrGtestGlue/CMakeLists.txt @@ -0,0 +1,48 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + + +add_library(omrGtest STATIC + omrGtest.cpp) +target_include_directories(omrGtest + PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/gtest-1.7.0/ + ${PROJECT_SOURCE_DIR}/third_party/gtest-1.7.0/src + PUBLIC + ${PROJECT_SOURCE_DIR}/third_party/gtest-1.7.0/include +) +add_library(omrGtestGlue INTERFACE) + +target_include_directories(omrGtestGlue + INTERFACE + . +) + +target_sources(omrGtestGlue INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/argmain.cpp +) + +target_link_libraries(omrGtestGlue INTERFACE omrGtest) + +#TODO system thread library should be linked in a more generic way. +if(NOT OMR_HOST_OS STREQUAL "win") + if(NOT OMR_HOST_OS STREQUAL "zos") + target_link_libraries(omrGtest pthread) + endif() +endif() +#target_link_libraries(omrGtest INTERFACE omrGtestGlue) diff --git a/fvtest/porttest/CMakeLists.txt b/fvtest/porttest/CMakeLists.txt new file mode 100644 index 00000000000..f85568b147a --- /dev/null +++ b/fvtest/porttest/CMakeLists.txt @@ -0,0 +1,107 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) + +set(cudaSources "") + +if(OMR_OPT_CUDA) + set(cudaSources + cudaBasic.cpp + cudaError.cpp + cudaEvent.cpp + cudaInvalid.cpp + cudaLaunch.cpp + cudaLink.cpp + cudaMemory.cpp + cudaModule.cpp + cudaPeer.cpp + cudaPropery.cpp + cudaPtx.cpp + cudaStram.cpp + cudaTests.cpp + ) +endif() + + +add_executable(omrporttest + fileTest.cpp + heapTest.cpp + j9portTest.cpp + main.cpp + memTest.cpp + omrdumpTest.cpp + omrerrorTest.cpp + omrfileTest.cpp + omrfilestreamTest.cpp + omrheapTest.cpp + omrintrospectTest.cpp + omrmemTest.cpp + omrmmapTest.cpp + omrsignalExtendedTest.cpp + omrsignalTest.cpp + omrslTest.cpp + omrstrTest.cpp + omrtimeTest.cpp + omrttyExtendedTest.cpp + omrttyTest.cpp + omrvmemTest.cpp + si.cpp + si_numcpusTest.cpp + testHelpers.cpp + testProcessHelpers.cpp + vmemTest.cpp + + ${cudaSources} +) + + + +target_link_libraries(omrporttest + omrGtestGlue + omrcore + omrport + omrtestutil +) +if(OMR_HOST_OS STREQUAL "win") + target_link_libraries(omrporttest + ws2_32 + omrglue + ) +endif() + +if(OMR_HOST_OS STREQUAL "zos") + target_link_libraries(omrporttest j9a2e) +endif() + + +add_library(sltestlib SHARED + sltestlib/sltest.c) +target_link_libraries(sltestlib PRIVATE omr_shared) + +#Shared lib test broken on windows +if(OMR_HOST_OS STREQUAL "win") + add_test(NAME porttest COMMAND omrporttest --gtest-filter="-PortSlTest.*") +else() + add_test(NAME porttest COMMAND omrporttest) +endif() + +if(OMR_OPT_CUDA) + add_test(NAME cuda_porttest COMMAND omrporttest --gtest_filter="Cuda*" -earlyExit) +endif() + diff --git a/fvtest/sigtest/CMakeLists.txt b/fvtest/sigtest/CMakeLists.txt new file mode 100644 index 00000000000..ec84fc6989e --- /dev/null +++ b/fvtest/sigtest/CMakeLists.txt @@ -0,0 +1,77 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_executable(omrsigtest + sigTest.cpp + sigTestHelpers.cpp + main.cpp +) + +#TODO: hack for windows. These libraries should be linked on dependants +if(OMR_HOST_OS STREQUAL "win") + target_link_libraries(omrsigtest + ws2_32 + shell32 + Iphlpapi + psapi + pdh + ) +endif() + +if(OMR_HOST_OS STREQUAL "zos") + target_link_libraries(omrsigtest j9a2e) +endif() + +#TODO pretty sure omrtestutil only used for headers +target_link_libraries(omrsigtest + omrGtestGlue + omrtestutil + j9thrstatic + omrport + omrglue + omrsig +) + +#TODO Unported makefile section: +#MODULE_INCLUDES += ../util +#MODULE_INCLUDES += $(OMR_GTEST_INCLUDES) +#MODULE_CXXFLAGS += $(OMR_GTEST_CXXFLAGS) + +#vpath argmain.cpp $(top_srcdir)/fvtest/omrGtestGlue + +#MODULE_STATIC_LIBS += \ + #omrGtest \ + #testutil \ + #omrstatic + +#MODULE_SHARED_LIBS += omrsig + +#ifeq (linux,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += rt pthread +#endif +#ifeq (osx,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += iconv pthread +#endif +#ifeq (aix,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += iconv perfstat +#endif +#ifeq (win,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += ws2_32 shell32 Iphlpapi psapi pdh +#endif + +add_test(NAME sigtest COMMAND omrsigtest) diff --git a/fvtest/threadtest/CMakeLists.txt b/fvtest/threadtest/CMakeLists.txt new file mode 100644 index 00000000000..bccc23f0c24 --- /dev/null +++ b/fvtest/threadtest/CMakeLists.txt @@ -0,0 +1,104 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_executable(omrthreadtest + abortTest.cpp + CEnterExit.cpp + CMonitor.cpp + createTest.cpp + CThread.cpp + joinTest.cpp + keyDestructorTest.cpp + lockedMonitorCountTest.cpp + main.cpp + ospriority.cpp + priorityInterruptTest.cpp + rwMutexTest.cpp + sanityTest.cpp + sanityTestHelper.cpp + threadTestHelp.cpp +) + +#TODO Unported makefile fragment: +#ifeq (1,$(OMR_THR_FORK_SUPPORT)) + #OBJECTS += forkResetTest forkResetRWMutexTest +#endif + +#OBJECTS := $(addsuffix $(OBJEXT),$(OBJECTS)) + +#MODULE_INCLUDES += $(top_srcdir)/fvtest/util +#MODULE_INCLUDES += $(OMR_GTEST_INCLUDES) $(top_srcdir)/thread +#MODULE_CXXFLAGS += $(OMR_GTEST_CXXFLAGS) + +#vpath argmain.cpp $(top_srcdir)/fvtest/omrGtestGlue + +#MODULE_STATIC_LIBS += \ + #omrGtest \ + #testutil \ + #omrstatic + +#ifeq (linux,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += rt pthread +#endif +#ifeq (osx,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += iconv pthread +#endif +#ifeq (aix,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += iconv perfstat +#endif +#ifeq (win,$(OMR_HOST_OS)) + #MODULE_SHARED_LIBS += ws2_32 shell32 Iphlpapi psapi pdh +#endif + +#include $(top_srcdir)/omrmakefiles/rules.mk + +target_link_libraries(omrthreadtest + omrglue + omrtestutil + omrGtestGlue + j9thrstatic + omrutil + omrport + j9hashtable + j9avl + j9pool +) +if(OMR_HOST_OS STREQUAL "linux") + target_link_libraries(omrthreadtest + rt) +elseif(OMR_HOST_OS STREQUAL "win") + target_link_libraries(omrthreadtest + ws2_32 + shell32 + Iphlpapi + psapi + pdh + ) +endif() + +if(OMR_HOST_OS STREQUAL "zos") + target_link_libraries(omrthreadtest j9a2e) +endif() + +add_test(NAME threadtest COMMAND omrthreadtest) +#TODO need to add other execution targets +# ./omrthreadtest --gtest_also_run_disabled_tests --gtest_filter=ThreadCreateTest.DISABLED_SetAttrThreadWeight +#ifneq (,$(findstring linux,$(SPEC))) +# ./omrthreadtest --gtest_filter=ThreadCreateTest.*:$(GTEST_FILTER) -realtime +#endif + diff --git a/fvtest/util/CMakeLists.txt b/fvtest/util/CMakeLists.txt new file mode 100644 index 00000000000..dcc4ed50ab4 --- /dev/null +++ b/fvtest/util/CMakeLists.txt @@ -0,0 +1,24 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + + +add_library(omrtestutil STATIC + printerrorhelper.cpp + testvmhelper.cpp +) +target_include_directories(omrtestutil PUBLIC .) diff --git a/fvtest/utiltest/CMakeLists.txt b/fvtest/utiltest/CMakeLists.txt new file mode 100644 index 00000000000..d1d38b8e580 --- /dev/null +++ b/fvtest/utiltest/CMakeLists.txt @@ -0,0 +1,39 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_executable(omrutiltest + main.cpp +) + +target_link_libraries(omrutiltest + #omrGtestGlue + omrGtest + omrutil + omrglue +) + +target_include_directories(omrutiltest + PRIVATE + $ +) + +if(OMR_HOST_OS STREQUAL "zos") + target_link_libraries(omrutiltest j9a2e) +endif() + +add_test(NAME utiltest COMMAND omrutiltest) diff --git a/gc/CMakeLists.txt b/gc/CMakeLists.txt new file mode 100644 index 00000000000..9d6ec3ca064 --- /dev/null +++ b/gc/CMakeLists.txt @@ -0,0 +1,279 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +project(libomrgc VERSION 0.0.1 LANGUAGES CXX) + + +add_hookgen(include/omrmm.hdf + ${CMAKE_CURRENT_SOURCE_DIR}/../include_core/mmomrhook.h + ${CMAKE_CURRENT_SOURCE_DIR}/base/mmomrhook_internal.h +) +add_hookgen(base/omrmmprivate.hdf + ${CMAKE_CURRENT_SOURCE_DIR}/base/mmprivatehook.h + ${CMAKE_CURRENT_SOURCE_DIR}/base/mmprivatehook_internal.h +) + +add_tracegen(base/j9mm.tdf) +add_tracegen(base/omrmm.tdf) +add_tracegen(verbose/j9vgc.tdf) + +add_library(omrgc + base/AddressOrderedListPopulator.cpp + base/AllocationContext.cpp + base/AllocationInterfaceGeneric.cpp + base/BaseVirtual.cpp + base/BumpAllocatedListPopulator.cpp + base/CardTable.cpp + base/Collector.cpp + base/CollectorLanguageInterface.cpp + base/Configuration.cpp + base/CopyScanCache.cpp + base/CycleState.cpp + base/Dispatcher.cpp + base/EmptyListPopulator.cpp + base/EnvironmentBase.cpp + base/Forge.cpp + base/GCCode.cpp + base/GCExtensionsBase.cpp + base/GlobalAllocationManager.cpp + base/GlobalCollector.cpp + base/Heap.cpp + base/HeapMap.cpp + base/HeapMapIterator.cpp + base/HeapMemorySubSpaceIterator.cpp + base/HeapRegionDescriptor.cpp + base/HeapRegionIterator.cpp + base/HeapRegionManager.cpp + base/HeapRegionManagerTarok.cpp + base/HeapSplit.cpp + base/HeapVirtualMemory.cpp + base/LightweightNonReentrantLock.cpp + base/LightweightNonReentrantReaderWriterLock.cpp + base/MarkMap.cpp + base/MarkedObjectPopulator.cpp + base/MarkingScheme.cpp + base/MasterGCThread.cpp + base/Math.cpp + base/MemoryManager.cpp + base/MemoryPool.cpp + base/MemoryPoolAddressOrderedList.cpp + base/MemoryPoolAddressOrderedListBase.cpp + base/MemoryPoolBumpPointer.cpp + base/MemoryPoolHybrid.cpp + base/MemoryPoolLargeObjects.cpp + base/MemoryPoolSplitAddressOrderedList.cpp + base/MemoryPoolSplitAddressOrderedListBase.cpp + base/MemorySpace.cpp + base/MemorySubSpace.cpp + base/MemorySubSpaceChildIterator.cpp + base/MemorySubSpaceFlat.cpp + base/MemorySubSpaceGenerational.cpp + base/MemorySubSpaceGeneric.cpp + base/MemorySubSpacePoolIterator.cpp + base/MemorySubSpaceRegionIterator.cpp + base/MemorySubSpaceSemiSpace.cpp + base/MemorySubSpaceUniSpace.cpp + base/ModronAssertions.cpp + base/NUMAManager.cpp + base/NonVirtualMemory.cpp + base/OMRVMInterface.cpp + base/OMRVMThreadInterface.cpp + base/ObjectAllocationInterface.cpp + base/ObjectHeapBufferedIterator.cpp + base/ObjectHeapIteratorAddressOrderedList.cpp + base/ObjectMap.cpp + base/Packet.cpp + base/PacketList.cpp + base/ParallelDispatcher.cpp + base/ParallelMarkTask.cpp + base/ParallelSweepChunk.cpp + base/ParallelTask.cpp + base/PhysicalArena.cpp + base/PhysicalArenaRegionBased.cpp + base/PhysicalArenaVirtualMemory.cpp + base/PhysicalSubArena.cpp + base/PhysicalSubArenaRegionBased.cpp + base/PhysicalSubArenaVirtualMemory.cpp + base/PhysicalSubArenaVirtualMemoryFlat.cpp + base/ReferenceChainWalkerMarkMap.cpp + base/RegionPool.cpp + base/RegionPoolGeneric.cpp + base/StartupManager.cpp + base/SweepHeapSectioning.cpp + base/SweepPoolManager.cpp + base/SweepPoolManagerAddressOrderedList.cpp + base/SweepPoolManagerAddressOrderedListBase.cpp + base/SweepPoolManagerHybrid.cpp + base/SweepPoolManagerSplitAddressOrderedList.cpp + base/SweepPoolState.cpp + base/TLHAllocationInterface.cpp + base/TLHAllocationSupport.cpp + base/Task.cpp + base/Validator.cpp + base/VirtualMemory.cpp + base/WorkPacketOverflow.cpp + base/WorkPackets.cpp + base/WorkStack.cpp + base/ZOSLinkage.cpp + base/gcspinlock.cpp + base/gcutils.cpp + base/modronapicore.cpp + base/segregated/AllocationContextSegregated.cpp + base/segregated/ConfigurationSegregated.cpp + base/segregated/GlobalAllocationManagerSegregated.cpp + base/segregated/HeapRegionDescriptorSegregated.cpp + base/segregated/LockingFreeHeapRegionList.cpp + base/segregated/LockingHeapRegionQueue.cpp + base/segregated/MemoryPoolAggregatedCellList.cpp + base/segregated/MemoryPoolSegregated.cpp + base/segregated/MemorySubSpaceSegregated.cpp + base/segregated/ObjectHeapIteratorSegregated.cpp + base/segregated/OverflowSegregated.cpp + base/segregated/RegionPoolSegregated.cpp + base/segregated/SegregatedAllocationInterface.cpp + base/segregated/SegregatedAllocationTracker.cpp + base/segregated/SegregatedGC.cpp + base/segregated/SegregatedListPopulator.cpp + base/segregated/SegregatedMarkingScheme.cpp + base/segregated/SegregatedSweepTask.cpp + base/segregated/SizeClasses.cpp + base/segregated/SweepSchemeSegregated.cpp + base/segregated/WorkPacketsSegregated.cpp + base/standard/CompactFixHeapForWalkTask.cpp + base/standard/CompactScheme.cpp + base/standard/ConcurrentCardTable.cpp + base/standard/ConcurrentCardTableForWC.cpp + base/standard/ConcurrentClearNewMarkBitsTask.cpp + base/standard/ConcurrentCompleteTracingTask.cpp + base/standard/ConcurrentFinalCleanCardsTask.cpp + base/standard/ConcurrentGC.cpp + base/standard/ConcurrentOverflow.cpp + base/standard/ConcurrentPrepareCardTableTask.cpp + base/standard/ConcurrentSafepointCallback.cpp + base/standard/ConcurrentScanRememberedSetTask.cpp + base/standard/ConcurrentScavengeTask.cpp + base/standard/ConcurrentSweepScheme.cpp + base/standard/ConfigurationFlat.cpp + base/standard/ConfigurationGenerational.cpp + base/standard/ConfigurationStandard.cpp + base/standard/CopyScanCacheChunk.cpp + base/standard/CopyScanCacheChunkInHeap.cpp + base/standard/CopyScanCacheList.cpp + base/standard/CopyScanCacheStandard.cpp + base/standard/EnvironmentStandard.cpp + base/standard/HeapMemoryPoolIterator.cpp + base/standard/HeapRegionDescriptorStandard.cpp + base/standard/HeapRegionManagerStandard.cpp + base/standard/HeapWalker.cpp + base/standard/OverflowStandard.cpp + base/standard/ParallelCompactTask.cpp + base/standard/ParallelGlobalGC.cpp + base/standard/ParallelScavengeTask.cpp + base/standard/ParallelSweepScheme.cpp + base/standard/PhysicalSubArenaVirtualMemorySemiSpace.cpp + base/standard/RSOverflow.cpp + base/standard/Scavenger.cpp + base/standard/SweepHeapSectioningSegmented.cpp + base/standard/WorkPacketsConcurrent.cpp + base/standard/WorkPacketsStandard.cpp + + startup/mminitcore.cpp + startup/omrgcalloc.cpp + startup/omrgcstartup.cpp + + stats/AllocationFailureStats.cpp + stats/AllocationStats.cpp + stats/CardCleaningStats.cpp + stats/ClassUnloadStats.cpp + stats/CompactStats.cpp + stats/ConcurrentCardTableStats.cpp + stats/ConcurrentGCStats.cpp + stats/ConcurrentSweepStats.cpp + stats/CopyForwardStatsCore.cpp + stats/HeapMemorySnapshot.cpp + stats/HeapResizeStats.cpp + stats/HeapStats.cpp + stats/LargeObjectAllocateStats.cpp + stats/MarkStats.cpp + stats/MetronomeStats.cpp + stats/PercolateStats.cpp + stats/RootScannerStats.cpp + stats/ScavengerCopyScanRatio.cpp + stats/ScavengerHotFieldStats.cpp + stats/ScavengerStats.cpp + stats/SweepStats.cpp + + structs/ForwardedHeader.cpp + structs/HashTableIterator.cpp + structs/OMRVMThreadListIterator.cpp + structs/ObjectHeapIterator.cpp + structs/ObjectIteratorState.cpp + structs/PoolIterator.cpp + structs/SublistFragment.cpp + structs/SublistIterator.cpp + structs/SublistPool.cpp + structs/SublistPuddle.cpp + structs/SublistSlotIterator.cpp + + # verbose/j9vgc.tdf + verbose/VerboseBuffer.cpp + verbose/VerboseHandlerOutput.cpp + verbose/VerboseManager.cpp + verbose/VerboseWriter.cpp + verbose/VerboseWriterChain.cpp + verbose/VerboseWriterFileLogging.cpp + verbose/VerboseWriterFileLoggingBuffered.cpp + verbose/VerboseWriterFileLoggingSynchronous.cpp + verbose/VerboseWriterHook.cpp + verbose/VerboseWriterStreamOutput.cpp + verbose/handler_standard/VerboseHandlerOutputStandard.cpp + + # Hookgen generated files + ${CMAKE_CURRENT_SOURCE_DIR}/base/mmprivatehook.h + ${CMAKE_CURRENT_SOURCE_DIR}/base/mmprivatehook_internal.h + ${CMAKE_CURRENT_SOURCE_DIR}/../include_core/mmomrhook.h + ${CMAKE_CURRENT_SOURCE_DIR}/base/mmomrhook_internal.h + + # Tracegen generated files + ${CMAKE_CURRENT_BINARY_DIR}/ut_j9mm.c + ${CMAKE_CURRENT_BINARY_DIR}/ut_omrmm.c + ${CMAKE_CURRENT_BINARY_DIR}/ut_j9vgc.c +) + +target_include_directories(omrgc + PUBLIC + . + ${CMAKE_CURRENT_BINARY_DIR} #Ideally this should be private, but the glue pulls this in + base + base/segregated + base/standard + include + startup + stats + structs + verbose + verbose/handler_standard + $ + PRIVATE +) + +target_link_libraries(omrgc + PUBLIC + # TODO: omrcore + #omrglue +) diff --git a/glue/CMakeLists.txt b/glue/CMakeLists.txt new file mode 100644 index 00000000000..7c8bd69243f --- /dev/null +++ b/glue/CMakeLists.txt @@ -0,0 +1,48 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_library(omrglue + ArrayletObjectModel.hpp + CollectorLanguageInterfaceImpl.cpp + CollectorLanguageInterfaceImpl.hpp + CompactSchemeFixupObject.cpp + CompactSchemeFixupObject.hpp + ConfigurationLanguageInterfaceImpl.cpp + ConfigurationLanguageInterfaceImpl.hpp + ContractslotScanner.hpp + EnvironmentLanguageInterfaceImpl.cpp + EnvironmentLanguageInterfaceImpl.hpp + FrequentObjectsStats.cpp + FrequentObjectsStats.hpp + HeapRegionDescriptorTypes.hpp + LanguageSegregatedAllocationCache.hpp + LanguageThreadLocalHeap.hpp + MixedObjectModel.hpp + ObjectIterator.cpp + ObjectIterator.hpp + ObjectModel.cpp + ObjectModel.hpp + ObjectScannerState.hpp + StartupManagerImpl.cpp + StartupManagerImpl.hpp + VerboseManagerImpl.cpp + VerboseManagerImpl.hpp +) + +target_include_directories(omrglue PUBLIC .) +target_link_libraries(omrglue PUBLIC omrgc) diff --git a/omr/CMakeLists.txt b/omr/CMakeLists.txt new file mode 100644 index 00000000000..c9b7e2a9491 --- /dev/null +++ b/omr/CMakeLists.txt @@ -0,0 +1,50 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_tracegen(omrti.tdf) +add_tracegen(omrvm.tdf) + +add_library(omrcore + OMR_Agent.cpp + OMR_MethodDictionary.cpp + OMR_MethodDictionary.hpp + OMR_Profiler.cpp + OMR_Runtime.cpp + OMR_TI.cpp + OMR_TIMemorySize.cpp + OMR_VM.cpp + OMR_VMThread.cpp + omrrasinit.c + omrti.tdf + omrtrcinit.c + startup/omrvmstartup.cpp + ut_omrti.c + ut_omrti.h + ut_omrvm.c + ut_omrvm.h +) + +target_include_directories(omrcore + PUBLIC + . +) + +target_link_libraries(omrcore + PUBLIC + omrgc # mminitcore.h +) diff --git a/omrcfg.CMakeTemplate.h b/omrcfg.CMakeTemplate.h new file mode 100644 index 00000000000..83c2a01eca8 --- /dev/null +++ b/omrcfg.CMakeTemplate.h @@ -0,0 +1,225 @@ +/******************************************************************************* + * + * (c) Copyright IBM Corp. 2017 + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 and + * Apache License v2.0 which accompanies this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * The Apache License v2.0 is available at + * http://www.opensource.org/licenses/apache2.0.php + * + * Contributors: + * Multiple authors (IBM Corp.) - initial implementation and documentation + *******************************************************************************/ + +/** + * The OMR build configuration. A public header. Controls the APIs of all other headers. + * Include at the top of every OMR source and header. + */ + +#if !defined(OMRCFG_H_) +#define OMRCFG_H_ + +#cmakedefine OMR_GC +#cmakedefine OMR_JIT +#cmakedefine OMR_JITBUILDER +#cmakedefine OMR_TEST_COMPILER +#cmakedefine OMR_PORT +#cmakedefine OMR_THREAD +#cmakedefine OMR_OMRSIG +#cmakedefine OMR_EXAMPLE + +#cmakedefine OMR_GC_ALLOCATION_TAX +#cmakedefine OMR_GC_OBJECT_ALLOCATION_NOTIFY +#cmakedefine OMR_GC_BATCH_CLEAR_TLH +#cmakedefine OMR_GC_COMBINATION_SPEC +#cmakedefine OMR_GC_CONCURRENT_SWEEP +#cmakedefine OMR_GC_DEBUG_ASSERTS +#cmakedefine OMR_GC_HEAP_CARD_TABLE +#cmakedefine OMR_GC_LARGE_OBJECT_AREA +#cmakedefine OMR_GC_MINIMUM_OBJECT_SIZE +#cmakedefine OMR_GC_MODRON_COMPACTION +#cmakedefine OMR_GC_MODRON_CONCURRENT_MARK +#cmakedefine OMR_GC_MODRON_SCAVENGER +#cmakedefine OMR_GC_CONCURRENT_SCAVENGER +#cmakedefine OMR_GC_MODRON_STANDARD +#cmakedefine OMR_GC_NON_ZERO_TLH +#cmakedefine OMR_GC_SEGREGATED_HEAP +#cmakedefine OMR_GC_THREAD_LOCAL_HEAP + +/** + * Tells if a platform has support for Semaphores. + * ifRemoved: platform cannot use semaphore operations. + */ +#cmakedefine OMR_INTERP_HAS_SEMAPHORES + +/** + * Use TDF based trace engine + * ifRemoved: No tracepoints + */ +#cmakedefine OMR_RAS_TDF_TRACE + +/** + * Support options to adapt spinning as controlled by options provided to the vm. + * Requires flag: OMR_THR_JLM_HOLD_TIMES + * ifRemoved: No adaptive spinning supported + */ +#cmakedefine OMR_THR_ADAPTIVE_SPIN + +/** + * Enable support for lock monitor to profile locking behaviour - counts only + * ifRemoved: Lock monitor cannot be enabled + */ +#cmakedefine OMR_THR_JLM + +/** + * Enable support for lock monitor to profile locking behaviour - counts + timings only + * ifRemoved: Lock monitor cannot be enabled + */ +#cmakedefine OMR_THR_JLM_HOLD_TIMES + +/** + * object header does not contain the monitor word + * ifRemoved: object header will contain the monitor word + */ +#cmakedefine OMR_THR_LOCK_NURSERY + +/** + * Output lots of thread statistics (Pentium only) + * ifRemoved: Turn off in production VMs + */ +#cmakedefine OMR_THR_TRACING 1 + +#cmakedefine OMRTHREAD_LIB_AIX 1 +#cmakedefine OMRTHREAD_LIB_UNIX 1 +#cmakedefine OMRTHREAD_LIB_WIN32 1 +#cmakedefine OMRTHREAD_LIB_ZOS 1 + +/** + * This spec targets PPC processors. + */ +#cmakedefine OMR_ARCH_POWER + +/** + * This spec targets ARM processors. + */ +#cmakedefine OMR_ARCH_ARM + +/** + * This spec targets x86 processors. + */ +#cmakedefine OMR_ARCH_X86 + +/** + * This spec targets S390 processors. + */ +#cmakedefine OMR_ARCH_S390 + +#cmakedefine OMR_ENV_DATA64 +#cmakedefine OMR_ENV_GCC +#cmakedefine OMR_ENV_LITTLE_ENDIAN +#cmakedefine OMR_GC_ARRAYLETS +#cmakedefine OMR_GC_COMPRESSED_POINTERS +#cmakedefine OMR_GC_HYBRID_ARRAYLETS +#cmakedefine OMR_GC_OBJECT_MAP +#cmakedefine OMR_GC_REALTIME +#cmakedefine OMR_GC_STACCATO +#cmakedefine OMR_GC_TLH_PREFETCH_FTA +#cmakedefine OMR_GC_VLHGC + +/** + * Flag to indicate that on 64-bit platforms, the monitor slot and class slot in object headers are U32 rather than UDATA. + */ +#cmakedefine OMR_INTERP_COMPRESSED_OBJECT_HEADER + +/** + * Flag to indicate that on 64-bit platforms, the monitor slot in object headers is a U32 rather than a UDATA. + * ifRemoved: The monitor slot is a UDATA. + */ +#cmakedefine OMR_INTERP_SMALL_MONITOR_SLOT + +/** + * Add support for CUDA + */ +#cmakedefine OMR_OPT_CUDA + +/** + * Enabling this flag implies the platform's vmem implementation is able to allocate memory top down. + * ifRemoved: Implies the platform's vmem implementation is not able to allocate memory top down + */ +#cmakedefine OMR_PORT_ALLOCATE_TOP_DOWN + +/** + * Enables async signal handler thread in the port library. + * ifRemoved: Async signal handler thread is disabled. + */ +#cmakedefine OMR_PORT_ASYNC_HANDLER + +/** + * The platform is able to attempt to reserve virtual memory via a call to omrvmem_reserve_memory at the address specified by the user. + * ifRemoved: The platform is not able to reserve virtual memory at a specific address + */ +#cmakedefine OMR_PORT_CAN_RESERVE_SPECIFIC_ADDRESS + +/** + * This platform is able to associate memory with a specific node, as is relevant when the system has a Non Uniform Memory Access configuration. + * ifRemoved: This platform is not able to associate memory with a specific node. + */ +#cmakedefine OMR_PORT_NUMA_SUPPORT + +/** + * If set, omrsig_protect will include support for registering a handler using CEEHDLR. + * Pass OMRPORT_SIG_OPTIONS_ZOS_USE_CEEHDLR into omrsig_set_options() before the first call + * to omrsig_protect() to turn on the use of CEEHDLR at runtime. + * ifRemoved: omrsig_protect will not include support for CEEHDLR. + */ +#cmakedefine OMR_PORT_ZOS_CEEHDLRSUPPORT + +/** + * Enable the j9thread library to be used after a fork(). + * ifRemoved: The j9thread library may be corrupt and unusable after a fork(). + */ +#cmakedefine OMR_THR_FORK_SUPPORT + +/** + * Attempt to enter raw monitors using user-space spinlocks before reverting to an OS synchronization object + * ifRemoved: All raw monitor enters will proceed directly to an OS synchronization object + */ +#cmakedefine OMR_THR_THREE_TIER_LOCKING + +/** + * Enable support for custom spin options. + * Requires flag: OMR_THR_THREE_TIER_LOCKING. + * ifRemoved: Custom spin options cannot be used. + */ +#cmakedefine OMR_THR_CUSTOM_SPIN_OPTIONS + +/** + * Allows a user to select the thread notify policy: signal or broadcast. + * ifRemoved: User will not be able to select the thread notify policy, and broadcast policy will always be used. + */ +#cmakedefine OMR_NOTIFY_POLICY_CONTROL + +/** + * This flag enables new synchronization prototypes which + * -- prevent large number of threads to spin at a time on a monitor + * -- avoid the thundering herd problem on wake up + * + * The prototypes provide the following features + * -- track number of threads spinning on a monitor + * -- wake threads only when no thread is spinning on a monitor + * -- limit/control number of threads that are woken up per monitor + * -- limit/control number of threads that are allowed to spin per monitor + */ +#cmakedefine OMR_THR_SPIN_WAKE_CONTROL + +/** + * This enables the option to select different algorithms for yielding. + */ +#cmakedefine OMR_THR_YIELD_ALG + +#endif /* !defined(OMRCFG_H_) */ diff --git a/omrsigcompat/CMakeLists.txt b/omrsigcompat/CMakeLists.txt new file mode 100644 index 00000000000..8d7e8722f02 --- /dev/null +++ b/omrsigcompat/CMakeLists.txt @@ -0,0 +1,95 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_library(omrsig SHARED + omrsig.cpp +) + +#TODO need more comprehensive symbols +set(exportedSyms + omrsig_primary_signal + omrsig_handler + signal +) + +#for now only export symbols on windows +if(OMR_HOST_OS STREQUAL "win") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/omrsig.exportlist" "EXPORTS\n" ) + foreach(exportSymbol ${exportedSyms}) + file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/omrsig.exportlist" "${exportSymbol}\n" ) + endforeach() + set_target_properties(omrsig + PROPERTIES LINK_FLAGS "-def:${CMAKE_CURRENT_BINARY_DIR}/omrsig.exportlist") + set(CRT_DLL "MSVC100.dll") + #TODO: below assumes we are using debug builds + if(MSVC12) + set(CRT_DLL "MSVC120d.dll") + elseif(MSVC14) + set(CRT_DLL "MSVC140d.dll") + endif() + target_compile_definitions(omrsig PRIVATE -DMSVC_RUNTIME_DLL="${CRT_DLL}") +endif() + +#Symbols exported from source makefile: +#EXPORT_FUNCTIONS_FILE := omrsig.exportlist +#$(EXPORT_FUNCTIONS_FILE): + #@# all + #@echo omrsig_primary_signal >>$@ + #@echo omrsig_handler >>$@ + #@echo signal >>$@ +#ifeq (,$(findstring win,$(OMR_HOST_OS))) + #@# !windows + #@echo omrsig_primary_sigaction >>$@ + #@echo sigaction >>$@ + #@echo sigset >>$@ + #@echo sigignore >>$@ + #@echo bsd_signal >>$@ + #@echo sysv_signal >>$@ +#endif +#ifneq (,$(findstring linux,$(OMR_HOST_OS))) + #@# linux + #@echo __sysv_signal >>$@ + #@echo ssignal >>$@ +#endif +#ifneq (,$(findstring osx,$(OMR_HOST_OS))) + #@# osx + #@echo __sysv_signal >>$@ + #@echo ssignal >>$@ +#endif +#ifneq (,$(findstring zos,$(OMR_HOST_OS))) + #@# z/os + #@echo __sigactionset >>$@ +#endif +#ifeq (,$(findstring win,$(OMR_HOST_OS))) +#ifeq (,$(findstring zos,$(OMR_HOST_OS))) + #@# !win && !zos + #@echo sigvec >>$@ +#endif +#endif + +target_link_libraries(omrsig omrutil omr_shared) + +#TODO ensure we are linking in the same way as source makefile: +#MODULE_STATIC_LIBS += omrutil +#ifneq (,$(findstring linux,$(OMR_HOST_OS))) + #MODULE_SHARED_LIBS += pthread +#endif +#ifneq (,$(findstring osx,$(OMR_HOST_OS))) + #MODULE_SHARED_LIBS += pthread +#endif + diff --git a/omrtrace/CMakeLists.txt b/omrtrace/CMakeLists.txt new file mode 100644 index 00000000000..4b95da0453d --- /dev/null +++ b/omrtrace/CMakeLists.txt @@ -0,0 +1,37 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_library(omrtrace STATIC + omrtraceapi.cpp + omrtracecomponent.cpp + omrtraceformatter.cpp + omrtracelog.cpp + omrtracemain.cpp + omrtracemisc.cpp + omrtraceoptions.cpp + omrtracepublish.cpp + omrtracewrappers.cpp +) + +#TODO: check if following makefile fragment still required: +#ifeq (gcc,$(OMR_TOOLCHAIN)) +## disable builtin strncpy buffer length check for optimized builds (_FORTIFY_SOURCE=1 requires -O3) + #ifeq ($(OMR_OPTIMIZE),1) + #MODULE_CXXFLAGS+=-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 + #endif +#endif diff --git a/omrversionstrings.CMakeTemplate.h b/omrversionstrings.CMakeTemplate.h new file mode 100644 index 00000000000..23d961403f1 --- /dev/null +++ b/omrversionstrings.CMakeTemplate.h @@ -0,0 +1,29 @@ +/******************************************************************************* + * + * (c) Copyright IBM Corp. 2017 + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 and + * Apache License v2.0 which accompanies this distribution. + * + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * The Apache License v2.0 is available at + * http://www.opensource.org/licenses/apache2.0.php + * + * Contributors: + * Multiple authors (IBM Corp.) - initial implementation and documentation + *******************************************************************************/ + +/* + * @configure_input@ + */ + +#ifndef OMRVERSIONSTRINGS_H +#define OMRVERSIONSTRINGS_H + +#cmakedefine OMR_VERSION_STRING "@OMR_VERSION_STRING@" +#cmakedefine OMR_JIT_VERSION_STRING "@OMR_JIT_VERSION_STRING@" + +#endif /* OMRVERSIONSTRINGS_H */ diff --git a/port/CMakeLists.txt b/port/CMakeLists.txt new file mode 100644 index 00000000000..2f27909e839 --- /dev/null +++ b/port/CMakeLists.txt @@ -0,0 +1,354 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +#TODO: at the moment this assumes all C source files which is a lie +include_directories( + . + ../nls +) + +add_definitions(-DOMRPORT_LIBRARY_DEFINE) + +set(OBJECTS "") +set(VPATH "") + +if(OMR_HOST_OS STREQUAL "aix") + list(APPEND OBJECTS omrgetsp.c) +endif() + + +if(OMR_HOST_OS STREQUAL "zos") + list(APPEND OBJECTS + j9generate_ieat_dump.s + omrget_large_pageable_pages_supported.s + j9wto.s + j9pgser_release.s + omrgetuserid.c + j9sysinfo_get_number_CPUs.s + j9jobname.s + j9userid.s + j9csrsi.c + j9csrsi_wrp.s + j9zfs.c + j9lpdat.mc + ) + #TODO more objects here. See port_objects.mk:55 + if(OMR_ENV_DATA64) + list(APPEND OBJECTS + omrget_userExtendedPrivateAreaMemoryType.s + omrget_large_pages_supported.s + omrget_large_2gb_pages_supported.s + omrvmem_support_above_bar.s + omrvmem_support_below_bar_64.s + j9ipt_ttoken64.s + ) + else() + list(APPEND OBJECTS omrvmem_support_below_bar_31.c) + endif() +else() + list(APPEND OBJECTS protect_helpers.c) +endif() + +list(APPEND OBJECTS + omrgetjobname.c + omrgetjobid.c + omrgetasid.c +) + +if(OMR_ARCH_S390) + list(APPEND OBJECTS omrrttime.s) +else() + if(OMR_ARCH_PPC) + if(OMR_ENV_DATA64) + if(OMR_HOST_OS STREQUAL "linux") + #TODO what source extension is this? + list(APPEND OBJECTS omrrttime) + endif() + endif() + endif() +endif() + +if(OMR_ARCH_S390) + if(OMR_HOST_OS STREQUAL "linux") + list(APPEND OBJECTS omrgetstfle) #TODO: extension? + else() + if(OMR_ENV_DATA64) + list(APPEND OBJECTS omrgetstfle64.s) + else() + list(APPEND OBJECTS omrgetstfle31.s) + endif() + endif() +endif() + + +#TODO another if block @port_objects.mk:89 + +if(OMR_HOST_OS STREQUAL "aix") + list(APPEND OBJECTS + rt_divu64.c + rt_time.c + ) +endif() + +list(APPEND OBJECTS + omrcpu.c + omrerror.c + omrerrorhelpers.c + omrexit.c + omrfile.c + omrfiletext.c + omrfilestream.c + omrfilestreamtext.c +) + +if(NOT OMR_HOST_OS STREQUAL "win") + list(APPEND OBJECTS omriconvhelpers.c) +endif() + +list(APPEND OBJECTS omrfile_blockingasync.c) + +if(OMR_HOST_OS STREQUAL "win") + list(APPEND OBJECTS omrfilehelpers.c) +endif() + +if(OMR_ENV_DATA64) + list(APPEND OBJECTS omrmem32helpers.c) +endif() + +list(APPEND OBJECTS + omrheap.c + omrmem.c + omrmemtag.c + omrmemcategories.c + omrport.c + omrmmap.c + j9nls.c + j9nlshelpers.c + omrosbacktrace.c + omrosbacktrace_impl.c + omrintrospect.c + omrintrospect_common.c + omrosdump.c + omrportcontrol.c + omrportptb.c + + omrsignal.c +) + +if(NOT OMR_HOST_OS STREQUAL "win") + list(APPEND OBJECTS omrsignal_context.c) +endif() + +list(APPEND OBJECTS + omrsl.c + omrstr.c + omrsysinfo.c +) + +if(OMR_HOST_OS STREQUAL zos) + list(APPEND OBJECTS omrsysinfo_helpers.c) +endif() + +list(APPEND OBJECTS omrsyslog.c) + +if(OMR_HOST_OS STREQUAL win) + #TODO hack to compile mc files + enable_language(RC) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/win32/omrsyslogmessages.rc + COMMAND mc ${CMAKE_CURRENT_SOURCE_DIR}/win32/omrsyslogmessages.mc + DEPENDS win32/omrsyslogmessages.mc + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/win32 + ) + #TODO need to handle res files properly + #list(APPEND OBJECTS omrsyslogmessages.res) +endif() + +list(APPEND OBJECTS + omrtime.c + omrtlshelpers.c + omrtty.c + omrvmem.c + omrmemtag_checks.c +) + +if(OMR_HOST_OS STREQUAL aix) + list(APPEND OBJECTS omrosdump_helpers.c) +elseif(OMR_HOST_OS STREQUAL linux) + list(APPEND OBJECTS omrosdump_helpers.c) +elseif(OMR_HOST_OS STREQUAL osx) + list(APPEND OBJECTS omrosdump_helpers.c) +endif() + +if(OMR_HOST_OS STREQUAL zos) + if(NOT OMR_ENV_DATA64) + list(APPEND OBJECTS + omrsignal_ceehdlr.c + omrsignal_context_ceehdlr.c + ) + endif() +endif() + +if(OMR_HOST_ARCH STREQUAL ppc) + if(OMR_HOST_OS STREQUAL linux) + list(APPEND OBJECTS auxv.c) + endif() +endif() + +if(OMR_OPT_CUDA) + list(APPEND OBJECTS omrcuda.c) +endif() + + + + +#Setup paths and include directories + +if(OMR_HOST_OS STREQUAL "zos") + list(APPEND VPATH zos390) + include_directories(zos390) +endif() + +if(OMR_HOST_OS STREQUAL "win") + if(OMR_ENV_DATA64) + list(APPEND VPATH win64amd) + include_directories(win64amd) + endif() +endif() + +if(OMR_HOST_OS STREQUAL "aix") + #ifdef I5_VERSION + #ifeq (1,$(OMR_ENV_DATA64)) + #vpath % $(PORT_SRCDIR)iseries64 + #MODULE_INCLUDES += $(PORT_SRCDIR)iseries64 + #endif + #vpath % $(PORT_SRCDIR)iseries + #MODULE_INCLUDES += $(PORT_SRCDIR)iseries + #endif + + if(OMR_ENV_DATA64) + #vpath % $(PORT_SRCDIR)aix64 + #MODULE_INCLUDES += $(PORT_SRCDIR)aix64 + endif() + #vpath % $(PORT_SRCDIR)aix + #MODULE_INCLUDES += $(PORT_SRCDIR)aix +endif() + + +#endif +#TODO other platforms port_objects:209 + +if(OMR_HOST_OS STREQUAL "linux") + #TODO need to port following vpath code + #ifeq (ppc,$(OMR_HOST_ARCH)) + #ifeq (1,$(OMR_ENV_DATA64)) + #ifeq (1,$(OMR_ENV_LITTLE_ENDIAN)) + #vpath % $(PORT_SRCDIR)linuxppc64le + #MODULE_INCLUDES += $(PORT_SRCDIR)linuxppc64le + #endif + #vpath % $(PORT_SRCDIR)linuxppc64 + #MODULE_INCLUDES += $(PORT_SRCDIR)linuxppc64 + #endif + #vpath % $(PORT_SRCDIR)linuxppc + #MODULE_INCLUDES += $(PORT_SRCDIR)linuxppc + #endif + + #ifeq (s390,$(OMR_HOST_ARCH)) + #ifeq (1,$(OMR_ENV_DATA64)) + #vpath % $(PORT_SRCDIR)linuxs39064 + #MODULE_INCLUDES += $(PORT_SRCDIR)linuxs39064 + #endif + #vpath % $(PORT_SRCDIR)linuxs390 + #MODULE_INCLUDES += $(PORT_SRCDIR)linuxs390 + #endif + + if(OMR_ARCH_ARM) + list(APPEND VPATH linuxarm) + include_directories(linuxarm) + endif() + + if(OMR_ARCH_X86) + if(OMR_ENV_DATA64) + list(APPEND VPATH linuxamd64) + include_directories(linuxamd64) + else() + list(APPEND VPATH linux386) + include_directories(linux386) + endif() + + endif() + + list(APPEND VPATH linux) + include_directories(linux) +endif() + + +if(OMR_HOST_OS STREQUAL "osx") + list(APPEND VPATH osx_include osx) + include_directories(osx_include osx) +endif() + + +if(OMR_HOST_OS STREQUAL "win") + list(APPEND VPATH win32_include win32) + include_directories(win32_include win32) +else() + list(APPEND VPATH unix) + include_directories(unix unix_include) +endif() + +list(APPEND VPATH common include) +include_directories(common include) + +#TODO need to set some flags and etc see line 300 + + +set(resolvedPaths "") +VPathResolve(OBJECTS VPATH resolvedPaths) + + +if(OMR_HOST_OS STREQUAL "win") + list(APPEND resolvedPaths win32/omrsyslogmessages.rc) +endif() + +add_tracegen(common/omrport.tdf) + +add_library(omrport STATIC + ut_omrport.c + ${resolvedPaths} +) + +target_link_libraries(omrport + j9thrstatic + j9hashtable +) + +#TODO hack to get to compile. Need platform checks +if(NOT OMR_HOST_OS STREQUAL "win") + if(NOT OMR_HOST_OS STREQUAL "zos") + target_link_libraries(omrport dl) + endif() +endif() + +if(OMR_HOST_OS STREQUAL "osx") + target_link_libraries(omrport iconv) +endif() + +if(OMR_HOST_OS STREQUAL "win") + target_link_libraries(omrport psapi pdh) +endif() diff --git a/scripts/build-on-travis.sh b/scripts/build-on-travis.sh new file mode 100755 index 00000000000..cfd021cd3cf --- /dev/null +++ b/scripts/build-on-travis.sh @@ -0,0 +1,46 @@ +#!/bin/bash +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +set -evx + +if test "x$BUILD_WITH_CMAKE" = "xyes"; then + mkdir build + cd build + cmake -Wdev -C../cmake/caches/Travis.cmake .. + if test "x$RUN_BUILD" != "xno"; then + cmake --build . + if test "x$RUN_TESTS" != "xno"; then + ctest -V + fi + fi +else + make -f run_configure.mk OMRGLUE=./example/glue SPEC="$SPEC" PLATFORM="$PLATFORM" + if test "x$RUN_BUILD" != "xno"; then + # Normal build system + make -j4 + if test "x$RUN_TESTS" != "xno"; then + make test + fi + fi + if test "x$RUN_LINT" = "xyes"; then + llvm-config --version + clang++ --version + make lint + fi +fi diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt new file mode 100644 index 00000000000..87ad91e7288 --- /dev/null +++ b/third_party/CMakeLists.txt @@ -0,0 +1,20 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_subdirectory(pugixml-1.5) +# TODO: gtest/gmock diff --git a/third_party/pugixml-1.5/CMakeLists.txt b/third_party/pugixml-1.5/CMakeLists.txt new file mode 100644 index 00000000000..81e82b6186f --- /dev/null +++ b/third_party/pugixml-1.5/CMakeLists.txt @@ -0,0 +1,26 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_library(pugixml + pugixml.cpp +) + +target_include_directories(pugixml + PUBLIC + ./ +) diff --git a/thread/CMakeLists.txt b/thread/CMakeLists.txt new file mode 100644 index 00000000000..b71755c3cd9 --- /dev/null +++ b/thread/CMakeLists.txt @@ -0,0 +1,297 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + + +add_tracegen(j9thr.tdf) + + +set(OBJECTS "") +set(VPATHS "") +list(APPEND OBJECTS + j9sem.c + omrthread.c + omrthreadattr.c + omrthreaddebug.c + omrthreaderror.c + omrthreadinspect.c + omrthreadmem.cpp + omrthreadnuma.c + omrthreadpriority.c + omrthreadtls.c + priority.c + thrcreate.c + threadhelpers.cpp + thrprof.c + thrdsup.c + rasthrsup.c + rwmutex.c +) + +#TODO need to port this makefile snippet +#ifeq (1,$(OMR_THR_JLM)) + #OBJECTS += omrthreadjlm +#endif + +if(NOT OMR_HOST_OS STREQUAL "win") + list(APPEND OBJECTS unixpriority.c) +else() + list(APPEND OBJECTS dllmain.c) + list(APPEND VPATHS win32) +endif() + + +include_directories(.) + + +if(OMR_HOST_OS STREQUAL "zos") + list(APPEND VPATHS + zos390 + unix + ) + include_directories(zos390 unix) + list(APPEND OBJECTS thrcputime.s) +endif() + +if(OMR_HOST_OS STREQUAL "linux") + list(APPEND VPATHS + linux + unix + ) + include_directories(linux unix) + +endif() + +if(OMR_HOST_OS STREQUAL "osx") + list(APPEND VPATHS osx unix) + include_directories(osx unix) +endif() + +#TODO need to implement AIX vpaths. +#relevent section from makefile: +#ifeq (aix,$(OMR_HOST_OS)) + #vpath % $(THREAD_SRCDIR)aix + #vpath % $(THREAD_SRCDIR)unix + #MODULE_INCLUDES += $(THREAD_SRCDIR)aix $(THREAD_SRCDIR)unix +#endif + +list(APPEND VPATHS common) + +#TODO need to add warning flags +#relevant Makefile section: +# Disable some warnings +#ifeq ($(OMR_TOOLCHAIN),gcc) +# MODULE_CFLAGS += -Wno-unused +#endif + + +#TODO need to port following symbol export stuff from Makefile: +#ifeq (zos,$(OMR_HOST_OS)) +#define WRITE_ZOS_THREAD_EXPORTS +#@echo omrthread_get_os_errno2 >>$@ +#endef +#endif + +#ifeq (1,$(OMR_THR_JLM)) +#define WRITE_JLM_THREAD_EXPORTS +#@echo omrthread_jlm_init >>$@ +#@echo omrthread_jlm_get_gc_lock_tracing >>$@ +#endef +#endif + +#ifeq (1,$(OMR_THR_ADAPTIVE_SPIN)) +#define WRITE_ADAPTIVE_SPIN_THREAD_EXPORTS +#@echo jlm_adaptive_spin_init >>$@ +#endef +#endif + +#ifeq (1,$(OMR_THR_TRACING)) +#define WRITE_TRACING_THREAD_EXPORTS +#@echo omrthread_monitor_dump_trace >>$@ +#@echo omrthread_monitor_dump_all >>$@ +#@echo omrthread_dump_trace >>$@ +#@echo omrthread_reset_tracing >>$@ +#endef +#endif + +#define WRITE_COMMON_THREAD_EXPORTS +#@echo j9sem_init >>$@ +#@echo j9sem_post >>$@ +#@echo j9sem_wait >>$@ +#@echo j9sem_destroy >>$@ +#@echo omrthread_init_library >>$@ +#@echo omrthread_shutdown_library >>$@ +#@echo omrthread_get_os_errno >>$@ +#@echo omrthread_get_errordesc >>$@ +#@echo omrthread_current_stack_free >>$@ +#@echo omrthread_abort >>$@ +#@echo omrthread_attach >>$@ +#@echo omrthread_attach_ex >>$@ +#@echo omrthread_create >>$@ +#@echo omrthread_create_ex >>$@ +#@echo omrthread_cancel >>$@ +#@echo omrthread_join >>$@ +#@echo omrthread_interrupt >>$@ +#@echo omrthread_clear_interrupted >>$@ +#@echo omrthread_interrupted >>$@ +#@echo omrthread_priority_interrupt >>$@ +#@echo omrthread_clear_priority_interrupted >>$@ +#@echo omrthread_priority_interrupted >>$@ +#@echo omrthread_monitor_destroy >>$@ +#@echo omrthread_monitor_destroy_nolock >>$@ +#@echo omrthread_monitor_flush_destroyed_monitor_list >>$@ +#@echo omrthread_monitor_enter >>$@ +#@echo omrthread_monitor_get_name >>$@ +#@echo omrthread_monitor_enter_abortable_using_threadId >>$@ +#@echo omrthread_monitor_enter_using_threadId >>$@ +#@echo omrthread_monitor_try_enter >>$@ +#@echo omrthread_monitor_try_enter_using_threadId >>$@ +#@echo omrthread_monitor_exit >>$@ +#@echo omrthread_monitor_exit_using_threadId >>$@ +#@echo omrthread_monitor_owned_by_self >>$@ +#@echo omrthread_monitor_init_with_name >>$@ +#@echo omrthread_monitor_notify >>$@ +#@echo omrthread_monitor_notify_all >>$@ +#@echo omrthread_monitor_wait >>$@ +#@echo omrthread_monitor_wait_timed >>$@ +#@echo omrthread_monitor_wait_abortable >>$@ +#@echo omrthread_monitor_wait_interruptable >>$@ +#@echo omrthread_monitor_num_waiting >>$@ +#@echo omrthread_resume >>$@ +#@echo omrthread_self >>$@ +#@echo omrthread_set_priority >>$@ +#@echo omrthread_get_priority >>$@ +#@echo omrthread_sleep >>$@ +#@echo omrthread_sleep_interruptable >>$@ +#@echo omrthread_suspend >>$@ +#@echo omrthread_tls_alloc >>$@ +#@echo omrthread_tls_alloc_with_finalizer >>$@ +#@echo omrthread_tls_free >>$@ +#@echo omrthread_tls_get >>$@ +#@echo omrthread_tls_set >>$@ +#@echo omrthread_yield >>$@ +#@echo omrthread_yield_new >>$@ +#@echo omrthread_exit >>$@ +#@echo omrthread_detach >>$@ +#@echo omrthread_global >>$@ +#@echo omrthread_global_monitor >>$@ +#@echo omrthread_get_flags >>$@ +#@echo omrthread_get_state >>$@ +#@echo omrthread_get_osId >>$@ +#@echo omrthread_get_ras_tid >>$@ +#@echo omrthread_get_stack_range >>$@ +#@echo omrthread_monitor_init_walk >>$@ +#@echo omrthread_monitor_walk >>$@ +#@echo omrthread_monitor_walk_no_locking >>$@ +#@echo omrthread_rwmutex_init >>$@ +#@echo omrthread_rwmutex_destroy >>$@ +#@echo omrthread_rwmutex_enter_read >>$@ +#@echo omrthread_rwmutex_exit_read >>$@ +#@echo omrthread_rwmutex_enter_write >>$@ +#@echo omrthread_rwmutex_try_enter_write >>$@ +#@echo omrthread_rwmutex_exit_write >>$@ +#@echo omrthread_rwmutex_is_writelocked >>$@ +#@echo omrthread_park >>$@ +#@echo omrthread_unpark >>$@ +#@echo omrthread_numa_get_max_node >>$@ +#@echo omrthread_numa_set_enabled >>$@ +#@echo omrthread_numa_set_node_affinity >>$@ +#@echo omrthread_numa_get_node_affinity >>$@ +#@echo omrthread_map_native_priority >>$@ +#@echo omrthread_set_priority_spread >>$@ +#@echo omrthread_set_name >>$@ + +#@echo omrthread_lib_enable_cpu_monitor >>$@ +#@echo omrthread_lib_lock >>$@ +#@echo omrthread_lib_try_lock >>$@ +#@echo omrthread_lib_unlock >>$@ +#@echo omrthread_lib_get_flags >>$@ +#@echo omrthread_lib_set_flags >>$@ +#@echo omrthread_lib_clear_flags >>$@ +#@echo omrthread_lib_control >>$@ +#@echo omrthread_lib_use_realtime_scheduling >>$@ + +#@echo omrthread_attr_init >>$@ +#@echo omrthread_attr_destroy >>$@ +#@echo omrthread_attr_set_name >>$@ +#@echo omrthread_attr_set_schedpolicy >>$@ +#@echo omrthread_attr_set_priority >>$@ +#@echo omrthread_attr_set_stacksize >>$@ +#@echo omrthread_attr_set_category >>$@ + +#@# for builder use only +#@echo omrthread_monitor_lock >>$@ +#@echo omrthread_monitor_unlock >>$@ + +#@echo omrthread_monitor_pin >>$@ +#@echo omrthread_monitor_unpin >>$@ + +#@echo omrthread_nanosleep >>$@ +#@echo omrthread_nanosleep_supported >>$@ +#@echo omrthread_nanosleep_to >>$@ + +#@echo omrthread_get_user_time >>$@ +#@echo omrthread_get_self_user_time >>$@ +#@echo omrthread_get_cpu_time >>$@ +#@echo omrthread_get_cpu_time_ex >>$@ +#@echo omrthread_get_self_cpu_time >>$@ +#@echo omrthread_get_process_times >>$@ + +#@echo omrthread_get_handle >>$@ +#@echo omrthread_get_stack_size >>$@ +#@echo omrthread_get_os_priority >>$@ + +#@echo omrthread_get_stack_usage >>$@ +#@echo omrthread_enable_stack_usage >>$@ + +#@# process-wide statistics +#@echo omrthread_get_process_cpu_time >>$@ +#@echo omrthread_get_jvm_cpu_usage_info >>$@ +#@echo omrthread_get_jvm_cpu_usage_info_error_recovery >>$@ +#@echo omrthread_get_category >>$@ +#@echo omrthread_set_category >>$@ + +#@# temp for the JIT +#@echo j9thread_self >>$@ +#@echo j9thread_tls_get >>$@ +#endef + +#define WRITE_THREAD_EXPORTS +#$(WRITE_COMMON_THREAD_EXPORTS) +#$(WRITE_ZOS_THREAD_EXPORTS) +#$(WRITE_JLM_THREAD_EXPORTS) +#$(WRITE_ADAPTIVE_SPIN_THREAD_EXPORTS) +#$(WRITE_TRACING_THREAD_EXPORTS) +#endef +set(resolvedPaths "") +VPathResolve(OBJECTS VPATHS resolvedPaths) +include_directories(common) +#TODO also should be able to build dynamic lib +add_library(j9thrstatic + ${resolvedPaths} + ut_j9thr.c +) + +target_include_directories(j9thrstatic + INTERFACE + . +) + +target_link_libraries(j9thrstatic + omrutil + j9pool +) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 00000000000..9df1ccb0e12 --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,76 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +if (NOT CMAKE_CROSSCOMPILING) + + add_subdirectory(hookgen) + add_subdirectory(tracemerge) + add_subdirectory(tracegen) + + export(TARGETS hookgen tracemerge tracegen FILE "ImportTools.cmake") + +else(NOT CMAKE_CROSSCOMPILING) + + set(OMR_TOOLS_IMPORTFILE "IMPORTFILE-NOTFOUND" CACHE FILEPATH + "Point it to the ImportTools.cmake file of a native build") + + #Logically we should be importing the file here, however, + #burried in the cmake docs, it says imported targets are directory scoped + #thus they would be useless if imported here + #include(${OMR_TOOLS_IMPORTFILE}) + +endif(NOT CMAKE_CROSSCOMPILING) + + +#TODO: currently output in source tree, should be in build tree +#TODO: Dependecy checking is broken, since it checks for output in build tree rather than src +function(add_hookgen input) + get_filename_component(input_dir "${input}" DIRECTORY) + #message("Hookgen, Output = ${ARGN}") + #message("Hookgen, depends = ${CMAKE_CURRENT_SOURCE_DIR}/${input}") + add_custom_command( + OUTPUT ${ARGN} + COMMAND hookgen ${CMAKE_CURRENT_SOURCE_DIR}/${input} + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${input}" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${input_dir} + ) +endfunction() + + +#TODO: pehaps should detect output by searching for "executable=" line +#takes extra optional argument name to override output filename +function(add_tracegen input) + get_filename_component(input_dir "${input}" DIRECTORY) + + if(ARGV1) + set(base_name "${ARGV1}") + else() + get_filename_component(base_name "${input}" NAME_WE) + endif() + #file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${input_dir}/ut_${base_name}" generated_filename) + file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/ut_${base_name}" generated_filename) + + add_custom_command( + OUTPUT "${generated_filename}.c" "${generated_filename}.h" "${generated_filename}.pdat" + COMMAND $ -w2cd -treatWarningAsError -generatecfiles -threshold 1 -file ${CMAKE_CURRENT_SOURCE_DIR}/${input} + DEPENDS ${input} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) +endfunction() + +#TODO we still dont do tracemerge properly diff --git a/tools/hookgen/CMakeLists.txt b/tools/hookgen/CMakeLists.txt new file mode 100644 index 00000000000..6b725be7f96 --- /dev/null +++ b/tools/hookgen/CMakeLists.txt @@ -0,0 +1,28 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + + +add_executable(hookgen + HookGen.cpp + main.cpp +) + +target_link_libraries(hookgen pugixml) +if(OMR_HOST_OS STREQUAL "zos") + target_link_libraries(hookgen j9a2e) +endif() diff --git a/tools/tracegen/CMakeLists.txt b/tools/tracegen/CMakeLists.txt new file mode 100644 index 00000000000..479fc4a5c0d --- /dev/null +++ b/tools/tracegen/CMakeLists.txt @@ -0,0 +1,50 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_executable(tracegen + main.cpp +) + +target_link_libraries(tracegen + PRIVATE + trace # static +) + +# TODO: Move libtrace to it's own home +# NOTE: trace is static so we don't futz with RPATHs to run the tools. +add_library(trace STATIC + ArgParser.cpp + CFileWriter.cpp + DATFileWriter.cpp + FileReader.cpp + FileUtils.cpp + Port.cpp + StringUtils.cpp + TDFParser.cpp + TraceGen.cpp + TraceHeaderWriter.cpp +) + +target_include_directories(trace + INTERFACE + ./ +) + +if(OMR_HOST_OS STREQUAL "zos") + target_link_libraries(trace j9a2e) +endif() diff --git a/tools/tracemerge/CMakeLists.txt b/tools/tracemerge/CMakeLists.txt new file mode 100644 index 00000000000..b19e1632b14 --- /dev/null +++ b/tools/tracemerge/CMakeLists.txt @@ -0,0 +1,32 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_executable(tracemerge + DATMerge.cpp + main.cpp +) + +target_include_directories(tracemerge + PRIVATE + ../tracegen/ +) + +target_link_libraries(tracemerge + PRIVATE + trace # static +) diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt new file mode 100644 index 00000000000..04db773b811 --- /dev/null +++ b/util/CMakeLists.txt @@ -0,0 +1,24 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +#add_subdirectory(a2e) +add_subdirectory(avl) +add_subdirectory(hashtable) +add_subdirectory(hookable) +add_subdirectory(omrutil) +add_subdirectory(pool) diff --git a/util/avl/CMakeLists.txt b/util/avl/CMakeLists.txt new file mode 100644 index 00000000000..ce2a7bddcdc --- /dev/null +++ b/util/avl/CMakeLists.txt @@ -0,0 +1,30 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_tracegen(avl.tdf) + +add_library(j9avl STATIC + avlsup.c + ut_avl.c +) + +target_include_directories(j9avl + PUBLIC + . +) + diff --git a/util/hashtable/CMakeLists.txt b/util/hashtable/CMakeLists.txt new file mode 100644 index 00000000000..d11c6ebc94f --- /dev/null +++ b/util/hashtable/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + + +#TODO need to port following makefile snippet +#ifeq ($(OMR_TOOLCHAIN),gcc) +# MODULE_CFLAGS += -Wno-unused-value +#endif + +add_tracegen(hashtable.tdf) + +add_library(j9hashtable STATIC + hash.c + hashtable.c + ut_hashtable.c +) + +target_include_directories(j9hashtable + PUBLIC + . +) + +target_link_libraries(j9hashtable + PUBLIC + omrutil + j9avl + j9pool +) diff --git a/util/hookable/CMakeLists.txt b/util/hookable/CMakeLists.txt new file mode 100644 index 00000000000..b132127a76b --- /dev/null +++ b/util/hookable/CMakeLists.txt @@ -0,0 +1,28 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +#TODO there is a bunch of stuff with vpaths, presumably for some extensibility reasons +# need to figure out if its actually needed and implement properly if required +add_library(j9hookstatic STATIC + hookable.cpp +) +target_include_directories(j9hookstatic + PUBLIC + . +) + diff --git a/util/omrutil/CMakeLists.txt b/util/omrutil/CMakeLists.txt new file mode 100644 index 00000000000..9067dc46248 --- /dev/null +++ b/util/omrutil/CMakeLists.txt @@ -0,0 +1,105 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +#TODO port following vpath code: +#ifeq (s390,$(OMR_HOST_ARCH)) + #ifeq (zos,$(OMR_HOST_OS)) + #ifeq (1,$(OMR_ENV_DATA64)) + #OBJECTS += j9memclrz10_64$(OBJEXT) + #vpath %.s unix/zos/64 + #else + #OBJECTS += j9ceetbck$(OBJEXT) + #OBJECTS += j9memclrz10_31$(OBJEXT) + #vpath %.s unix/zos/31 + #endif + + #OBJECTS += zosversion$(OBJEXT) getstoragekey$(OBJEXT) getpsw$(OBJEXT) j9getdsa$(OBJEXT) + #vpath %.c unix/zos + #vpath %.s unix/zos + #endif + + #ifeq (linux,$(OMR_HOST_OS)) + #ifeq (1,$(OMR_ENV_DATA64)) + #OBJECTS += j9memclrz10_64$(OBJEXT) + #vpath %.s unix/linux/s390/64 + #else + #OBJECTS += j9memclrz10_31$(OBJEXT) + #vpath %.s unix/linux/s390/31 + #endif + + #OBJECTS += archinfo$(OBJEXT) + #vpath %.c unix/linux/s390 + #endif +#endif + +#ifeq (ppc,$(OMR_HOST_ARCH)) + #ifeq (linux,$(OMR_HOST_OS)) + #ifeq (1,$(OMR_ENV_DATA64)) + #ifeq (1,$(OMR_ENV_LITTLE_ENDIAN)) + #OBJECTS += gettoc$(OBJEXT) + #vpath %.s unix/linux/ppc/64le + #endif + #endif + #endif + #ifeq (0,$(OMR_ENV_DATA64)) + #OBJECTS += cas8help$(OBJEXT) + #ifeq (linux,$(OMR_HOST_OS)) + #vpath cas8help.s unix/linux/ppc/32 + #else + #vpath cas8help.s unix/aix/32 + #endif + #endif +#endif + +#ifeq (zos,$(OMR_HOST_OS)) + #OBJECTS += zbarrier$(OBJEXT) + #ifeq (0,$(OMR_ENV_DATA64)) + #vpath zbarrier.s unix/zos/31 + #else + #vpath zbarrier.s unix/zos/64 + #endif +#endif + +add_tracegen(utilcore.tdf j9utilcore) + +add_library(omrutil STATIC + AtomicFunctions.cpp + argscan.c + detectVMDirectory.c + gettimebase.c + j9memclr.c + poolForPort.c + primeNumberHelper.c + ranking.c + spacesaving.c + stricmp.c + threadhelp.c + thrname_core.c + ut_j9utilcore.c + utf8decode.c + utf8encode.c + xlphelp.c + xml.c +) + +if(OMR_HOST_OS STREQUAL "win") + target_sources(omrutil + PRIVATE + win/j9getdbghelp.c + ) +endif() diff --git a/util/pool/CMakeLists.txt b/util/pool/CMakeLists.txt new file mode 100644 index 00000000000..01f54f0ab14 --- /dev/null +++ b/util/pool/CMakeLists.txt @@ -0,0 +1,26 @@ +############################################################################### +# +# (c) Copyright IBM Corp. 2017 +# +# This program and the accompanying materials are made available +# under the terms of the Eclipse Public License v1.0 and +# Apache License v2.0 which accompanies this distribution. +# +# The Eclipse Public License is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# The Apache License v2.0 is available at +# http://www.opensource.org/licenses/apache2.0.php +# +# Contributors: +# Multiple authors (IBM Corp.) - initial implementation and documentation +############################################################################### + +add_tracegen(pool.tdf) + +add_library(j9pool STATIC + pool.c + pool_cap.c + ut_pool.c +) +