Skip to content

Add support for AArch64 macOS - #6204

Merged
0xdaryl merged 1 commit into
eclipse-omr:masterfrom
knn-k:aarch64macos1
Oct 21, 2021
Merged

0xdaryl merged 1 commit into
eclipse-omr:masterfrom
knn-k:aarch64macos1

Conversation

@knn-k

@knn-k knn-k commented Oct 14, 2021

Copy link
Copy Markdown
Contributor

This commit adds changes for supporting AArch64 macOS.

Signed-off-by: KONNO Kazuhiro konno@jp.ibm.com

@knn-k

knn-k commented Oct 14, 2021

Copy link
Copy Markdown
Contributor Author

omrosdump.c and omrsignal_context.c are not implemented yet. Just disabled x86-specific parts in those files.


if(OMR_OS_LINUX)
list(APPEND OMR_PLATFORM_DEFINITIONS
-Wno-unused-but-set-variable

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This option is not available in clang for AArch64 macOS.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If there is an equivalent option, it should be used instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I cannot find an equivalent option.

% clang --version
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: arm64-apple-darwin20.6.0
Thread model: posix
% clang -c -Wno-unused-but-set-variable hello.c
warning: unknown warning option '-Wno-unused-but-set-variable'; did you mean '-Wno-unused-const-variable'? [-Wunknown-warning-option]

if(OMR_ENV_DATA64 AND (NOT OMR_ARCH_AARCH64))
# Set page zero size to 4KB for mapping memory below 4GB.
list(APPEND OMR_PLATFORM_EXE_LINKER_OPTIONS
-pagezero_size 0x1000

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You cannot change the pagezero size on AArch64 macOS.

@knn-k

knn-k commented Oct 14, 2021

Copy link
Copy Markdown
Contributor Author

Builds for x86-64 macOS and aarch64 Linux are successful in OpenJ9 project (eclipse-openj9/openj9#13700).

@0xdaryl

0xdaryl commented Oct 18, 2021

Copy link
Copy Markdown
Contributor

@keithc-ca : would you like to review this PR as well?


if(OMR_OS_LINUX)
list(APPEND OMR_PLATFORM_DEFINITIONS
-Wno-unused-but-set-variable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If there is an equivalent option, it should be used instead.

@@ -25,9 +25,14 @@ list(APPEND OMR_PLATFORM_DEFINITIONS
-DAARCH64GNU

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does GNU refer to here? If it is the compiler, it would seem inappropriate on macOS where clang is used.

Copy link
Copy Markdown
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 any uses of AARCH64GNU in OMR (nor in OpenJ9): perhaps it need not be defined.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess -DAARCH64GNU came from -DARMGNU for 32-bit ARM.
I removed the option from aarch64.cmake and also from omrmakefiles/rules.linux.mk for consistency.

Comment thread cmake/modules/platform/os/osx.cmake Outdated
list(APPEND TR_COMPILE_DEFINITIONS -DSUPPORTS_THREAD_LOCAL -DOSX)

if(OMR_ENV_DATA64)
if(OMR_ENV_DATA64 AND (NOT OMR_ARCH_AARCH64))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The parentheses in (NOT OMR_ARCH_AARCH64) are not needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread compiler/aarch64/runtime/CodeSync.cpp Outdated
__builtin___clear_cache(codeStart, codeStart+codeSize);
#else
#error Not supported yet
#error Not supported platform

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: the message should be 'Unsupported platform' or 'Platform not supported'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread port/osx/omrosdump.c Outdated
Comment on lines +54 to +58
#if !defined(AARCH64)
x86_thread_state_t thread_state;
x86_float_state_t float_state;
x86_exception_state_t exceptions;
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the condition should be defined(_AMD64_), which should be repeated in a comment on the #endif:

#if defined(_AMD64_)
	x86_thread_state_t thread_state;
	x86_float_state_t float_state;
	x86_exception_state_t exceptions;
#endif /* defined(_AMD64_) */

The same goes for all x86_64-specific sections below. Later, an implementation should be added for aarch64, conditional on defined(AARCH64).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread port/osx/omrosdump.c Outdated
static kern_return_t
list_thread_commands(mach_port_t task_port, struct thread_command_full_64 **thread_commands, natural_t *thread_count)
{
#if !defined(AARCH64)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The condition should be defined(_AMD64_), which should be repeated in a comment on #else and #endif.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread port/osx/omrsignal_context.c Outdated
uint32_t
infoForFPR(struct OMRPortLibrary *portLibrary, OMRUnixSignalInfo *info, int32_t index, const char **name, void **value)
{
#if !defined(AARCH64)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The condition should be defined(_AMD64_), which should be repeated in a comment on #else and #endif.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

-Wno-unused-but-set-variable
)

if(OMR_OS_LINUX)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be if(OMR_TOOLCONFIG STREQUAL "gnu")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This does not work. MacOS clang environment is recognized as a "gnu" toolchain.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the condition using CMAKE_C_COMPILER_ID.

@knn-k
knn-k force-pushed the aarch64macos1 branch 2 times, most recently from b289212 to c084bd8 Compare October 19, 2021 03:38
@knn-k

knn-k commented Oct 19, 2021

Copy link
Copy Markdown
Contributor Author

I ran a build for x86-64 macOS with this PR in the following internal Jenkins job:

  • job/Build_JDK17_x86-64_mac_Personal/76/

@knn-k

knn-k commented Oct 19, 2021

Copy link
Copy Markdown
Contributor Author

I have no idea why some of the checks in this PR were canceled.

Comment thread port/osx/omrosdump.c Outdated
Comment on lines +54 to +58
#if defined(_AMD64_)
x86_thread_state_t thread_state;
x86_float_state_t float_state;
x86_exception_state_t exceptions;
#endif /* defined(_AMD64_) */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, my suggestion to use _AMD64_ was based on outdated advice in https://github.com/eclipse/omr/blob/master/doc/CodingStandard.md: I think this should use OMR_ARCH_X86 instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wonder it should be OMR_ARCH_X86 or other symbol like J9HAMMER. What is defined with x86-64 macOS?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I still think it should be OMR_ARCH_X86, see, for example, AtomicSupport.hpp. If we ever support 32-bit builds on OSX, we have much more work to do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I replaced _AMD64_ by OMR_ARCH_X86.

-Wno-unused-but-set-variable
)

if(OMR_OS_LINUX)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

-Wno-unused-but-set-variable
)

# Apple clang does not support the following option

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please end sentences with a period.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread port/osx/omrosdump.c Outdated
Comment on lines +54 to +58
#if defined(_AMD64_)
x86_thread_state_t thread_state;
x86_float_state_t float_state;
x86_exception_state_t exceptions;
#endif /* defined(_AMD64_) */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I still think it should be OMR_ARCH_X86, see, for example, AtomicSupport.hpp. If we ever support 32-bit builds on OSX, we have much more work to do.

@knn-k

knn-k commented Oct 21, 2021

Copy link
Copy Markdown
Contributor Author

I updated the condition for sys_icache_invalidate() in CodeSync.cpp.

Comment thread compiler/aarch64/runtime/CodeSync.cpp Outdated
* 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 defined (__clang__) && defined (__APPLE__)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There should not be spaces before (, here and on line 30, to be consistent, e.g. line 32.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

This commit adds changes for supporting AArch64 macOS.

Signed-off-by: KONNO Kazuhiro <konno@jp.ibm.com>

@keithc-ca keithc-ca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @knn-k.

@0xdaryl

0xdaryl commented Oct 21, 2021

Copy link
Copy Markdown
Contributor

Jenkins build all

@0xdaryl 0xdaryl self-assigned this Oct 21, 2021
@0xdaryl
0xdaryl merged commit 285f5f5 into eclipse-omr:master Oct 21, 2021
@knn-k
knn-k deleted the aarch64macos1 branch October 21, 2021 21:16
@knn-k

knn-k commented Oct 25, 2021

Copy link
Copy Markdown
Contributor Author

#6215 implements omrsignal_context.c.

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