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

Add support for compiling natives on macOS arm64 #458

Merged
merged 4 commits into from
Sep 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion openjdk.test.jck/src/native/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@
# Figure out current platform
###
OS:=$(shell uname -s | tr "[:upper:]" "[:lower:]")
ARCH:=$(shell uname -m | tr "[:upper:]" "[:lower:]")

ifneq (,$(findstring cygwin,$(OS)))
OS:=win
endif

ifneq (,$(findstring darwin,$(OS)))
OS:=osx
# Detect a M1 processor. Needed because uname -m doesn't work when the shell runs in x86_64 emulation
ARCH:=$(shell sysctl -n machdep.cpu.brand_string)
ifeq ($(ARCH),Apple M1)
ARCH:=arm64
endif
endif

ifeq ($(OS),os/390)
Expand All @@ -44,6 +50,7 @@ ifneq (,$(findstring win,$(OS)))
endif

$(info OS is $(OS))
$(info ARCH is $(ARCH))

ifeq ($(OS),win)
DESTDIR=$(OUTDIR)\$(OS)
Expand Down Expand Up @@ -145,7 +152,11 @@ LDFLAGS=-shared

ifeq ($(OS),osx)
CC=gcc
CFLAGS=-fPIC -I$(OSX_PATH) -I$(SRC_PATH)
ifeq ($(ARCH),arm64)
CFLAGS=-arch arm64 -fPIC -I$(OSX_PATH) -I$(SRC_PATH)
else
CFLAGS=-fPIC -I$(OSX_PATH) -I$(SRC_PATH)
endif
LDFLAGS=-shared
endif

Expand Down