Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial changes for Open XL z/os support #7320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Deigue
Copy link
Contributor

@Deigue Deigue commented Apr 25, 2024

Includes all the initial work done a while ago made in order to support compiling with Open XL in context of z/OS.

(This is one part of the multiple changes added for supporting Open XL compilation on OMR)

Comment on lines 472 to 477
uintptr_t *tempHandle;
tempHandle = (uintptr_t *)&(thread->handle.__[0]);
#if defined(__GNUC__)
tempHandle = (uintptr_t *)&(thread->handle.__);
#else
tempHandle = (uintptr_t *)&(thread->handle.__[0]);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the same pattern as in #7323.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I am seeing https://github.com/Deigue/omr/blob/4401fae20ac9db1255fafb68333e322297d43620/include_core/thrtypes.h#L57 , handle is of type OSTHREAD

OSTHREAD tempHandle = thread->handle;
return  (uint_ptr)*  <cast> tempHandle

But what would the cast look like? Where can I find OSTHREAD to see what exactly __ is pulling out and how to cast it properly? "handle" also seemed like too broad a search/grep for /usr/include

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this is what I meant:

    OSTHREAD tempHandle = thread->handle;
    return (uintptr_t)*(unsigned long long *)&tempHandle;

For z/OS, OSTHREAD is defined in include_core/unix/thrdsup.h:

typedef pthread_t OSTHREAD;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, confirmed it works and everything compiles, and changed accordingly.

@babsingh
Copy link
Contributor

jenkins build all

@Deigue
Copy link
Contributor Author

Deigue commented Jun 11, 2024

java 21 jenkins passed
However, will be making more additional changes, so will need reverify here after have a more final draft.

  • Removed unnecessary changes and confirmed compiling with Open XL upto latest wip error.
  • Cleanup of pragma packed changes. pragma packed and pragma reset is unsupported by Open XL, and pragma pack(push,1) and pragma pop(pop) is functionally identical and works with both XLC and Open XL on z/OS.
  • Pending to RE-verify Jenkins XLC build.

@Deigue Deigue force-pushed the openxl-initial branch 2 times, most recently from 566b966 to f06239c Compare June 17, 2024 20:56
@Deigue
Copy link
Contributor Author

Deigue commented Jun 19, 2024

j21 jenkins verify Verified new changes compiling with XLC as well, after checking locally working with Open XL. Removing draft and changing to ready for review ...

@Deigue Deigue marked this pull request as ready for review June 19, 2024 15:06
Comment on lines +45 to +47
#if !defined(__GNUC__)
#define __THROW
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is within an extern "C" block, so none of the uses of __THROW below seem appropriate.
The macro definition, and its uses here and in omrsig.cpp should just be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is extern "C" only if __cplusplus is defined right?

And if that is the case, the it is safe to remove the define instances below entirely?
L35: #define __THROW
Snippet L35:37

#if defined(OSX)
#define __THROW
#endif /* defined(OSX) */

And what does that mean for these below where __THROW is being used, does the "__THROW" part need to be removed specifically from every line? https://github.com/eclipse/omr/blob/c256823419b4579cf64f94072337fa108f1761f9/include_core/omrsig.h#L104-L115

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The definitions of __THROW should be removed as well as all uses.

Copy link
Contributor Author

@Deigue Deigue Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Ill remove these, and from omrsig.cpp as well, will need somebody to help me run/issue a jenkins build for macos/windows as well, to verify that it doesnt impact and is all good.

Copy link
Contributor Author

@Deigue Deigue Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get these errors when removing the specifications:

/omr/omrsigcompat/omrsig.cpp:241:1: error: 'signal' is missing exception specification 'throw()'
  241 | signal(int signum, sighandler_t handler)
      | ^
      |                                          throw()

This being shown for all 5 functions defined in omrsig.cpp with __THROW (probably more errors if not just zos, as some might be not defined on zos)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are declared within an extern "C" { } block; C functions don't (can't) have throw() specifications.
If you preprocess omrsig.cpp, do you see an ealier declaration of these functions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The definition of the signal handler in omrsig.cpp should be qualified with extern "C". One might expect that it would be sufficient that the declaration appears within the extern "C" block beginning on line 45, but apparently not: That is something we should bring to the attention of the compiler team.

The suppression of warnings on Windows suggest to me that the declaration of signal is wrong there as well.

@@ -25,6 +25,7 @@

#include "omrcomp.h"

struct OMRPortLibrary;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A blank line after this one would be welcome.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -24,7 +24,7 @@ top_srcdir := ..
include $(top_srcdir)/omrmakefiles/configure.mk

MODULE_NAME := omrsig
ARTIFACT_TYPE := c_shared
ARTIFACT_TYPE := cxx_shared
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has nothing to do with OpenXL; it's just an error that could be corrected separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed from this PR.

@@ -1663,7 +1663,7 @@ omrshmem_openSharedMemory (OMRPortLibrary *portLibrary, intptr_t fd, const char
goto failDontUnlink;
}
} else {
#if defined(__GNUC__) || defined(AIXPPC)
#if (defined(__GNUC__) || defined(AIXPPC)) && !defined(J9ZOS390)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest reordering the #if branches so it's clear which one is intended for z/OS, or #define KEY appropriately for each platform/compiler and then use KEY instead of key, _key or __key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you detail that a bit, looking at the logic again, since I have excluded via !defined(J9ZOS390) , it should mean that z/OS does not use any of the child if branches underlying within the parent if clause right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now that none of the branches would apply for z/OS: is that the right behavior?
If so, I suggest we reorder the code to put the z/OS path first, and this in the #else block:

#if defined(OMRZOS390)
    // existing lines 1686-1709
#elif defined(__GNUC__) || defined(AIXPPC)
    // existing lines 1667-1683
#endif /* defined(OMRZOS390) */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, and that does look cleaner.
But what is the difference (if any) between OMRZOS390 and J9ZOS390 ... because if it seems there is diff, then I will still need it as follows:

#if defined(OMRZOS390)
    // existing lines 1686-1709
#elif (defined(__GNUC__) || defined(AIXPPC)) && !defined(J9ZOS390)
    // existing lines 1667-1683
#endif /* defined(OMRZOS390) */

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think OMRZOS390 is the preferred flag to test in new code, J9ZOS390 is a name that originated in OpenJ9. They're both still used and I think they're equivalent, but OMR is supposed to be a base for OpenJ9, not dependent on anything from OpenJ9 (including naming conventions).

Copy link
Contributor Author

@Deigue Deigue Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the build is failing after reorganizing this and omrshsem_deprecated.c

cd .../omr/build/port && /xlc210/usr/lpp/IBM/cnw/v2r1/openxl/bin/ibm-clang64  -D__STDC_LIMIT_MACROS -D_ALL_SOURCE -D_OPEN_THREADS=3 -D_XOPEN_SOURCE=600 -DJ9ZOS390 -DJ9ZOS39064 -DLONGLONG -DOMR_EBCDIC -DOMRPORT_LIBRARY_DEFINE -DSUPPORTS_THREAD_LOCAL -DZOS -I...(all includes here)  -fstrict-aliasing -mzos-target=ZOSV2R4 -m64 -march=arch10   -fvisibility=default -o CMakeFiles/omrport_obj.dir/unix/omrshmem.c.o   -c /.../omr/port/unix/omrshmem.c  

The full command follows the above format, and J9Z0S390 is defined, but looks like OMRZOS390 is not ... so I might need to switch it to J9ZOS390. Doing this seems to highlight a bigger issue, that OMRZOS390 clauses aren't being used for the file, so all the conditionals that are expected to be entered arent, and thus causes compilation problems.

Looks like from what I can see it was not set for xlc all along either, unless Im missing somewhere in code where its defined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see OMRZOS390 defined anywhere (despite tests in this file and in omrsharedhelper.h).
Unless someone can point to where OMRZOS390 is defined, this should use J9ZOS390.

Copy link
Contributor Author

@Deigue Deigue Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, thats what I was mentioning in my prior comment. As such, in the current state of the PR I am still utilizing J9ZOS390 in this file.
Unless you are saying replace all the mentions in this file, that I would have to change and I suspect I will be running into other problems.

@@ -1060,7 +1060,7 @@ omrshsem_openSemaphore(struct OMRPortLibrary *portLibrary, intptr_t fd, char *ba
goto failDontUnlink;
}
} else {
#if defined(__GNUC__) || defined(AIXPPC) || defined(OMRZTPF)
#if (defined(__GNUC__) || defined(AIXPPC) || defined(J9ZTPF)) && !defined(J9ZOS390)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment regarding KEY here.

@@ -28,7 +28,7 @@
#define PGTHA_ACCESS_CURRENT 1
#define PGTHA_FLAG_PROCESS_DATA 0x80

#pragma pack(packed)
#pragma pack(push, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean the same for both xlc and OpenXL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes they should be functionally the same.
https://www.ibm.com/docs/en/zos/2.4.0?topic=descriptions-pragma-pack
also have confirmed internally with Sean from the open-xl/cpp team

Copy link
Contributor Author

@Deigue Deigue Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have changed this to #pragma pack(1) after having confirmed the packed struct sizes between XLC and Open XL and confirming the functionality is identical with Sean. He suggested to use this notation instead.
Also verified both XLC and Open XL compilers all omr tests are passing with this.

Comment on lines 52 to 53
#if defined(OMR_ENV_DATA64)
#else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just say #if !defined(OMR_ENV_DATA64) and add the missing #endif comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like I have your feedback in the other PR: #7321
Might just remove this file from this PR, as that one seems to handle more updated/latest code for omrintrospect.h

typedef _Packed struct J9RIT {
typedef struct __attribute__((packed)) J9RIT {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, do xlc and OpenXL attach the same meaning to this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do have the same meaning as per discussing internally with Sean from the cpp team. I did inquire if we have any published/public documentation for this, but I dont think they have a dedicated page regarding this particular suggestion/tweak.
However digging a bit and searching for it, there is a small mention of it on this page: https://www.ibm.com/docs/en/open-xl-c-cpp-zos/2.1?topic=guide-binary-compatibility

To quote part of our discussions:

The problem with _Packed is that it is C only and the usual change to attribute((packed)) for C++ doesn't have the same semantics.

typedef struct S _Packed {
   char c;
   int i;
 } S;
 S s1;
 struct S s2;

In this example s1 and s2 have different sizes and types. The _Packed keyword applies to the declarator (eg. typedef name S) on the struct definition. The _Packed keyword creates a hidden duplicate version of the struct.
Avoid the keyword even in XL.

Includes all the initial work done a while ago made
in order to support compiling with Open XL in context
of z/OS.

Signed-off-by: Gaurav Chaudhari <[email protected]>
@Deigue
Copy link
Contributor Author

Deigue commented Sep 18, 2024

@keithc-ca This one is also ready. I have added comments for prior questions above. Wanted to make sure this is approved from your perspective before Babneet can kick off the jenkins builds and start the process for merging the changes.

Comment on lines +45 to +47
#if !defined(__GNUC__)
#define __THROW
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The definition of the signal handler in omrsig.cpp should be qualified with extern "C". One might expect that it would be sufficient that the declaration appears within the extern "C" block beginning on line 45, but apparently not: That is something we should bring to the attention of the compiler team.

The suppression of warnings on Windows suggest to me that the declaration of signal is wrong there as well.

@@ -1663,7 +1663,7 @@ omrshmem_openSharedMemory (OMRPortLibrary *portLibrary, intptr_t fd, const char
goto failDontUnlink;
}
} else {
#if defined(__GNUC__) || defined(AIXPPC)
#if (defined(__GNUC__) || defined(AIXPPC)) && !defined(J9ZOS390)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see OMRZOS390 defined anywhere (despite tests in this file and in omrsharedhelper.h).
Unless someone can point to where OMRZOS390 is defined, this should use J9ZOS390.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants