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

Loongarch: Add Loongarch port #1406

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.xml
Expand Up @@ -529,6 +529,8 @@ com/sun/jna/linux-mips64el/libjnidispatch.so;
processor=mips64el;osname=linux,
com/sun/jna/linux-s390x/libjnidispatch.so;
processor=S390x;osname=linux,
com/sun/jna/linux-loongarch64/libjnidispatch.so;
processor=loongarch64;osname=linux,

com/sun/jna/freebsd-x86/libjnidispatch.so;
processor=x86;osname=freebsd,
Expand Down Expand Up @@ -638,6 +640,9 @@ osname=macosx;processor=aarch64
<zipfileset src="${lib.native}/linux-mips64el.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-mips64el"/>
<zipfileset src="${lib.native}/linux-loongarch64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-loongarch64"/>
<zipfileset src="${lib.native}/linux-s390x.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-s390x"/>
Expand Down Expand Up @@ -851,6 +856,7 @@ osname=macosx;processor=aarch64
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-ppc64le.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-sparcv9.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-mips64el.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-loongarch64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-s390x.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-riscv64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-x86.jar" overwrite="true"/>
Expand Down
12 changes: 12 additions & 0 deletions native/Makefile
Expand Up @@ -111,6 +111,18 @@ endif
STRIP=strip -x
# end defaults


OS_PLATFORM = $(shell uname -m)
ifeq ($(OS_PLATFORM), mips64)
LDFLAGS += -Wl,-z,noexecstack
endif

OS_PLATFORM = $(shell uname -m)
ifeq ($(OS_PLATFORM), loongarch64)
LDFLAGS += -Wl,-z,noexecstack
endif
Copy link
Member

Choose a reason for hiding this comment

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

This look broken as for example android and at least windows aarch64 are crossbuild, so the local platform should not affect the build. Also the other architectures have no similar treatment and mips64 should not even be touched, as this is targetted for loongarch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This look broken as for example android and at least windows aarch64 are crossbuild, so the local platform should not affect the build. Also the other architectures have no similar treatment and mips64 should not even be touched, as this is targetted for loongarch.

My fault. I will revise it



# Android build (cross-compile) requires the android NDK.
# Ensure the following tools are in your path and adjust NDK_PLATFORM as needed
ifeq ($(OS),android)
Expand Down
4 changes: 3 additions & 1 deletion native/libffi/Makefile.am
Expand Up @@ -51,6 +51,7 @@ noinst_HEADERS = src/aarch64/ffitarget.h src/aarch64/internal.h \
src/avr32/ffitarget.h src/bfin/ffitarget.h \
src/cris/ffitarget.h src/csky/ffitarget.h src/frv/ffitarget.h \
src/ia64/ffitarget.h src/ia64/ia64_flags.h \
src/loongarch/ffitarget.h \
src/m32r/ffitarget.h src/m68k/ffitarget.h \
src/m88k/ffitarget.h src/metag/ffitarget.h \
src/microblaze/ffitarget.h src/mips/ffitarget.h \
Expand All @@ -72,7 +73,8 @@ EXTRA_libffi_la_SOURCES = src/aarch64/ffi.c src/aarch64/sysv.S \
src/avr32/ffi.c src/avr32/sysv.S src/bfin/ffi.c \
src/bfin/sysv.S src/cris/ffi.c src/cris/sysv.S src/frv/ffi.c \
src/csky/ffi.c src/csky/sysv.S src/frv/eabi.S src/ia64/ffi.c \
src/ia64/unix.S src/m32r/ffi.c src/m32r/sysv.S src/m68k/ffi.c \
src/ia64/unix.S src/loongarch/ffi.c src/loongarch/sysv.S \
src/m32r/ffi.c src/m32r/sysv.S src/m68k/ffi.c \
src/m68k/sysv.S src/m88k/ffi.c src/m88k/obsd.S \
src/metag/ffi.c src/metag/sysv.S src/microblaze/ffi.c \
src/microblaze/sysv.S src/mips/ffi.c src/mips/o32.S \
Expand Down
3 changes: 3 additions & 0 deletions native/libffi/config.guess
Expand Up @@ -985,6 +985,9 @@ EOF
k1om:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
loongarch32:Linux:*:* | loongarch64:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
m32r*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
Expand Down
1 change: 1 addition & 0 deletions native/libffi/config.sub
Expand Up @@ -1185,6 +1185,7 @@ case $cpu-$vendor in
| k1om \
| le32 | le64 \
| lm32 \
| loongarch32 | loongarch64 \
| m32c | m32r | m32rle \
| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
Expand Down
5 changes: 5 additions & 0 deletions native/libffi/configure.host
Expand Up @@ -140,6 +140,11 @@ case "${host}" in
SOURCES="ffi.c sysv.S"
;;

loongarch64-*-*)
TARGET=LOONGARCH; TARGETDIR=loongarch
SOURCES="ffi.c sysv.S"
;;

m32r*-*-*)
TARGET=M32R; TARGETDIR=m32r
SOURCES="ffi.c sysv.S"
Expand Down