Skip to content

Commit

Permalink
CMake: Update metal-c handling
Browse files Browse the repository at this point in the history
- Move handling of -q64 flag to ensure it gets properly set regardless of
scoping

- add -qnosearch and -I/usr/include/metal by default as standard c headers
are unusable by metal-c

- Move port library metal-c files to new library to work around
limitations on older versions of cmake

- Combine metal-c compilation rules. CMake does not seem to like having
custom rules which look like generated rules. ie rules which depend on
.c files and produce .o files

Signed-off-by: Devin Nakamura <devinn@ca.ibm.com>
  • Loading branch information
dnakamura committed Feb 3, 2021
1 parent 5ad8273 commit 7b6fea0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
20 changes: 8 additions & 12 deletions cmake/modules/OmrMetalC.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2019, 2020 IBM Corp. and others
# Copyright (c) 2019, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -38,12 +38,9 @@ find_program(XLC_EXECUTABLE
DOC "The XLC compiler"
)

set(OMR_METALC_XLC_FLAGS "-qlongname" CACHE STRING "Options added to XLC when compiler METAL-C to HLASM")
set(OMR_METALC_XLC_FLAGS "-qlongname" "-qnosearch" "-I/usr/include/metal/" CACHE STRING "Options added to XLC when compiler METAL-C to HLASM")
set(OMR_METALC_ASM_FLAGS "-mgoff" "-I" "CBC.SCCNSAM" CACHE STRING "Options added when compiling METAL-C HLASM files")

if(OMR_ENV_DATA64)
list(APPEND OMR_METALC_XLC_FLAGS "-q64")
endif()

# omr_compile_metalc(<mfile> <ofile>)
#
Expand All @@ -60,6 +57,10 @@ function(omr_compile_metalc mfile ofile)
omr_assert(TEST XLC_EXECUTABLE)
omr_assert(TEST AS_EXECUTABLE)

if(OMR_ENV_DATA64)
list(APPEND OMR_METALC_XLC_FLAGS "-q64")
endif()

if(NOT IS_ABSOLUTE "${mfile}")
set(mfile "${CMAKE_CURRENT_SOURCE_DIR}/${mfile}")
endif()
Expand All @@ -71,15 +72,10 @@ function(omr_compile_metalc mfile ofile)
set(cfile "${ofile}.c")
set(sfile "${ofile}.s")

add_custom_command(
OUTPUT "${cfile}"
MAIN_DEPENDENCY "${mfile}"
COMMAND "${CMAKE_COMMAND}" -E copy "${mfile}" "${cfile}"
VERBATIM
)
add_custom_command(
OUTPUT "${ofile}"
MAIN_DEPENDENCY "${cfile}"
DEPENDS "${mfile}"
COMMAND "${CMAKE_COMMAND}" -E copy "${mfile}" "${cfile}"
COMMAND "${XLC_EXECUTABLE}" -qmetal -S ${OMR_METALC_XLC_FLAGS} -o "${sfile}" "${cfile}"
COMMAND "${AS_EXECUTABLE}" ${OMR_METALC_ASM_FLAGS} -o "${ofile}" "${sfile}"
VERBATIM
Expand Down
15 changes: 11 additions & 4 deletions port/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2020 IBM Corp. and others
# Copyright (c) 2017, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -70,10 +70,13 @@ if(OMR_HOST_OS STREQUAL "zos")
zos390/omrlpdat.mc
zos390/omrlpdat.o
)
target_sources(omrport_obj
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/zos390/omrlpdat.o
# Older versions of CMake don't let you add pre-compiled objects to object-libraries.
# Instead create a new static library for the metal c files
omr_add_library(omrport_metalc STATIC
${CMAKE_CURRENT_BINARY_DIR}/zos390/omrlpdat.o
)
set_target_properties(omrport_metalc PROPERTIES LINKER_LANGUAGE C)

list(APPEND OBJECTS
omrgenerate_ieat_dump.s
omrget_large_pageable_pages_supported.s
Expand Down Expand Up @@ -444,6 +447,10 @@ target_link_libraries(omrport
${CMAKE_DL_LIBS}
)

if(OMR_OS_ZOS)
target_link_libraries(omrport PRIVATE omrport_metalc)
endif()

if(OMRPORT_OMRSIG_SUPPORT)
target_link_libraries(omrport PRIVATE omrsig)
endif()
Expand Down

0 comments on commit 7b6fea0

Please sign in to comment.