Skip to content

Commit

Permalink
CMake: Update handling of a2e/omr_ascii
Browse files Browse the repository at this point in the history
- Move include folders from platform includes to omr_ascii since they
aren't required when doing an EBCDIC build

- Make omr_port_obj inherit compile options from omr_base so releveant
a2e flags get applied if required.

- Update misc components to properly support EBCDIC builds.

Signed-off-by: Devin Nakamura <devinn@ca.ibm.com>
  • Loading branch information
dnakamura committed May 4, 2021
1 parent 22a4853 commit abc94cf
Show file tree
Hide file tree
Showing 19 changed files with 59 additions and 79 deletions.
11 changes: 5 additions & 6 deletions cmake/modules/platform/os/zos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@ list(APPEND OMR_PLATFORM_DEFINITIONS
-DZOS
)

list(APPEND OMR_PLATFORM_INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/util/a2e/headers
/usr/lpp/cbclib/include
/usr/include
)
# CMake ignores any include directories which appear in IMPLICIT_INCLUDE_DIRECTORIES.
# This causes an issue with a2e since we need to re-specify them after clearing default search path.
list(REMOVE_ITEM CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES /usr/include)
list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES /usr/include)

# Create helper targets for specifying ascii/ebcdic options
add_library(omr_ascii INTERFACE)
target_compile_definitions(omr_ascii INTERFACE -DIBM_ATOE)
target_compile_options(omr_ascii INTERFACE "-Wc,convlit(ISO8859-1)")
target_compile_options(omr_ascii INTERFACE "-Wc,convlit(ISO8859-1),nose,se(${CMAKE_CURRENT_LIST_DIR}/../../../../util/a2e/headers)")
target_link_libraries(omr_ascii INTERFACE j9a2e)

add_library(omr_ebcdic INTERFACE)
Expand Down
4 changes: 0 additions & 4 deletions fvtest/algotest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ if(OMR_OS_WINDOWS)
)
endif()

if(OMR_OS_ZOS)
target_link_libraries(omralgotest j9a2e)
endif()

set_property(TARGET omralgotest PROPERTY FOLDER fvtest)

omr_add_test(NAME algotest COMMAND $<TARGET_FILE:omralgotest> --gtest_output=xml:${CMAKE_CURRENT_BINARY_DIR}/omralgotest-results.xml -avltest:${CMAKE_CURRENT_SOURCE_DIR}/avltest.lst)
4 changes: 0 additions & 4 deletions fvtest/compilertriltest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ target_link_libraries(comptest
tril
)

if(OMR_OS_ZOS)
target_link_libraries(comptest j9a2e)
endif()

set_property(TARGET comptest PROPERTY FOLDER fvtest)

omr_add_test(
Expand Down
4 changes: 0 additions & 4 deletions fvtest/gctest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ target_link_libraries(omrgctest
${OMR_PORT_LIB}
)

if(OMR_OS_ZOS)
target_link_libraries(omrgctest j9a2e)
endif()

set_property(TARGET omrgctest PROPERTY FOLDER fvtest)

omr_add_test(NAME gctest
Expand Down
6 changes: 0 additions & 6 deletions fvtest/porttest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ if(OMR_OS_WINDOWS)
)
endif()

if(OMR_OS_ZOS)
target_link_libraries(omrporttest
j9a2e
)
endif()

omr_add_library(sltestlib SHARED
sltestlib/sltest.c
)
Expand Down
4 changes: 2 additions & 2 deletions fvtest/porttest/omrsignalTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2020 IBM Corp. and others
* Copyright (c) 1991, 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 @@ -41,7 +41,7 @@
#include <process.h>
#endif /* defined(OMR_OS_WINDOWS) */

#if defined(J9ZOS390)
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
#include "atoe.h"
#endif

Expand Down
53 changes: 28 additions & 25 deletions fvtest/porttest/si.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2020 IBM Corp. and others
* Copyright (c) 1991, 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 All @@ -24,6 +24,10 @@
* $Revision: 1.64 $
* $Date: 2012-12-05 05:27:54 $
*/
#if defined(J9ZOS390)
#define _UNIX03_SOURCE
#endif

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Expand All @@ -42,8 +46,7 @@
#include <sys/resource.h> /* For RLIM_INFINITY */
#endif /* !defined(OMR_OS_WINDOWS) */

#if defined(J9ZOS390)
#define _UNIX03_SOURCE
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
#include "atoe.h"
#endif

Expand Down Expand Up @@ -1769,29 +1772,29 @@ TEST(PortSysinfoTest, sysinfo_test_get_tmp3)
const char *utf8 = "/tmp/test/";
const char *utf8_file = "/tmp/test/test.txt";
char *origEnvRef = getenv("TMPDIR");
#if defined(J9ZOS390)
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
char *envVarInEbcdic = a2e_string("TMPDIR");
char *origEnvInEbcdic = NULL;
char *utf8InEbcdic = a2e_string(utf8);
#endif /* defined(J9ZOS390) */
#endif /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */

reportTestEntry(OMRPORTLIB, testName);

if (NULL != origEnvRef) {
origEnv = (char *)omrmem_allocate_memory(strlen(origEnvRef) + 1, OMRMEM_CATEGORY_PORT_LIBRARY);
if (NULL != origEnv) {
strcpy(origEnv, origEnvRef);
#if defined(J9ZOS390)
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
origEnvInEbcdic = a2e_string(origEnv);
#endif /* defined(J9ZOS390) */
#endif /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */
}
}

#if defined(J9ZOS390)
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
rc = setenv(envVarInEbcdic, utf8InEbcdic, 1);
#else /* defined(J9ZOS390) */
#else /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */
rc = setenv("TMPDIR", (const char *)utf8, 1);
#endif /* defined(J9ZOS390) */
#endif /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */

#endif /* defined(OMR_OS_WINDOWS) */

Expand Down Expand Up @@ -1845,21 +1848,21 @@ TEST(PortSysinfoTest, sysinfo_test_get_tmp3)
if (NULL != origEnv) {
#if defined(OMR_OS_WINDOWS)
_wputenv_s(L"TMP", origEnv);
#elif defined(J9ZOS390) /* defined(OMR_OS_WINDOWS) */
#elif defined(J9ZOS390) && !defined(OMR_EBCDIC) /* defined(OMR_OS_WINDOWS) */
setenv(envVarInEbcdic, origEnvInEbcdic, 1);
#else /* defined(J9ZOS390) */
#else /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */
setenv("TMPDIR", origEnv, 1);
#endif /* defined(OMR_OS_WINDOWS) */
omrmem_free_memory(origEnv);
} else {
#if defined(OMR_OS_WINDOWS)
_wputenv_s(L"TMP", L"");
#elif !defined(J9ZOS390) /* defined(OMR_OS_WINDOWS) */
#elif !defined(J9ZOS390) && !defined(OMR_EBCDIC) /* defined(OMR_OS_WINDOWS) */
unsetenv("TMPDIR");
#endif /* defined(OMR_OS_WINDOWS) */
}

#if defined(J9ZOS390)
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
if (NULL != envVarInEbcdic) {
free(envVarInEbcdic);
}
Expand All @@ -1869,7 +1872,7 @@ TEST(PortSysinfoTest, sysinfo_test_get_tmp3)
if (NULL != utf8InEbcdic) {
free(utf8InEbcdic);
}
#endif /* defined(J9ZOS390) */
#endif /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */

if (NULL != buffer) {
omrmem_free_memory(buffer);
Expand All @@ -1891,11 +1894,11 @@ TEST(PortSysinfoTest, sysinfo_test_get_tmp4)
char *oldTmpDir = NULL;
char *oldTmpDirValue = NULL;
const char *modifiedTmpDir = "omrsysinfo_test_get_tmp4_dir";
#if defined(J9ZOS390)
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
char *envVarInEbcdic = a2e_string(envVar);
char *oldTmpDirValueInEbcdic = NULL;
char *modifiedTmpDirInEbcdic = a2e_string(modifiedTmpDir);
#endif /* defined(J9ZOS390) */
#endif /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */

reportTestEntry(OMRPORTLIB, testName);

Expand All @@ -1904,17 +1907,17 @@ TEST(PortSysinfoTest, sysinfo_test_get_tmp4)
oldTmpDirValue = (char *)omrmem_allocate_memory(strlen(oldTmpDir) + 1, OMRMEM_CATEGORY_PORT_LIBRARY);
if (NULL != oldTmpDirValue) {
strcpy(oldTmpDirValue, oldTmpDir);
#if defined(J9ZOS390)
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
oldTmpDirValueInEbcdic = a2e_string(oldTmpDirValue);
#endif /* defined(J9ZOS390) */
#endif /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */
}
}

#if defined(J9ZOS390)
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
rc = setenv(envVarInEbcdic, modifiedTmpDirInEbcdic, 1);
#else /* defined(J9ZOS390) */
#else /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */
rc = setenv(envVar, modifiedTmpDir, 1);
#endif /* defined(J9ZOS390) */
#endif /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */
if (0 != rc) {
outputErrorMessage(PORTTEST_ERROR_ARGS, "error in updating environment variable TMPDIR, rc: %zd\n", rc);
}
Expand Down Expand Up @@ -1960,7 +1963,7 @@ TEST(PortSysinfoTest, sysinfo_test_get_tmp4)
}

/* restore TMPDIR */
#if defined(J9ZOS390)
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
if (NULL != oldTmpDirValue) {
setenv(envVarInEbcdic, oldTmpDirValueInEbcdic, 1);
omrmem_free_memory(oldTmpDirValue);
Expand All @@ -1974,14 +1977,14 @@ TEST(PortSysinfoTest, sysinfo_test_get_tmp4)
if (NULL != modifiedTmpDirInEbcdic) {
free(modifiedTmpDirInEbcdic);
}
#else /* defined(J9ZOS390) */
#else /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */
if (NULL != oldTmpDirValue) {
setenv(envVar, oldTmpDirValue, 1);
omrmem_free_memory(oldTmpDirValue);
} else {
unsetenv(envVar);
}
#endif /* defined(J9ZOS390) */
#endif /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */

reportTestExit(OMRPORTLIB, testName);
}
Expand Down
6 changes: 4 additions & 2 deletions fvtest/porttest/testProcessHelpers.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
* Copyright (c) 2001, 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 @@ -40,9 +40,11 @@

#if defined(J9ZOS390)
#include <spawn.h>
#if !defined(OMR_EBCDIC)
#include <stdlib.h> /* for malloc for atoe */
#include "atoe.h"
#endif
#endif /* !defined(OMR_EBCDIC) */
#endif /* defined(J9ZOS390) */

#include <string.h>

Expand Down
4 changes: 0 additions & 4 deletions fvtest/sigtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ if(OMR_OS_WINDOWS)
)
endif()

if(OMR_OS_ZOS)
target_link_libraries(omrsigtest j9a2e)
endif()

target_include_directories(omrsigtest
PRIVATE
.
Expand Down
4 changes: 0 additions & 4 deletions fvtest/threadextendedtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ target_link_libraries(omrthreadextendedtest
${OMR_PORT_LIB}
)

if(OMR_OS_ZOS)
target_link_libraries(omrthreadextendedtest j9a2e)
endif()

set_property(TARGET omrthreadextendedtest PROPERTY FOLDER fvtest)

if(NOT OMR_OS_ZOS)
Expand Down
4 changes: 0 additions & 4 deletions fvtest/threadtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ if(OMR_OS_WINDOWS)
)
endif()

if(OMR_OS_ZOS)
target_link_libraries(omrthreadtest j9a2e)
endif()

set_property(TARGET omrthreadtest PROPERTY FOLDER fvtest)

omr_add_test(NAME threadtest COMMAND $<TARGET_FILE:omrthreadtest> --gtest_output=xml:${CMAKE_CURRENT_BINARY_DIR}/omrthreadtest-results.xml)
Expand Down
4 changes: 2 additions & 2 deletions fvtest/threadtest/createTestHelper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
* Copyright (c) 2001, 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 All @@ -24,7 +24,7 @@

#include <assert.h>
#include <stdlib.h>
#if defined(J9ZOS390)
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
#include "atoe.h"
#endif
#include <stdio.h>
Expand Down
5 changes: 1 addition & 4 deletions fvtest/utiltest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ omr_add_executable(omrutiltest

target_link_libraries(omrutiltest
#omrGtestGlue
omr_base
omrGtest
omrutil
)
Expand All @@ -34,10 +35,6 @@ target_include_directories(omrutiltest
$<TARGET_PROPERTY:omrGtestGlue,INTERFACE_INCLUDE_DIRECTORIES>
)

if(OMR_OS_ZOS)
target_link_libraries(omrutiltest j9a2e)
endif()

set_property(TARGET omrutiltest PROPERTY FOLDER fvtest)

omr_add_test(NAME utiltest COMMAND $<TARGET_FILE:omrutiltest> --gtest_output=xml:${CMAKE_CURRENT_BINARY_DIR}/omrutiltest-results.xml)
3 changes: 0 additions & 3 deletions omrsigcompat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ target_compile_options(omrsig
if(OMR_HOST_OS MATCHES "linux|osx")
target_link_libraries(omrsig PRIVATE dl)
endif()
if(OMR_OS_ZOS)
target_link_libraries(omrsig PRIVATE j9a2e)
endif()

install(
TARGETS omrsig
Expand Down
6 changes: 3 additions & 3 deletions omrtrace/omrtracewrappers.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2019 IBM Corp. and others
* Copyright (c) 1991, 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 @@ -31,9 +31,9 @@
#include "omrtrace_internal.h"
#include "thread_api.h"

#if defined(J9ZOS390)
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
#include "atoe.h"
#endif
#endif /* defined(J9ZOS390) && !defined(OMR_EBCDIC) */

void
twFprintf(const char *formatStr, ...)
Expand Down
5 changes: 5 additions & 0 deletions port/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ target_include_directories(omrport_obj PRIVATE
../nls
)

# Ensure that we pull in options associated with omr_base.
target_compile_options(omrport_obj PUBLIC $<TARGET_PROPERTY:omr_base,INTERFACE_COMPILE_OPTIONS>)
target_compile_definitions(omrport_obj PUBLIC $<TARGET_PROPERTY:omr_base,INTERFACE_COMPILE_DEFINITIONS>)
target_include_directories(omrport_obj PRIVATE $<TARGET_PROPERTY:omr_base,INTERFACE_INCLUDE_DIRECTORIES>)

# This flag indicates that we are compiling the port library
target_compile_definitions(omrport_obj PRIVATE -DOMRPORT_LIBRARY_DEFINE)

Expand Down
5 changes: 5 additions & 0 deletions thread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ target_compile_definitions(j9thr_obj
$<TARGET_PROPERTY:omr_base,INTERFACE_COMPILE_DEFINITIONS>
)

target_compile_options(j9thr_obj
PUBLIC
$<TARGET_PROPERTY:omr_base,INTERFACE_COMPILE_OPTIONS>
)

target_enable_ddr(j9thr_obj)
ddr_add_headers(j9thr_obj
${omr_SOURCE_DIR}/include_core/omrthread.h
Expand Down
2 changes: 1 addition & 1 deletion util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
###############################################################################

if(OMR_OS_ZOS)
if(OMR_OS_ZOS AND NOT OMR_USE_NATIVE_ENCODING)
add_subdirectory(a2e)
endif()
add_subdirectory(avl)
Expand Down
Loading

0 comments on commit abc94cf

Please sign in to comment.