Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,23 +326,21 @@ jobs:
${{ env.WINDOWS_BUILD_FOLDER }}/hl.exe --version
;;
make*)
if [[ ${{ matrix.architecture }} != arm64 ]]; then
./hl --version
case ${{ matrix.target }} in
linux) ldd -v ./hl ;;
darwin) otool -L ./hl ;;
esac

haxe -hl hello.hl -cp other/tests -main HelloWorld -D interp \
${{ matrix.architecture == 32 && '-D hl-legacy32' || '' }}
./hl hello.hl

# ensure the executable still works when installed globally
cp hello.hl /tmp
pushd /tmp
hl hello.hl
popd
fi
./hl --version
case ${{ matrix.target }} in
linux) ldd -v ./hl ;;
darwin) otool -L ./hl ;;
esac

haxe -hl hello.hl -cp other/tests -main HelloWorld -D interp \
${{ matrix.architecture == 32 && '-D hl-legacy32' || '' }}
./hl hello.hl

# ensure the executable still works when installed globally
cp hello.hl /tmp
pushd /tmp
hl hello.hl
popd

haxe -hl src/_main.c -cp other/tests -main HelloWorld
make hlc
Expand Down Expand Up @@ -431,9 +429,6 @@ jobs:
os: [darwin, linux, windows]
architecture: [x86_32, x86_64, arm64]
include:
- architecture: arm64
test-flags: --skip-hl-jit # not yet supported

- architecture: x86_32
test-flags: --skip-hl-jit # not stable

Expand Down Expand Up @@ -492,12 +487,7 @@ jobs:
tar -xvzf hashlink-*.tar.gz
cd $(echo hashlink-*/)
sudo mkdir -p /usr/local/{bin,lib}
if [[ "${{ matrix.architecture }}" == "arm64" ]]; then
echo "echo Jit is not supported on arm64" > /usr/local/bin/hl
chmod +x /usr/local/bin/hl
else
sudo cp hl /usr/local/bin/
fi
sudo cp hl /usr/local/bin/
sudo cp libhl.* *.hdll /usr/local/lib/

- name: Install binary (Windows)
Expand Down
30 changes: 23 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ include(GNUInstallDirs)
include(FindPkgConfig)
include(CTest)

set(WITH_VM_DEFAULT ON)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64" AND (NOT CMAKE_OSX_ARCHITECTURES MATCHES "x86_64"))
set(WITH_VM_DEFAULT OFF)
endif()

option(WITH_VM "Whether to build the Hashlink virtual machine" ${WITH_VM_DEFAULT})
option(WITH_VM "Whether to build the Hashlink virtual machine" ON)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
if(BUILD_SHARED_LIBS)
# ensure third-party static libs are built with PIC
Expand Down Expand Up @@ -59,6 +54,10 @@ if (MINGW)
add_link_options(-municode)
endif()

if(NOT MSVC)
add_compile_options(-fno-omit-frame-pointer)
endif()

list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/other/cmake
)
Expand Down Expand Up @@ -224,9 +223,24 @@ else()
endif()

if (WITH_VM)
# Select JIT backend based on target architecture
# On macOS, CMAKE_OSX_ARCHITECTURES overrides CMAKE_SYSTEM_PROCESSOR for cross-compilation
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64" AND NOT CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
set(JIT_SOURCES
src/jit_aarch64.c
src/jit_aarch64_emit.c
src/jit_common.c
)
else()
set(JIT_SOURCES
src/jit_x86.c
src/jit_common.c
)
endif()

add_executable(hl
src/code.c
src/jit.c
${JIT_SOURCES}
src/main.c
src/module.c
src/debugger.c
Expand All @@ -246,6 +260,8 @@ if (WITH_VM)

if (WIN32)
target_link_libraries(hl user32)
else()
target_link_libraries(hl dl)
endif()
endif()

Expand Down
21 changes: 8 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ STD = src/std/array.o src/std/buffer.o src/std/bytes.o src/std/cast.o src/std/da
src/std/socket.o src/std/string.o src/std/sys.o src/std/types.o src/std/ucs2.o src/std/thread.o src/std/process.o \
src/std/track.o

HL_OBJ = src/code.o src/jit.o src/main.o src/module.o src/debugger.o src/profile.o
ifneq (,$(filter aarch64 arm64,$(ARCH)))
HL_JIT = src/jit_aarch64.o src/jit_aarch64_emit.o src/jit_common.o
else
HL_JIT = src/jit_x86.o src/jit_common.o
endif

HL_OBJ = src/code.o $(HL_JIT) src/main.o src/module.o src/debugger.o src/profile.o

FMT_CPPFLAGS = -I include/mikktspace -I include/minimp3

Expand Down Expand Up @@ -239,19 +245,12 @@ LIBHL = libhl.$(LIBEXT)
HL = hl$(EXE_SUFFIX)
HLC = hlc$(EXE_SUFFIX)

all: $(LIBHL) libs
ifeq ($(ARCH),arm64)
$(warning HashLink vm is not supported on arm64, skipping)
else
all: $(HL)
endif
all: $(LIBHL) libs $(HL)

install:
$(UNAME)==Darwin && ${MAKE} uninstall
ifneq ($(ARCH),arm64)
mkdir -p $(INSTALL_BIN_DIR)
cp $(HL) $(INSTALL_BIN_DIR)
endif
mkdir -p $(INSTALL_LIB_DIR)
cp *.hdll $(INSTALL_LIB_DIR)
cp $(LIBHL) $(INSTALL_LIB_DIR)
Expand Down Expand Up @@ -362,11 +361,7 @@ release_win:
rm -rf $(PACKAGE_NAME)

release_linux release_osx:
ifeq ($(ARCH),arm64)
cp $(LIBHL) *.hdll $(PACKAGE_NAME)
else
cp $(HL) $(LIBHL) *.hdll $(PACKAGE_NAME)
endif
tar -cvzf $(PACKAGE_NAME).tar.gz $(PACKAGE_NAME)
rm -rf $(PACKAGE_NAME)

Expand Down
4 changes: 3 additions & 1 deletion hl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@
<ItemGroup>
<ClCompile Include="src\code.c" />
<ClCompile Include="src\debugger.c" />
<ClCompile Include="src\jit.c" />
<ClCompile Include="src\jit_x86.c" />
<ClCompile Include="src\jit_common.c" />
<ClCompile Include="src\main.c" />
<ClCompile Include="src\module.c" />
<ClCompile Include="src\profile.c" />
Expand All @@ -369,6 +370,7 @@
<ClInclude Include="src\hl.h" />
<ClInclude Include="src\hlmodule.h" />
<ClInclude Include="src\hlsystem.h" />
<ClInclude Include="src\jit_common.h" />
<ClInclude Include="src\opcodes.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
4 changes: 3 additions & 1 deletion hl.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<ClCompile Include="src\main.c" />
<ClCompile Include="src\code.c" />
<ClCompile Include="src\module.c" />
<ClCompile Include="src\jit.c" />
<ClCompile Include="src\jit_x86.c" />
<ClCompile Include="src\jit_common.c" />
<ClCompile Include="src\debugger.c" />
<ClCompile Include="src\profile.c" />
</ItemGroup>
Expand All @@ -13,5 +14,6 @@
<ClInclude Include="src\opcodes.h" />
<ClInclude Include="src\hl.h" />
<ClInclude Include="src\hlsystem.h" />
<ClInclude Include="src\jit_common.h" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions other/osx/entitlements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
<dict>
<key>com.apple.security.get-task-allow</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
</dict>
</plist>
4 changes: 4 additions & 0 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,10 @@ HL_PRIM void *hl_alloc_executable_memory( int size ) {
return malloc(size);
#elif defined(HL_CONSOLE)
return NULL;
#elif defined(__APPLE__) && defined(__aarch64__)
void *p;
p = mmap(NULL,size,PROT_READ|PROT_WRITE|PROT_EXEC,(MAP_PRIVATE|MAP_ANONYMOUS|MAP_JIT),-1,0);
return p;
#else
void *p;
p = mmap(NULL,size,PROT_READ|PROT_WRITE|PROT_EXEC,(MAP_PRIVATE|MAP_ANONYMOUS),-1,0);
Expand Down
2 changes: 1 addition & 1 deletion src/hl.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
# define HL_BSD
#endif

#if defined(_64BITS) || defined(__x86_64__) || defined(_M_X64) || defined(__LP64__) || defined(__wasm64__)
#if defined(_64BITS) || defined(__x86_64__) || defined(_M_X64) || defined(__LP64__) || defined(__wasm64__) || defined(__aarch64__)
# define HL_64
#endif

Expand Down
Loading
Loading