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 win32-aarch64 support #1264

Merged
merged 9 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Next Release (5.7.0)

Features
--------
* [#1264](https://github.com/java-native-access/jna/pull/1264): Update libffi to v3.3; Add Windows `aarch64` target. - [@tresf](https://github.com/tresf).
* [#1217](https://github.com/java-native-access/jna/pull/1217): Add mappings for AIX `Perfstat` library to `c.s.j.p.unix.aix` - [@dbwiddis](https://github.com/dbwiddis).
* [#1231](https://github.com/java-native-access/jna/pull/1231): The test suite can now be executed on Windows using either ANSI or UNICODE win32 API by passing `-Dw32.ascii=true/false` to ant. Previously, UNICODE was always used. - [@T-Svensson](https://github.com/T-Svensson/)
* [#1237](https://github.com/java-native-access/jna/pull/1237): *Experimental:* Add artifacts that make jna and jna-platform named modules (provide `module-info.class`). The new artifacts are named `jna-jpms.jar` and `jna-platform-jpms.jar` - [@matthiasblaesing](https://github.com/matthiasblaesing).
Expand Down
82 changes: 67 additions & 15 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,72 @@
version: 1.0.{build}
image: Visual Studio 2015

# speed up cloning
shallow_clone: true
clone_depth: 10

environment:
matrix:
- TARGET_ARCH: x86_64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CYGWIN_PACKAGES: git,make,automake,libtool,mingw64-x86_64-gcc-g++,mingw64-x86_64-gcc-core
CHOCO_PACKAGES: ant cygwin
CYGWIN_SETUP: cygwinsetup.exe # from choco
JAVA_HOME: C:\Program Files\Java\jdk1.8.0

- TARGET_ARCH: x86
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CYGWIN_PACKAGES: git,make,automake,libtool,mingw64-i686-gcc-g++,mingw64-i686-gcc-core
CHOCO_PACKAGES: ant cygwin
CYGWIN_SETUP: cygwinsetup.exe # from choco
JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0 # 32-bit

- TARGET_ARCH: aarch64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 # provides cygwin, mingw
CYGWIN_PACKAGES: make,automake,libtool
CHOCO_PACKAGES: ant
CYGWIN_SETUP: setup-x86_64.exe # from appveyor
JAVA_HOME: C:\Program Files\Java\jdk1.8.0

install:
- cmd: set PATH=%PATH%;c:\cygwin64;c:\cygwin64\bin
- cmd: choco install -y -f -i ant
- cmd: choco install -y -f -i cygwin
- cmd: C:\cygwin64\cygwinsetup.exe --root C:\cygwin64 --local-package-dir C:\cygwin64\packages --quiet-mode --no-desktop --no-startmenu --packages git,make,automake,automake1.15,libtool,mingw64-x86_64-gcc-g++,mingw64-x86_64-gcc-core,gcc-g++
- cmd: set JAVA_HOME=C:\Program Files\Java\jdk1.8.0
- cmd: set PATH=%JAVA_HOME%\bin;%PATH%
- cmd: set PATH=c:\cygwin64;c:\cygwin64\bin;%PATH%
- cmd: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64'
# Must prepend cygwin PATH to avoid "cygheap base mismatch" from Git\usr\bin\sed
- cmd: set PATH=C:\cygwin64;C:\cygwin64\bin;%JAVA_HOME%\bin;%PATH%;
- cmd: choco install -y -f -i %CHOCO_PACKAGES%
- cmd: '%CYGWIN_SETUP% --root C:\cygwin64 --local-package-dir C:\cygwin64\packages --quiet-mode --no-desktop --no-startmenu --packages %CYGWIN_PACKAGES%'

build_script:
- cmd: ant dist
# Setup msvc environment
for:
- # VS 2015: x64
matrix:
only:
- TARGET_ARCH: x86_64
before_build:
- cmd: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64'
before_test:
- cmd: net start spooler
test_script:
- cmd: ant test
- cmd: ant test-platform

- # VS 2015: x86
matrix:
only:
- TARGET_ARCH: x86
before_build:
- cmd: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86'
before_test:
- cmd: net start spooler
test_script:
- cmd: ant test
- cmd: ant test-platform

test_script:
- cmd: net start spooler
- cmd: ant test
- cmd: ant test-platform
- # VS 2019: aarch64
matrix:
only:
- TARGET_ARCH: aarch64
before_build:
- cmd: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64_arm64'
test_script:
- cmd: echo Skipping tests

build_script:
- cmd: ant -Dos.prefix=win32-%TARGET_ARCH% dist
11 changes: 9 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ com/sun/jna/win32-x86/jnidispatch.dll;
processor=x86;osname=win,
com/sun/jna/win32-x86-64/jnidispatch.dll;
processor=x86-64;osname=win,
com/sun/jna/win32-aarch64/jnidispatch.dll;
processor=aarch64;osname=win,
com/sun/jna/w32ce-arm/jnidispatch.dll;
processor=arm;osname=wince,

Expand Down Expand Up @@ -627,6 +629,9 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<zipfileset src="${lib.native}/win32-x86-64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/win32-x86-64"/>
<zipfileset src="${lib.native}/win32-aarch64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/win32-aarch64"/>
<zipfileset src="${lib.native}/w32ce-arm.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/w32ce-arm"/>
Expand Down Expand Up @@ -744,7 +749,8 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
</condition>
<!-- args are based on GNU grep, other versions may differ -->
<apply dir="${build.headers}" executable="${grep}" parallel="true"
failonerror="${grep.required}" relative="true" output="${md5.file}">
failonerror="${grep.required}" relative="true" output="${md5.file}"
error="${md5.file}.error">
<arg value="-A"/>
<arg value="1"/>
<arg value="JNIEXPORT"/>
Expand Down Expand Up @@ -784,6 +790,7 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/darwin.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/win32-x86.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/win32-x86-64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/win32-aarch64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/w32ce-arm.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-x86.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-x86-64.jar" overwrite="true"/>
Expand Down Expand Up @@ -876,7 +883,7 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<equals arg1="${os.prefix}" arg2="android-armv7"/>
</condition>
<condition property="ARCH" value="aarch64">
<equals arg1="${os.prefix}" arg2="android-aarch64"/>
<matches string="${os.prefix}" pattern="-aarch64$"/>
tresf marked this conversation as resolved.
Show resolved Hide resolved
</condition>
<condition property="ARCH" value="x86">
<equals arg1="${os.prefix}" arg2="android-x86"/>
Expand Down
Binary file added lib/native/win32-aarch64.jar
Binary file not shown.
19 changes: 16 additions & 3 deletions native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
# Supported platforms (built and tested):
#
# Windows 2000/XP/2003/Vista (x86/amd64)
# Windows (x86/amd64/aarch64)
# Windows CE/Mobile (arm)
# Darwin/OS X (i386/x86_64/ppc)
# Linux (i386/amd64/ppc/arm)
Expand Down Expand Up @@ -246,8 +246,21 @@ LIBS=psapi.lib
ARSFX=.lib
ifeq ($(ARCH),amd64)
CC+= -m64
endif
FFI_CONFIG+= && rm -f include/ffitarget.h && cp $(FFI_SRC)/include/*.h $(FFI_SRC)/src/x86/ffitarget.h include
FFI_TARGET=$(FFI_SRC)/src/x86/ffitarget.h
else ifeq ($(ARCH),aarch64)
# Force $(CC) fallback; avoid arch mismatch
WINDRES=false
# Disable mingw; no aarch64 support
MINGW=
FFI_CONFIG+=--host=aarch64-cygwin
# Skip building assembly callback functions
CDEFINES+= -DASMFN_OFF
DLLCB=
tresf marked this conversation as resolved.
Show resolved Hide resolved
CC+= -marm64
FFI_CONFIG+=--host=aarch64-cygwin
endif
FFI_TARGET?=$(FFI_SRC)/src/$(ARCH)/ffitarget.h
FFI_CONFIG+= && rm -f include/ffitarget.h && cp $(FFI_SRC)/include/*.h $(FFI_TARGET) include
FFI_ENV+=LD="$(LD)" CPP="$(CPP)" CXXCPP="$(CPP)"
EXTRAOBJS+=$(DLLCB)

Expand Down
2 changes: 1 addition & 1 deletion native/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
<equals arg1="${os.prefix}" arg2="android-armv7"/>
</condition>
<condition property="ARCH" value="aarch64">
<equals arg1="${os.prefix}" arg2="android-aarch64"/>
<matches string="${os.prefix}" pattern="-aarch64$"/>
</condition>
<condition property="ARCH" value="x86">
<equals arg1="${os.prefix}" arg2="android-x86"/>
Expand Down
4 changes: 2 additions & 2 deletions native/callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
extern "C" {
#endif

#if defined(_WIN32) && !defined(_WIN32_WCE)
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(ASMFN_OFF)
#include "com_sun_jna_win32_DLLCallback.h"
#ifdef _WIN64
#ifdef _MSC_VER
Expand Down Expand Up @@ -313,7 +313,6 @@ create_callback(JNIEnv* env, jobject obj, jobject method,
}
void
free_callback(JNIEnv* env, callback *cb) {
int i;
(*env)->DeleteWeakGlobalRef(env, cb->object);
ffi_closure_free(cb->closure);
free(cb->arg_types);
Expand All @@ -332,6 +331,7 @@ free_callback(JNIEnv* env, callback *cb) {
}
free(cb->arg_jtypes);
#ifdef DLL_FPTRS
int i;
for (i=0;i < DLL_FPTRS;i++) {
if (fn[i] == cb->saved_x_closure) {
fn[i] = NULL;
Expand Down
66 changes: 66 additions & 0 deletions native/libffi/.appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
shallow_clone: true

# We're currently only testing libffi built with Microsoft's
# tools.
# This matrix should be expanded to include at least:
# 32- and 64-bit gcc/cygwin
# 32- and 64-bit gcc/mingw
# 32- and 64-bit clang/mingw
# and perhaps more.

image: Visual Studio 2017
platform:
- x64
- x86
- arm
- arm64

environment:
global:
CYG_ROOT: C:/cygwin
CYG_CACHE: C:/cygwin/var/cache/setup
CYG_MIRROR: http://mirrors.kernel.org/sourceware/cygwin/
matrix:
- VSVER: 15

install:
- ps: >-
If ($env:Platform -Match "x86") {
$env:VCVARS_PLATFORM="x86"
$env:BUILD="i686-pc-cygwin"
$env:HOST="i686-pc-cygwin"
$env:MSVCC="/cygdrive/c/projects/libffi/msvcc.sh"
$env:SRC_ARCHITECTURE="x86"
} ElseIf ($env:Platform -Match "arm64") {
$env:VCVARS_PLATFORM="x86_arm64"
$env:BUILD="i686-pc-cygwin"
$env:HOST="aarch64-w64-cygwin"
$env:MSVCC="/cygdrive/c/projects/libffi/msvcc.sh -marm64"
$env:SRC_ARCHITECTURE="aarch64"
} ElseIf ($env:Platform -Match "arm") {
$env:VCVARS_PLATFORM="x86_arm"
$env:BUILD="i686-pc-cygwin"
$env:HOST="arm-w32-cygwin"
$env:MSVCC="/cygdrive/c/projects/libffi/msvcc.sh -marm"
$env:SRC_ARCHITECTURE="arm"
} Else {
$env:VCVARS_PLATFORM="amd64"
$env:BUILD="x86_64-w64-cygwin"
$env:HOST="x86_64-w64-cygwin"
$env:MSVCC="/cygdrive/c/projects/libffi/msvcc.sh -m64"
$env:SRC_ARCHITECTURE="x86"
}
- 'appveyor DownloadFile https://cygwin.com/setup-x86.exe -FileName setup.exe'
- 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu >NUL'
- '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"'
- echo call VsDevCmd to set VS150COMNTOOLS
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
- ps: $env:VSCOMNTOOLS=(Get-Content ("env:VS" + "$env:VSVER" + "0COMNTOOLS"))
- echo "Using Visual Studio %VSVER%.0 at %VSCOMNTOOLS%"
- call "%VSCOMNTOOLS%..\..\vc\Auxiliary\Build\vcvarsall.bat" %VCVARS_PLATFORM%

build_script:
- c:\cygwin\bin\sh -lc "(cd $OLDPWD; ./autogen.sh;)"
- c:\cygwin\bin\sh -lc "(cd $OLDPWD; ./configure CC='%MSVCC%' CXX='%MSVCC%' LD='link' CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' AR='/cygdrive/c/projects/libffi/.travis/ar-lib lib' NM='dumpbin -symbols' STRIP=':' --build=$BUILD --host=$HOST;)"
- c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp src/%SRC_ARCHITECTURE%/ffitarget.h include; make; find .;)"
- c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp `find . -name 'libffi-?.dll'` $HOST/testsuite/; make check; cat `find ./ -name libffi.log`)"
4 changes: 4 additions & 0 deletions native/libffi/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto

*.sln text eol=crlf
*.vcxproj* text eol=crlf
10 changes: 10 additions & 0 deletions native/libffi/.github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## System Details

<!--- What platform are you working with? eg. the output of config.guess -->
<!--- Provide any toolchain details here. eg. compiler version -->

## Problems Description

<!--- Provide a description of the problem here -->
<!--- If this is a configure-time problem, attach config.log -->
<!--- If this is a testsuite problem, attach the relevant log output -->
6 changes: 4 additions & 2 deletions native/libffi/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
.dirstamp
*.la
Makefile
!testsuite/libffi.bhaible/Makefile
Makefile.in
aclocal.m4
compile
config.*
!.travis/compile
configure
depcomp
doc/libffi.info
Expand All @@ -20,7 +21,6 @@ include/ffitarget.h
install-sh
libffi.pc
libtool
libtool-ldflags
ltmain.sh
m4/libtool.m4
m4/lt*.m4
Expand All @@ -33,3 +33,5 @@ libffi.xcodeproj/xcuserdata
libffi.xcodeproj/project.xcworkspace
build_*/
darwin_*/
src/arm/trampoline.S
**/texinfo.tex
Loading