Giter Site home page Giter Site logo

haxefoundation / hashlink Goto Github PK

View Code? Open in Web Editor NEW
793.0 45.0 149.0 7.42 MB

A virtual machine for Haxe

Home Page: https://hashlink.haxe.org/

License: MIT License

C 66.15% Haxe 24.72% Makefile 0.76% C++ 4.33% CMake 3.85% Objective-C 0.17% Batchfile 0.01% Ruby 0.02%
virtual-machine interpreter haxe

hashlink's Introduction

HashLink

HashLink

Build Status Build Status

HashLink is a virtual machine for Haxe https://hashlink.haxe.org

Building on Linux/OSX

HashLink is distributed with some graphics libraries allowing to develop various applications, you can manually disable the libraries you want to compile in Makefile. Here's the dependencies that you install in order to compile all the libraries:

  • fmt: libpng-dev libturbojpeg-dev libvorbis-dev
  • openal: libopenal-dev
  • sdl: libsdl2-dev
  • ssl: libmbedtls-dev
  • uv: libuv1-dev
  • sqlite: libsqlite3-dev

To install all dependencies on the latest Ubuntu, for example:

sudo apt-get install libpng-dev libturbojpeg-dev libvorbis-dev libopenal-dev libsdl2-dev libmbedtls-dev libuv1-dev libsqlite3-dev

For 16.04, see this note.

To install all dependencies on the latest Fedora, for example:

sudo dnf install libpng-devel turbojpeg-devel libvorbis-devel openal-soft-devel SDL2-devel mesa-libGLU-devel mbedtls-devel libuv-devel sqlite-devel

And on OSX:

brew bundle to install the dependencies listed in Brewfile.

Once dependencies are installed you can simply call:

make

To be able to use hashlink binary with the debugger you can then call:

sudo make codesign_osx

To install hashlink binaries on your system you can then call:

make install

Building on Windows

Open hl.sln using Visual Studio C++ and compile.

To build all of HashLink libraries it is required to download several additional distributions, read each library README file (in hashlink/libs/xxx/README.md) for additional information.

Debugging

You can debug Haxe/HashLink applications by using the Visual Studio Code Debugger

Documentation

Read the Documentation on the HashLink wiki.

hashlink's People

Contributors

andyli avatar apprentice-alchemist avatar aurel300 avatar azrou avatar clementlandrin avatar constnw avatar gama11 avatar jaimemf avatar josuigoa avatar klabz avatar mcapdegelle avatar nadako avatar ncannasse avatar nspitko avatar onehundredfeet avatar pperidont avatar qkdreyer avatar rcstuber avatar sebthom avatar shakesoda avatar simn avatar somerandev avatar speedphoenix avatar spiratom avatar tobil4sk avatar tong avatar tothbenoit avatar trethaller avatar yanrishatum avatar yuxiaomao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hashlink's Issues

release hlsdl on haxelib

I had hard time finding hlsdl lib, its somewhere in this repo under a different folder names which doesnt make it easy to use. Maybe it is a good idea to:

  • put it in a separate repository
  • release it on haxelib

Libs for HL

Hi @ncannasse!

I would like to port libs from neko to hl.

If you dont mind i will take care about mysql and sqlite libs.

Unsafe cast Assert

An "Assert" is thrown when I compile this code in debug:

class A implements hxbit.Serializable {
	@:s public var weights : Map<Int, Float>;

	public function new(){}
}

class Main  { 
	static function main() 	{
		var a = new A();
		a.weights = [0 => -1];  // works if initialized with [0 => -1.0]

		var s = new hxbit.Serializer();
		s.beginSave();
		s.addKnownRef(a);
	}
}

cmake on mac

Was hoping to try some SDL or Heaps with HL, not tried using it in a while, but seems mac target is still quite unstable on Sierra atleast, used Haxe nightly, details below.

After installing dependancies either with macport +universal or brew --universal
I tried both and making, but I don't think the make file paths for libjpeg-turbo reflect correct for macports folders on Sierra it was local/opt rather than opt/local ?, and brew did not seem to have complete 32bit set ( 64bit png stuff only? ) so no success ( have maked terminal hl in past but that's very limited hoping to try some graphics ).

make all ARCH=32

Then realized that Andy has travis working so I tried the cmake files which I presume he added, from outside the git clone recursive I ran the cmake code that seemed to work without any effort, but I am not completely sure what was included in the HashLink hl file and if it was 64 or 32.

> cmake hashlink
-- The C compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found SDL2: /usr/local/lib/libSDL2main.a;/usr/local/lib/libSDL2.dylib;-framework Cocoa  
-- Found OpenGL: /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenGL.framework  
-- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.11") 
-- Found PNG: /usr/local/lib/libpng.dylib (found version "1.4.12") 
-- Performing Test TURBOJPEG_WORKS
-- Performing Test TURBOJPEG_WORKS - Success
-- Found TurboJPEG: /opt/local/lib/libturbojpeg.dylib  
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/lib/haxelib/hashlink

However when trying just a simple hello world it gives me error.

class Main {
    static function main() {
        new Main();
    }
    public function new(){
        trace("Hello World!");
    }
}
-cp src
-hl output.hl 
-main Main
--next
-cmd /usr/local/lib/haxelib/hashlink/git/hl output.hl
> haxe compile.hxml
src/module.c(274) : FATAL ERROR : Failed to load function std@breakpoint
Error: Command failed with error 1

using -hl output.c it generated code but did not create app.

// Generated by HLC 3.4.1 (HL v1)
#include <hl/code.h>
#include <hlc_main.c>

#ifndef HL_MAKE
#  include <hl/hashes.c>
#  include <hl/functions.c>
#  include <haxe/ds/ArraySort.c>
#  include <_std/Type.c>
#  include <_std/Sys.c>
#  include <hl/_Bytes/Bytes_Impl_.c>
#  include <_std/Std.c>
#  include <hl/types/ArrayDynIterator.c>
#  include <hl/types/BytesIterator_hl_UI16.c>
#  include <hl/types/BytesIterator_Single.c>
#  include <hl/types/BytesIterator_Int.c>
#  include <hl/types/BytesIterator_Float.c>
#  include <hl/types/ArrayObj.c>
#  include <hl/NativeArrayIterator_Int.c>
#  include <hl/NativeArrayIterator_Dynamic.c>
#  include <hl/NativeArrayIterator.c>
#  include <haxe/io/Eof.c>
#  include <_std/SysError.c>
#  include <_std/StringBuf.c>
#  include <hl/types/ArrayDyn.c>
#  include <haxe/Log.c>
#  include <hl/types/ArrayBytes_Float.c>
#  include <hl/types/ArrayBytes_Single.c>
#  include <hl/types/ArrayBytes_hl_UI16.c>
#  include <hl/types/ArrayBytes_Int.c>
#  include <hl/types/ArrayBase.c>
#  include <hl/types/ArrayAccess.c>
#  include <_std/Main.c>
#  include <_std/Date.c>
#  include <_std/String.c>
#  include <hl/BaseType.c>
#  include <hl/reflect.c>
#  include <hl/types.c>
#  include <hl/globals.c>
#endif

void hl_init_hashes();

// Entry point
void hl_entry_point() {
	hl_module_context ctx;
	hl_alloc_init(&ctx.alloc);
	ctx.functions_ptrs = hl_functions_ptrs;
	ctx.functions_types = hl_functions_types;
	hl_init_types(&ctx);
	hl_init_hashes();
	hl_init_roots();
	fun$334();
}
{
	"version" : 3401,
	"libs" : ["std"],
	"defines" : {
		"true" : "1",
		"sys" : "1",
		"source-header" : "Generated by Haxe 3.4.1",
		"hl" : "1",
		"haxe_ver" : "3.401",
		"haxe3" : "1",
		"dce" : "std"
	},
	"files" : [
		"output.c",
		"hl/hashes.c",
		"hl/functions.c",
		"haxe/ds/ArraySort.c",
		"_std/Type.c",
		"_std/Sys.c",
		"hl/_Bytes/Bytes_Impl_.c",
		"_std/Std.c",
		"hl/types/ArrayDynIterator.c",
		"hl/types/BytesIterator_hl_UI16.c",
		"hl/types/BytesIterator_Single.c",
		"hl/types/BytesIterator_Int.c",
		"hl/types/BytesIterator_Float.c",
		"hl/types/ArrayObj.c",
		"hl/NativeArrayIterator_Int.c",
		"hl/NativeArrayIterator_Dynamic.c",
		"hl/NativeArrayIterator.c",
		"haxe/io/Eof.c",
		"_std/SysError.c",
		"_std/StringBuf.c",
		"hl/types/ArrayDyn.c",
		"haxe/Log.c",
		"hl/types/ArrayBytes_Float.c",
		"hl/types/ArrayBytes_Single.c",
		"hl/types/ArrayBytes_hl_UI16.c",
		"hl/types/ArrayBytes_Int.c",
		"hl/types/ArrayBase.c",
		"hl/types/ArrayAccess.c",
		"_std/Main.c",
		"_std/Date.c",
		"_std/String.c",
		"hl/BaseType.c",
		"hl/reflect.c",
		"hl/types.c",
		"hl/globals.c"
	]
}

Please let me know if there are more tests I should try it would be really nice to try some simple sdl gpu graphics and see how small file sizes are, also would be great if there was a simple triangle example, I am not sure about setup of the main loop but I can probably work that out from Heaps once the 'make' is working on macs, but would be really good if there was working HL for mac, not bothered about sound support at moment just graphics would be great.

enumEq error

Here enumEq returns false instead of true.

enum FieldType<T> {
	PFlags( t : T );
	PEnum( name : String );
}

class Main  { 
	static function main() 	{
		trace( Type.enumEq(PFlags(PEnum("UserFlag")), PFlags(PEnum("UserFlag"))) );
	}
}

cannot compile hlc

Error   LNK2019 unresolved external symbol _hl_entry_point referenced in function _wmain    hlc D:\Documents\workspace\hl\hlc_main.obj  1
Error   LNK2019 unresolved external symbol _hlc_static_call referenced in function _wmain   hlc D:\Documents\workspace\hl\hlc_main.obj  1
Error   LNK2019 unresolved external symbol _hlc_get_wrapper referenced in function _wmain   hlc D:\Documents\workspace\hl\hlc_main.obj  1
Error   LNK1120 3 unresolved externals  hlc D:\Documents\workspace\hl\Debug\hlc.exe 1

In hlc.vcxproj, there is a reference to src\_main.c, but it doesn't exist in the repo. Maybe that's the reason?

hl_sys_print garbled with Chinese Characters in Windows environment

I think that the hl_sys_print do not need convert "ucs2" to "utf8". In Asian countries, the character encoding of the console is not utf8.

import hl.UI;

class App{
	static function main() {
		var s = "你好!";
		trace(s);  // bad
		UI.dialog("", s, cast 0);  // good
	}
}

I got a simple example, it can get correct output(only test in msvc2013 and cygwin's gcc).

test.c [save as utf-8(with BOM) for msvc]

#include <stdio.h>
#include <locale.h>
#include <wchar.h>

int main(int argc, char *argv[]) {
	wchar_t *str = L"好久不见";

	setlocale(LC_ALL, "");

	wprintf(L"%ls\n", str);

	return 0;
}

Cannot build HL1.1 on Linux

(But 1.0 works)


$ make
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o include/pcre/pcre_chartables.o -c include/pcre/pcre_chartables.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o include/pcre/pcre_compile.o -c include/pcre/pcre_compile.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o include/pcre/pcre_dfa_exec.o -c include/pcre/pcre_dfa_exec.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o include/pcre/pcre_exec.o -c include/pcre/pcre_exec.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o include/pcre/pcre_fullinfo.o -c include/pcre/pcre_fullinfo.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o include/pcre/pcre_globals.o -c include/pcre/pcre_globals.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o include/pcre/pcre_newline.o -c include/pcre/pcre_newline.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o include/pcre/pcre_string_utils.o -c include/pcre/pcre_string_utils.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o include/pcre/pcre_tables.o -c include/pcre/pcre_tables.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o include/pcre/pcre_xclass.o -c include/pcre/pcre_xclass.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/alloc.o -c src/alloc.c
src/alloc.c: In function ‘hl_gc_alloc_gen’:
src/alloc.c:576:34: warning: ‘allocated’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   MZERO((char*)ptr+size,allocated-size); // erase possible pointers after data
                                  ^
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/array.o -c src/std/array.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/buffer.o -c src/std/buffer.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/bytes.o -c src/std/bytes.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/cast.o -c src/std/cast.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/date.o -c src/std/date.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/error.o -c src/std/error.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/file.o -c src/std/file.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/fun.o -c src/std/fun.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/maps.o -c src/std/maps.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/math.o -c src/std/math.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/obj.o -c src/std/obj.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/random.o -c src/std/random.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/regexp.o -c src/std/regexp.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/socket.o -c src/std/socket.c
src/std/socket.c: In function ‘hl_socket_recv_from’:
src/std/socket.c:335:59: warning: pointer targets in passing argument 6 of ‘recvfrom’ differ in signedness [-Wpointer-sign]
  len = recvfrom(s->sock, data, len, MSG_NOSIGNAL, (struct sockaddr*)&saddr, &slen)
                                                           ^
In file included from /usr/include/x86_64-linux-gnu/sys/socket.h:280:0,
                 from src/std/socket.c:40:
/usr/include/x86_64-linux-gnu/bits/socket2.h:64:1: note: expected ‘socklen_t * restrict’ but argument is of type ‘int *’
 recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags,
 ^
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/string.o -c src/std/string.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/sys.o -c src/std/sys.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/types.o -c src/std/types.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/ucs2.o -c src/std/ucs2.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/thread.o -c src/std/thread.c
src/std/thread.c: In function ‘hl_thread_id’:
src/std/thread.c:42:2: warning: implicit declaration of function ‘syscall’ [-Wimplicit-function-declaration]
  return syscall(SYS_gettid);
  ^
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/std/process.o -c src/std/process.c
cc -o libhl.so -m64  -shared include/pcre/pcre_chartables.o include/pcre/pcre_compile.o include/pcre/pcre_dfa_exec.o include/pcre/pcre_exec.o include/pcre/pcre_fullinfo.o include/pcre/pcre_globals.o include/pcre/pcre_newline.o include/pcre/pcre_string_utils.o include/pcre/pcre_tables.o include/pcre/pcre_xclass.o src/alloc.o src/std/array.o src/std/buffer.o src/std/bytes.o src/std/cast.o src/std/date.o src/std/error.o src/std/file.o src/std/fun.o src/std/maps.o src/std/math.o src/std/obj.o src/std/random.o src/std/regexp.o 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 -lpthread -lm
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/callback.o -c src/callback.c
src/callback.c:173:14: warning: ‘hl_call_wrapper_all_ptr’ defined but not used [-Wunused-function]
 static void *hl_call_wrapper_all_ptr( vclosure_wrapper *c ) {
              ^
src/callback.c:177:12: warning: ‘hl_call_wrapper_all_ptr_i’ defined but not used [-Wunused-function]
 static int hl_call_wrapper_all_ptr_i( vclosure_wrapper *c ) {
            ^
src/callback.c:183:14: warning: ‘hl_call_wrapper_all_ptr_f’ defined but not used [-Wunused-function]
 static float hl_call_wrapper_all_ptr_f( vclosure_wrapper *c ) {
              ^
src/callback.c:189:15: warning: ‘hl_call_wrapper_all_ptr_d’ defined but not used [-Wunused-function]
 static double hl_call_wrapper_all_ptr_d( vclosure_wrapper *c ) {
               ^
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/code.o -c src/code.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/jit.o -c src/jit.c
src/jit.c: In function ‘make_dyn_cast’:
src/jit.c:2113:7: warning: unused variable ‘p’ [-Wunused-variable]
  preg p;
       ^
src/jit.c:2112:6: warning: unused variable ‘size’ [-Wunused-variable]
  int size;
      ^
src/jit.c: In function ‘hl_jit_function’:
src/jit.c:2639:28: warning: unused variable ‘size’ [-Wunused-variable]
       int jhasfield, jend, size;
                            ^
src/jit.c:2835:8: warning: overflow in implicit constant conversion [-Woverflow]
        copy(ctx,PEAX,pmem(&p,Esp,HDYN_VALUE - sizeof(vdynamic)),dst->size);
        ^
src/jit.c:3076:11: warning: unused variable ‘r’ [-Wunused-variable]
     preg *r;
           ^
src/jit.c:3075:9: warning: unused variable ‘size’ [-Wunused-variable]
     int size;
         ^
src/jit.c:3098:9: warning: unused variable ‘size’ [-Wunused-variable]
     int size;
         ^
src/jit.c: At top level:
src/jit.c:2040:14: warning: ‘get_dyncast’ defined but not used [-Wunused-function]
 static void *get_dyncast( hl_type *t ) {
              ^
src/jit.c:2056:14: warning: ‘get_dynset’ defined but not used [-Wunused-function]
 static void *get_dynset( hl_type *t ) {
              ^
src/jit.c:2072:14: warning: ‘get_dynget’ defined but not used [-Wunused-function]
 static void *get_dynget( hl_type *t ) {
              ^
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/main.o -c src/main.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/module.o -c src/module.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o src/debugger.o -c src/debugger.c
echo 64
64
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o hl src/callback.o src/code.o src/jit.o src/main.o src/module.o src/debugger.o -L. -lhl -lm -Wl,--export-dynamic -Wl,--no-undefined -ldl
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -o libs/fmt/fmt.o -c libs/fmt/fmt.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -I include/mbedtls/include -D LIBHL_EXPORTS -m64 -fPIC -shared -o fmt.hdll libs/fmt/fmt.o  -lhl -lpng -l:libturbojpeg.so.0 -lz -lvorbisfile
/usr/bin/ld: cannot find -lhl
collect2: error: ld returned 1 exit status
make: *** [fmt] Error 1

cheers

Unable to setup and use hlsdl haxelib.

It is not clear how to setup hlsdl on mac.
.src/module.c(207) : FATAL ERROR : Failed to load library ui.hdll
when trying to import sdl classes is this currently possible? Hello World works fine.

Does not run compiled bytecode on Linux

I'm on Ubuntu 16.04 x64

$ haxe -hl hw.hl -main HelloWorld.hx
$ hl hw.hl
Invalid debug file

$ haxe -hl hw.hl -main HelloWorld.hx -debug
$ hl hw.hl
Invalid opcode

Access violation with virtual

typedef Entry = {
	id: Null<String>,
	?str: String,
}

class Main  { 
	static function main() 	{
		var e : Entry = { id: null };

		for ( str in [""] ) {
			e = { id: null };
			e.str = str;
			getString(str);
		}
	}

	static function getString( str : String ){
		trace( str );
	}
}

Automatic struct padding detection

We need obj fields and enum fields to match C compiler alignment (for C interaction + HL/C reflection). It is necessary to replace some hl_pad_size by hl_pad_struct and perform compile time alignment check.

ex: apple 32 bits, double are not aligned on 64 bits, etc.

Sys.args() produces garbage

hl test.hl a b c
Test.hx:4: 1690
Test.hx:4: 1689
Test.hx:4: 1688
Test.hx:5: [abc䕎佋䅐䡔⼽汣慥⽮慨數癟牥楳湯⽳獵⽲楢n... 
class Test {
  static function main(){
    for (x in Sys.args()) trace(x.length);
    trace(Sys.args());
  }
}

Structure alignment / OSX support

ATM the compiler assumes that:

  • stack is aligned on 4 bytes
  • structures are aligned on their data size

We found that OSX compiler aligns on 32 bits (for a 32 bit apps), causing crashes in HL/C with virtuals.
It is necessary then to perform compile time detection of alignment mode and patch hl_type_align accordingly.

sizeof(bool) should also be runtime detected

Non-capturing regex groups are not supported

class Test {
    static function main() {
        var pattern = ~/(:?[a-z])/i;
        trace(pattern.match("a"));
    }
}

results in:

Non capturing groups '(?:' are not supported in macros
C:\apps\dev\haxe-3.4.0-rc1\std/hl/_std/EReg.hx:37: Called from fun@30 @x1C

Plans for embedding API

There was a thread about HashLink on Reddit where someone suggested an API for embedding the HashLink runtime into other software.

Mentioning Mono, HashLink might be an interesting alternative, as it seems to promise roughly about the same level of performance.
Is an API like this planned or does it already exist?

ARM support

On ARM cpu (iOS), memory alignment creates crash with GC_PRECISE when reading mark_bits. Using 8 bits read is working but should be slightly less efficient.

Unable to build HL on Linux

Ubuntu 16.04 x64:

$ make
<....>
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -D LIBHL_EXPORTS -m64 -fPIC -o src/std/regexp.o -c src/std/regexp.c
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include/pcre -D LIBHL_EXPORTS -m64 -fPIC -o src/std/socket.o -c src/std/socket.c
src/std/socket.c: In function ‘hl_socket_recv_from’:
src/std/socket.c:335:77: warning: pointer targets in passing argument 6 of ‘recvfrom’ differ in signedness [-Wpointer-sign]
  len = recvfrom(s->sock, data, len, MSG_NOSIGNAL, (struct sockaddr*)&saddr, &slen);
                                                                             ^
In file included from /usr/include/x86_64-linux-gnu/sys/socket.h:280:0,
                 from src/std/socket.c:40:
/usr/include/x86_64-linux-gnu/bits/socket2.h:64:1: note: expected ‘socklen_t * restrict {aka unsigned int * restrict}’ but argument is of type ‘int *’
 recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags,
 ^
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:219:0,
                 from src/std/socket.c:39:
src/std/socket.c: In function ‘make_array_result’:
src/std/socket.c:388:7: error: invalid type argument of ‘->’ (have ‘SOCKET {aka int}’)
   if( FD_ISSET(set,s->sock) )
       ^
src/std/socket.c:388:7: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
   if( FD_ISSET(set,s->sock) )
       ^
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:219:0,
                 from src/std/socket.c:39:
src/std/socket.c:388:7: error: invalid operands to binary % (have ‘fd_set * {aka struct <anonymous> *}’ and ‘int’)
   if( FD_ISSET(set,s->sock) )
       ^
Makefile:96: ошибка выполнения рецепта для цели «src/std/socket.o»
make: *** [src/std/socket.o] Ошибка 1

gc_alloc_var optimization

ATM gc_alloc_var takes too much time after a mark to allocate on already filled pages, because it will not blacklist full pages and will keep iterating over them. Using gc_free_pages as we do for gc_alloc_fixed would help.

This can be reproduced by disable interface memoization and running Northgard main loop.

creating a big array hangs on linux

the following code runs fine under hl/windows but hangs on linux hlc or crashes hl/jit

I am on Ubuntu 16.04 and compiled with gcc V 6.2.0 or gcc 5.4.1

import haxe.Timer;



class BugArray {
    inline static var LOOP = 1000;
    inline static var LOOP2 = LOOP * LOOP;
    inline static var LOOP3 = LOOP2 * LOOP;

    public static function benchmark(dg: Void->Void, ? msg: String) {
        if (msg != null) trace('$msg :');
        var dt = #if (js || interp) haxe.Timer.stamp(); #else Sys.cpuTime(); #end
        dg();
        trace(#if (js || interp) haxe.Timer.stamp() #else Sys.cpuTime() #end - dt);
    }


    static function arrayTest1() {
        var ar: Array<Int> = new Array();
        ar[LOOP2] = 0;
        for (i in 0...LOOP2) {
            ar[i] = i;
        }
    }


    public static function main() {
        trace("start");
    benchmark(arrayTest1, "arrayTest1");    
        trace("done");
    }
}

the strange thing is, if I add another static function, than the code runs - sometimes and sometimes not - it depends on the combination of functions I add.

MUnit not working (Reflect.callMethod)

When trying to test the haxe-doctest against the hashlink target.

I get the following exception:

Uncaught exception: Can't cast #hx.doctest.tests.MUnitDocTests to #massive.munit.TestClassHelper
Called from $Reflect.callMethod(C:\apps\dev\haxe\haxe-3.4.0\std/hl/_std/Reflect.hx:85)
Called from massive.munit.TestRunner.execute(massive/munit/TestRunner.hx:243)
Called from massive.munit.TestRunner.run(massive/munit/TestRunner.hx:229)
Called from hx.doctest.tests.$MUnitTest.main(hx/doctest/tests/MUnitTest.hx:33)
Called from hx.doctest.$TestRunner.main(hx/doctest/TestRunner.hx:53)
Called from fun$629(?:1)

This only happens with HL. All other targets work. Is there maybe something wrong within the HL implementation of Reflect.callMethod?

I test the HL target using this batch file: https://github.com/vegardit/haxe-doctest/blob/master/test-hl.cmd

I am using HL 1.1 and the latest Haxe build.

Crash on muliply call try-catch

Crash on Windows 10 at hl/jit (x86)

Sample code:

class CrashTestCase extends haxe.unit.TestCase
{
	function testCall( )
	{
		var arr = [
			sample(),
			sample(),
			sample(),
			sample(),
			sample(),
			sample(),
			sample(),
			sample(),
			sample(),
			sample(),
			sample(),
			sample(),
			sample(),
			sample(),
			sample(),
		];
	}
	
	static function sample( ) : Float
	{
		try
		{
			return Math.random();
		}
		catch ( e : Dynamic )
		{
			
		}
		return 0.0;
	}
}

class Main
{
	public static function main( ) : Void
	{
		var r = new haxe.unit.TestRunner();
		r.add(new CrashTestCase());
		r.run();
	}
}

Callstack

hl.exe!jit_buf(jit_ctx * ctx) Line 324	C
hl.exe!hl_jit_function(jit_ctx * ctx, hl_module * m, hl_function * f) Line 2195	C
hl.exe!hl_module_init(hl_module * m) Line 274	C
hl.exe!wmain(int argc, wchar_t * * argv) Line 106	C

HL/JIT 64 bits

While the HL bytecode, runtime and std library are compatible with both 32 and 64 bits compilation, the current JIT is limited to 32 bits and would require some additional work to fully support 64 bits CPU.

OpenAL jack disconnect

Under Windows 10, OpenAL stops working if you unplug the jack and plug it again.
You get the following trace in console:

AL lib: (EE) ALCmmdevPlayback_mixerProc: Failed to get padding: 0x88890004

fmt hdll linux

Trying to check out heaps hl but it says:
src/module.c(207) : FATAL ERROR : Failed to load library fmt.hdll

So I check and indeed I don't have it,
it's mentioned in the makefile but there's no rule for it.

What is the command to compile it?

Getting Started With Virtual Machine

Hi!
i came form AS3 and very new with Haxe.

i m using flash Develop and having difficulties in debugging while using it with haxe ui 2.

came across with this virtual machine , plz tell me how to get started with flash develop ,

sys.net.Socket.select not implemented

Hi, I need some non-blocking sockets for my game. I'd love to use Hashlink for quick JIT testing but apparently sys.net.Socket.select is not implemented for this target.

Here's a snippet of code I'm using:

import sys.net.Socket;

class SocketServer {
  static function main() {
    var sockets : Array<sys.net.Socket> = [];
    var s = new sys.net.Socket();
    s.bind(new sys.net.Host("localhost"),5000);
    s.listen(10); // Allow a buffer of 10 pending connections. You might want this higher for a busy server
    while (true) {
      var results = sys.net.Socket.select(  
        [] // Not interested in reading
        , sockets // Writing to all clients
        , [s] // Waiting for new sockets from the server
        , 0 // Infinite timeout

      ); //

      for (c in results.write)
      {
        c.write("exit");
      }
      if (results.others.length > 0)
      {
        // Accept a new socket from the server
        var c : sys.net.Socket = s.accept();
        sockets.push(c);
        c.setBlocking(false);
        c.setFastSend(true);
        c.write("your IP is "+c.peer().host.toString()+"\n");
      }
    }
  }
}

and here's the error it produces:

Uncaught exception: SysError(Not implemented)
Called from sys.net.$Socket.select(C:\HaxeToolkit\haxe\std/hl/_std/sys/net/Socket.hx:199)

I hope I'm wrong about this and there's some fix for my problem :) otherwise I'd love to see it implemented!

sys.io.File.saveContent writes to wrong path

on Linux sys.io.File.saveContent writes to a file named like the first character in the given path.
This is potentially destructive, HL should be flagged experimental until these issues are solved, I think.

jit error with string default value for Dynamic argument

Tried to run my project on hl and got this error:

JIT ERROR 8 (jic.c line 2495)

Here is minimal test code:

class Main {
    static function main() {
        test('oops');
    }
    static function test(msg:Dynamic = '') {
        trace('test ' + msg);
    }
}

hxml:

-main Main
-hl main.hl

and it runs ok on neko with this hxml:

-main Main
-neko main.n

How to call haxe function from native code?

How to call haxe function from native code?
Like I have

class TestMain {
    public function test(foo:Int):Void {
        trace("Native Code call");
    }
}

and how TestMain.test could be called from C code?

Mangled output of strings with non-ASCII chars [utos @ src/std/ucs2.c:201]

Sample program:

class TestCyrillic {
  public static function main() {
    Sys.println("машинаDr");
    Sys.println("машинаDrake1");
    Sys.println("машинаDr".length);
    }
}

Expected output is:

машинаDr
машинаDrake1
8

But actual output is:

маш
машина
8

String length shows correct value (8), but actual printing mangles the string.

[email protected]:201 seems to have a bug.
It uses len for following malloc call and utostr call. But ustrlen returns number of 2-byte characters and both malloc and utostr expect number of 1-byte chars.

I suggest fixing utos like this (or something better, I'm not very good in C):

static char *utos( const uchar *s ) {
	int len = ustrlen(s);
	int chars_len = 2 * len;
	char *out = (char*)malloc(chars_len + 1);
	if( utostr(out,chars_len+1,s) < 0 )
		*out = 0;
	return out;
}

Nighlty builds

Is it possible to setup nightly builds just like compiler nightlies?
I think that will allow people to avoid all issues they have on Linux and OSX trying to build hashlink manually.

About IDE

What IDE you are using ...? right now?

Sys.getEnv returns null for existing environment variable

Since the haxe code looks OK, I file the issue here.
HL runtime: HL JIT
System: Linux, Debian Jessie

haxe -hl test.hl -main Test
export FOO=FOO
export foo=foo
hl test.hl
Test.hx:4: null
Test.hx:5: null
class Test {
  static function main(){
    trace(Sys.getEnv("FOO"));
    trace(Sys.getEnv("foo"));
  }
}

some constants are not defined when HL_64

In alloc.c:

#ifndef HL_64
#   define GC_MASK_BITS         16
#   define GC_LEVEL0_BITS       8
#   define GC_LEVEL1_BITS       8
#   define GC_GET_LEVEL1(ptr)   hl_gc_page_map[((unsigned int)(ptr))>>(GC_MASK_BITS+GC_LEVEL1_BITS)]
#   define GC_GET_PAGE(ptr)     GC_GET_LEVEL1(ptr)[(((unsigned int)(ptr))>>GC_MASK_BITS)&GC_LEVEL1_MASK]
#endif

GC_LEVEL0_BITS is used in the same file even if HL_64, so there is a compilation error.
This is blocking for CI since Travis only offer 64-bit environments.

No output driver available

With the haxe 4.0 preview build, hashlink 1.2, and latest pull from heaps, any heaps samples I build and subsequently run with hl.exe produce this message in the console:

No output driver available.

HL 64 bit on macOS

hl built with ARCH=64 on macOS segfaults (haxe group post). Building with ARCH=32 works however.

Last time I checked 64 bit wasn't quite ready but it looks like things have progressed

I'm creating this issue to help inform new macOS users (since 64 bit will be default)

Make HL Bytecode as executable (like `nekotools boot`)

While HL does compiles to C executable, it's currently not possible to simply make .hl file as executable file which depends on pre-installed HL in the system.
I request feature of making executable for .hl bytecode which should run the installed HashLink.
Neko already have such feature via nekotools boot utility, which were pretty convenient when executable file output were required but compilation time weren't as long as for C++.

Multithreading support

I see some works were done on a threading side, but I'm not sure how it would work considering of GC notification if exposed to Haxe API right now.
So, what plans on a multithreading support, and how may I help with it? Considering I have no idea how HL GC works or how to implement it to support several threads.
Small UPD: I've made some supporting classes (Lock, Mutex, and Deque, but I'm seriously not sure if they are done properly, plus windows only) copying implementation from NekoVM in my fork

Map iteration allocates closures

According to profiling data, iterating on Map allocates many closures (to fix).

class Main  {

	
	static function main() {
		var m = [for( i in 0...10000 ) ""+i => i];
		hl.Profile.enable = true;
		var k = 0;
		for( v in m )
			k += v;
		hl.Profile.enable = false;
		trace( hl.Profile.getData() );
	}

}

PTiA_D required but PTiAi_D found in hdll

Under Linux, the HelloWorld example works perfectly, ./hl hello.hl would output

HelloWorld.hx:2: Hello world!

But trying a more complex program like the "Base2D" example from Heaps, this is the output:

src/module.c(277) : FATAL ERROR : Invalid signature for function std@alloc_enum : PTiA_D required but PTiAi_D found in hdll

Seems like all program that I try to run under hashlink that are more than simple console program output this error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.