Skip to content

Commit

Permalink
Merge pull request #3459 from nbhuiyan/nasm-windows
Browse files Browse the repository at this point in the history
Use NASM assembler on x86-64 Windows and update NASM set-up process on OSX and xLinux makefiles
  • Loading branch information
0xdaryl authored Jan 15, 2019
2 parents 0dd5b12 + bcc4976 commit 4d40830
Show file tree
Hide file tree
Showing 17 changed files with 183 additions and 94 deletions.
8 changes: 7 additions & 1 deletion doc/build-instructions/Build_Instructions_V10.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2018, 2018 IBM Corp. and others
Copyright (c) 2018, 2019 IBM Corp. and others
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -321,6 +321,12 @@ You must install a number of software dependencies to create a suitable build en
- [Microsoft Visual Studio 2013]( https://go.microsoft.com/fwlink/?LinkId=532495), which is the same compiler level used by OpenJDK. Later levels of this compiler are not supported.
- [Freemarker V2.3.8](https://sourceforge.net/projects/freemarker/files/freemarker/2.3.8/freemarker-2.3.8.tar.gz/download)
- [Freetype2 V2.3 or newer](https://www.freetype.org/)
- [NASM Assembler v2.13.03 or newer](https://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D)

Add the path to `nasm.exe` to the `PATH` environment variable to override the older version of NASM installed in Cygwin. e.g.
```
export PATH="/cygdrive/c/NASM:$PATH" (in Cygwin)
```

Update your `LIB` and `INCLUDE` environment variables to provide a path to the Windows debugging tools with the following commands:

Expand Down
8 changes: 7 additions & 1 deletion doc/build-instructions/Build_Instructions_V11.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2018, 2018 IBM Corp. and others
Copyright (c) 2018, 2019 IBM Corp. and others
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -366,12 +366,18 @@ You must install a number of software dependencies to create a suitable build en
- [Microsoft Visual Studio 2017]( https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=15), which is the default compiler level used by OpenJDK11; or [Microsoft Visual Studio 2013]( https://go.microsoft.com/fwlink/?LinkId=532495), which is chosen to compile if VS2017 isn't installed.
- [Freemarker V2.3.8](https://sourceforge.net/projects/freemarker/files/freemarker/2.3.8/freemarker-2.3.8.tar.gz/download)
- [LLVM/Clang](http://releases.llvm.org/7.0.0/LLVM-7.0.0-win64.exe)
- [NASM Assembler v2.13.03 or newer](https://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D)

Add the binary path of Clang to the `PATH` environment variable to override the older version of clang integrated in Cygwin. e.g.
```
export PATH="/cygdrive/c/LLVM/bin:$PATH" (in Cygwin)
```

Add the path to `nasm.exe` to the `PATH` environment variable to override the older version of NASM installed in Cygwin. e.g.
```
export PATH="/cygdrive/c/NASM:$PATH" (in Cygwin)
```

Update your `LIB` and `INCLUDE` environment variables to provide a path to the Windows debugging tools with the following commands:

```
Expand Down
8 changes: 7 additions & 1 deletion doc/build-instructions/Build_Instructions_V8.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2017, 2018 IBM Corp. and others
Copyright (c) 2017, 2019 IBM Corp. and others
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -356,6 +356,7 @@ OpenJ9 uses the mingw/GCC compiler during the build process. In the `Archive` ca
- [Freetype2 V2.3 or newer](https://www.freetype.org/)
- [LLVM/Clang 64bit](http://releases.llvm.org/7.0.0/LLVM-7.0.0-win64.exe)
- [LLVM/Clang 32bit](http://releases.llvm.org/7.0.0/LLVM-7.0.0-win32.exe)
- [NASM Assembler v2.13.03 or newer](https://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D)

Add the binary path of Clang to the `PATH` environment variable to override the older version of clang integrated in Cygwin. e.g.
```
Expand All @@ -364,6 +365,11 @@ or
export PATH="/cygdrive/c/LLVM_32/bin:$PATH" (in Cygwin for 32bit)
```

Add the path to `nasm.exe` to the `PATH` environment variable to override the older version of NASM installed in Cygwin. e.g.
```
export PATH="/cygdrive/c/NASM:$PATH" (in Cygwin)
```

Update your `LIB` and `INCLUDE` environment variables to provide a path to the Windows debugging tools with the following commands:

```
Expand Down
8 changes: 7 additions & 1 deletion doc/build-instructions/Build_Instructions_V9.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2017, 2018 IBM Corp. and others
Copyright (c) 2017, 2019 IBM Corp. and others
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -313,6 +313,12 @@ You must install a number of software dependencies to create a suitable build en
- [Microsoft Visual Studio 2013]( https://go.microsoft.com/fwlink/?LinkId=532495), which is the same compiler level used by OpenJDK. Later levels of this compiler are not supported.
- [Freemarker V2.3.8](https://sourceforge.net/projects/freemarker/files/freemarker/2.3.8/freemarker-2.3.8.tar.gz/download)
- [Freetype2 V2.3 or newer](https://www.freetype.org/)
- [NASM Assembler v2.13.03 or newer](https://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D)

Add the path to `nasm.exe` to the `PATH` environment variable to override the older version of NASM installed in Cygwin. e.g.
```
export PATH="/cygdrive/c/NASM:$PATH" (in Cygwin)
```

Update your `LIB` and `INCLUDE` environment variables to provide a path to the Windows debugging tools with the following commands:

Expand Down
3 changes: 3 additions & 0 deletions runtime/compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ if(OMR_ARCH_X86)
set(asm_inc_dirs
"-I${j9vm_SOURCE_DIR}/oti/"
"-I${CMAKE_CURRENT_SOURCE_DIR}/"
"-I${CMAKE_CURRENT_SOURCE_DIR}/x/runtime/"
"-I${CMAKE_CURRENT_SOURCE_DIR}/x/amd64/runtime/"
"-I${CMAKE_CURRENT_SOURCE_DIR}/x/i386/runtime/"
)
omr_append_flags(CMAKE_ASM_NASM_FLAGS ${asm_inc_dirs})
endif()
Expand Down
3 changes: 2 additions & 1 deletion runtime/compiler/build/platform/host/amd64-win64-mvs.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2000, 2017 IBM Corp. and others
# Copyright (c) 2000, 2019 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -23,3 +23,4 @@ HOST_SUBARCH=amd64
HOST_BITS=64
OS=win
TOOLCHAIN=win-msvc
NASM_ASSEMBLER=yes
18 changes: 2 additions & 16 deletions runtime/compiler/build/rules/gnu/filetypes.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2000, 2018 IBM Corp. and others
# Copyright (c) 2000, 2019 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -126,26 +126,12 @@ endef # DEF_RULE.pasm

RULE.pasm=$(eval $(DEF_RULE.pasm))

### NASM-specific rules

ifeq ($(OS),linux)
ifeq ($(HOST_BITS),32)
OBJ_FORMAT=-felf32
else
OBJ_FORMAT=-felf64
endif
endif #(OS = linux)

ifeq ($(OS),osx)
OBJ_FORMAT=-fmacho64
endif #(OS = osx)

#
# Compile .nasm file into .o file
#
define DEF_RULE.nasm
$(1): $(2) | jit_createdirs
nasm $(OBJ_FORMAT) $$(patsubst %,-D%=1,$$(S_DEFINES)) $$(patsubst %,-I'%/',$$(S_INCLUDES)) -o $$@ $$<
$$(NASM_CMD) $$(NASM_OBJ_FORMAT) $$(patsubst %,-D%=1,$$(NASM_DEFINES)) $$(patsubst %,-I'%/',$$(NASM_INCLUDES)) -o $$@ $$<

JIT_DIR_LIST+=$(dir $(1))

Expand Down
18 changes: 17 additions & 1 deletion runtime/compiler/build/rules/win-msvc/filetypes.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2000, 2017 IBM Corp. and others
# Copyright (c) 2000, 2019 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -89,6 +89,22 @@ endef # DEF_RULE.pasm

RULE.pasm=$(eval $(DEF_RULE.pasm))

#
# Compile .nasm file into .obj file
#
define DEF_RULE.nasm
$(1): $(2) | jit_createdirs
$$(NASM_CMD) $$(NASM_OBJ_FORMAT) $$(patsubst %,-D%=1,$$(NASM_DEFINES)) $$(patsubst %,-I%/,$$(subst \,/,$$(NASM_INCLUDES))) -o $$(subst \,/,"$$@") $$(subst \,/,"$$<")

JIT_DIR_LIST+=$(dir $(1))

jit_cleanobjs::
$$(call RM,$(1))

endef # DEF_RULE.nasm

RULE.nasm=$(eval $(DEF_RULE.nasm))

#
# Compile .rc file into .res file
#
Expand Down
52 changes: 51 additions & 1 deletion runtime/compiler/build/toolcfg/gnu/common.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2000, 2018 IBM Corp. and others
# Copyright (c) 2000, 2019 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -303,6 +303,56 @@ ifeq ($(HOST_ARCH),x)
PASM_FLAGS+=$(PASM_FLAGS_EXTRA)
endif

ifeq ($(HOST_ARCH),x)
#
# Setup NASM
#

NASM_CMD?=nasm

NASM_DEFINES=\
TR_HOST_X86 \
TR_TARGET_X86

ifeq ($(OS),osx)
NASM_DEFINES+=\
OSX
else
NASM_DEFINES+=\
LINUX
endif

NASM_INCLUDES=\
$(J9SRC)/oti \
$(J9SRC)/compiler \
$(J9SRC)/compiler/x/runtime

ifeq ($(HOST_BITS),32)
NASM_OBJ_FORMAT=-felf32

NASM_DEFINES+=\
TR_HOST_32BIT \
TR_TARGET_32BIT

NASM_INCLUDES+=\
$(J9SRC)/compiler/x/i386/runtime
else
ifeq ($(OS),osx)
NASM_OBJ_FORMAT=-fmacho64
else
NASM_OBJ_FORMAT=-felf64
endif

NASM_DEFINES+=\
TR_HOST_64BIT \
TR_TARGET_64BIT

NASM_INCLUDES+=\
$(J9SRC)/compiler/x/amd64/runtime
endif

endif # HOST_ARCH == x

#
# Setup CPP and SED to preprocess PowerPC Assembly Files
#
Expand Down
38 changes: 37 additions & 1 deletion runtime/compiler/build/toolcfg/win-msvc/common.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2000, 2018 IBM Corp. and others
# Copyright (c) 2000, 2019 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -208,6 +208,42 @@ endif

PASM_FLAGS+=$(PASM_FLAGS_EXTRA)

#
# Setup NASM
#

NASM_CMD?=nasm

NASM_DEFINES=\
TR_HOST_X86 \
TR_TARGET_X86 \
WINDOWS

NASM_INCLUDES=\
../oti \
../compiler \
../compiler/x/runtime

ifeq ($(HOST_BITS),32)
NASM_OBJ_FORMAT=-fwin32

NASM_DEFINES+=\
TR_HOST_32BIT \
TR_TARGET_32BIT

NASM_INCLUDES+=\
../compiler/x/i386/runtime
else
NASM_OBJ_FORMAT=-fwin64

NASM_DEFINES+=\
TR_HOST_64BIT \
TR_TARGET_64BIT

NASM_INCLUDES+=\
../compiler/x/amd64/runtime
endif

#
# Setup RC
#
Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/runtime/asmprotos.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extern "C" {
* is set for OS variants that currently use NASM and is used to
* decide the version of helper names to use.
*/
#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_X86) && defined(TR_HOST_64BIT))
#if defined(TR_HOST_X86) && defined(TR_HOST_64BIT)
#define NASM_ASSEMBLER
#endif

Expand Down
7 changes: 2 additions & 5 deletions runtime/compiler/x/amd64/runtime/AMD64CompressString.nasm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; Copyright (c) 2000, 2018 IBM Corp. and others
; Copyright (c) 2000, 2019 IBM Corp. and others
;
; This program and the accompanying materials are made available under
; the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -20,10 +20,7 @@

%ifdef TR_HOST_64BIT
%include "jilconsts.inc"

%include "x/amd64/runtime/AMD64CompressString_nasm.inc"


%include "AMD64CompressString_nasm.inc"

J9TR_ObjectColorBlack equ 03h

Expand Down
6 changes: 3 additions & 3 deletions runtime/compiler/x/runtime/X86LockReservation.nasm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; Copyright (c) 2000, 2018 IBM Corp. and others
; Copyright (c) 2000, 2019 IBM Corp. and others
;
; This program and the accompanying materials are made available under
; the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -34,10 +34,10 @@
DECLARE_GLOBAL jitMethodMonitorExitReservedPrimitive

%ifdef WINDOWS
UseFastCall equ 1
%define UseFastCall 1
%else
%ifdef TR_HOST_32BIT
UseFastCall equ 1
%define UseFastCall 1
%endif
%endif

Expand Down
8 changes: 4 additions & 4 deletions runtime/compiler/x/runtime/X86PicBuilder.nasm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; Copyright (c) 2000, 2018 IBM Corp. and others
; Copyright (c) 2000, 2019 IBM Corp. and others
;
; This program and the accompanying materials are made available under
; the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -29,7 +29,7 @@
CPU PPRO

%include "jilconsts.inc"
%include "x/runtime/X86PicBuilder_nasm.inc"
%include "X86PicBuilder_nasm.inc"

segment .text

Expand Down Expand Up @@ -1205,8 +1205,8 @@ ret ; branch will mispredict s
;
; --------------------------------------------------------------------------------

%include "jilconsts.inc"
%include "x/runtime/X86PicBuilder_nasm.inc"
%include "jilconsts.inc"
%include "X86PicBuilder_nasm.inc"

segment .text

Expand Down
6 changes: 1 addition & 5 deletions runtime/compiler/x/runtime/X86PicBuilder_nasm.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; Copyright (c) 2000, 2018 IBM Corp. and others
; Copyright (c) 2000, 2019 IBM Corp. and others
;
; This program and the accompanying materials are made available under
; the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -106,11 +106,7 @@ eq_IPicData_j2iThunk equ 22h ; only present if direct invoke is pos
; It's omitted here since it would be unused anyway.

%macro LoadHelperIndex 2 ; args: targetReg, helperIndexSym
%ifdef WINDOWS
mov %1, dword [%2]
%else
mov %1, dword [rel + %2]
%endif
%endmacro


Expand Down
4 changes: 2 additions & 2 deletions runtime/compiler/x/runtime/X86Unresolveds.nasm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
eq_offsetof_J9Object_clazz equ 8 ; offset of class pointer in a J9Object

%include "jilconsts.inc"
%include "x/runtime/X86PicBuilder_nasm.inc"
%include "X86PicBuilder_nasm.inc"

segment .text

Expand Down Expand Up @@ -1095,7 +1095,7 @@ retn


%include "jilconsts.inc"
%include "x/runtime/X86PicBuilder_nasm.inc"
%include "X86PicBuilder_nasm.inc"

%ifdef ASM_J9VM_INTERP_COMPRESSED_OBJECT_HEADER
eq_offsetof_J9Object_clazz equ 8 ; offset of class pointer in a J9Object
Expand Down
Loading

0 comments on commit 4d40830

Please sign in to comment.