What happened to the Emscripten branch?
What happened to the Emscripten branch?
I see that there has been no development in the last years. I wonder if that branch could be merged with the original one, or if it is too different.
Re: What happened to the Emscripten branch?
The original is still there at https://github.com/freebasic/fbc/tree/emscripten and every once and a while, I merge the master branch in to emscripten and push it to my own fork on https://github.com/jayrm/fbc/tree/emscripten
It looks really cool, and I want to try it, but I haven't had a chance to get it working.
EDIT:
to get it merged in to master, that is the official distribution, someone has to be willing to commit the time to support it. As in if freebasic is going to advertise that it supports emscripten build, then it needs documentation, packaging, etc, so that anyone can use it.
It looks really cool, and I want to try it, but I haven't had a chance to get it working.
EDIT:
to get it merged in to master, that is the official distribution, someone has to be willing to commit the time to support it. As in if freebasic is going to advertise that it supports emscripten build, then it needs documentation, packaging, etc, so that anyone can use it.
Re: What happened to the Emscripten branch?
A patch for fbc.bas:coderJeff wrote:The original is still there at https://github.com/freebasic/fbc/tree/emscripten and every once and a while, I merge the master branch in to emscripten and push it to my own fork on https://github.com/jayrm/fbc/tree/emscripten
Code: Select all
--- fbc.bas 2020-08-31 20:48:38.000000000 +0200
+++ src/compiler/fbc.bas 2020-10-31 01:26:07.016517629 +0100
@@ -133,7 +133,7 @@
static shared as zstring * 16 toolnames(0 to FBCTOOL__COUNT-1) = _
{ _
"as", "ar", "ld", "gcc", "llc", "dlltool", "GoRC", "windres", "cxbe", "dxe3gen", _
- "llvm-as", _
+ "emcc", _
"emar", _
"emcc", _
"emcc" _
@@ -2634,7 +2634,7 @@
if( fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_JS ) then
ext = @".asm"
else
- ext = @".llvm"
+ ext = @".s"
end if
if( stage = 1 ) then
@@ -3152,6 +3152,11 @@
end if
endif
end if
+
+ if( fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_JS ) then
+ ln += "-c "
+ end if
+
ln += """" + hGetAsmName( module, 2 ) + """ "
ln += "-o """ + *module->objfile + """"
ln += fbc.extopt.gas
Re: What happened to the Emscripten branch?
I've tried Emscripten on Linux 64-bit, but:
when compiling source code v1ctor , i am getting errors:
Unfortunately, I can't use it. It may be necessary to use older versions of Linux with older libraries Emscripten, python, etc.
when compiling source code v1ctor , i am getting errors:
and compilation stops (hangs)Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 392, in _handle_results
task = get()
TypeError: __init__() takes at least 3 arguments (1 given)
Unfortunately, I can't use it. It may be necessary to use older versions of Linux with older libraries Emscripten, python, etc.
Re: What happened to the Emscripten branch?
@angros47,
Would you prefer a new rebase of emscripten on to current fbc 1.08 fbc/master? I don't mind doing that. For really old branches I find it easier to periodically rebase the changes up the development tree rather than try to merge something really old in to latest development.
If you and others are interested, I can merge the changes in to fbc 1.08. I don't know much about the emscripten target so I would be counting others to provide information and patches if it gets added to current fbc 1.08.
Would you prefer a new rebase of emscripten on to current fbc 1.08 fbc/master? I don't mind doing that. For really old branches I find it easier to periodically rebase the changes up the development tree rather than try to merge something really old in to latest development.
If you and others are interested, I can merge the changes in to fbc 1.08. I don't know much about the emscripten target so I would be counting others to provide information and patches if it gets added to current fbc 1.08.
Re: What happened to the Emscripten branch?
That would surely help (the version in your github branch isn't already the 1.08 version?). And I agree, it should be merged in the official version (as soon as it works enough at least for an "hello world")
Re: What happened to the Emscripten branch?
Which version did you use? V1ctor's one, or CoderJeff's one? Also, what happens with a simple hello world example? Can you compile it? Can you run it?VANYA wrote:I've tried Emscripten on Linux 64-bit, but:
I am using CoderJeff's version. I managed to compile a hello world example with no issues, but it throws exceptions and doesn't work
Re: What happened to the Emscripten branch?
I use:Which version did you use? V1ctor's one, or CoderJeff's one? Also, what happens with a simple hello world example? Can you compile it? Can you run it?
I am using CoderJeff's version. I managed to compile a hello world example with no issues, but it throws exceptions and doesn't work
1) linux mint 19.3
2) emscripten 1.22.1-1build1 (by default in the standard repository)
3) compiler archive with emscripten from here: https://github.com/jayrm/fbc/tree/emscripten. When compiling it, a warning is displayed that the LLVM version must be older (I have a newer version), but the compiler and libraries are compiled. And when compiling the BAS source codes, problems appear (I described this above). Actually I tried the same archive from here: https://sourceforge.net/p/fbc/code/ci/emscripten/tree/ and tried to compile it with compiler version 1.05 (since at the time of creation freebasic-emscripten was version 1.05) , but couldn't even compile.
Re: What happened to the Emscripten branch?
Can you compile a simple hello world in C using that version of emscripten? Because I tried installing it on Ubuntu 16 and 18 and it never worked. All the sites where I asked told me that version is outdated and not working (I asked on Stack Overflow too https://stackoverflow.com/questions/635 ... it-to-work). Since then I switched to the 64 bit version of the OS and installed the latest version of emscripten. I never managed to get version 1.22 to work.
So, write a simple hello world test in c, and compile it with emcc. If you can't get it to work, it means you are using a broken version of emcc, and you need to replace it if you want to experiment.
So, write a simple hello world test in c, and compile it with emcc. If you can't get it to work, it means you are using a broken version of emcc, and you need to replace it if you want to experiment.
Re: What happened to the Emscripten branch?
I install the most recent version emscripten. I took the usual source "C" with "hello world".
The source is compiled, files are created: "1.js", "1.html".
When using the console with the command:
However, when using a browser with the 1.html file, nothing works, it just keeps "Preparing".
As for source code freebasic, an error pops up when compiling:
The source is compiled, files are created: "1.js", "1.html".
When using the console with the command:
everything is displayed correctly in the terminal.node 1.js
However, when using a browser with the 1.html file, nothing works, it just keeps "Preparing".
As for source code freebasic, an error pops up when compiling:
I'm tired of fighting ...fbc -target js-asmjs 1.bas -v
FreeBASIC Compiler - Version 1.08.0 (2020-11-02), built for linux-x86_64 (64bit)
Copyright (C) 2004-2019 The FreeBASIC development team.
target: js-asmjs, asmjs, 32bit (js-asmjs)
backend: gcc
compiling: 1.bas -o 1.c (main module)
compiling C: emcc -S -nostdlib -nostdinc -Wall -Wno-unused-label -Wno-unused-function -Wno-unused-variable -Wno-warn-absolute-paths -s ASYNCIFY=1 -s RETAIN_COMPILER_SETTINGS=1 -Wno-main -Werror-implicit-function-declaration -fno-strict-aliasing -fno-math-errno -fwrapv -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Wno-format "1.c" -o "1.llvm"
assembling: llvm-as "1.llvm" -o "1.o"
llvm-as: 1.llvm:1:2: error: expected top-level entity
.text
^
assembling failed: 'llvm-as' terminated with exit code 1
Re: What happened to the Emscripten branch?
Unless you compiled it with the flag "-s WASM=0", you should have also the file 1.wasm, check if you have it.
And the reason why you can't get it to work in your browser is that javascript cannot access local files for security reasons, so it cannot load it completely. You need to start up a small local web server. You can do it with:
from the directory where you have your files, then with the browser you visit localhost:8000/1.html
It should work (I learned it in the harsh way, so I understand your struggles)
About the FreeBasic compiler, I had exactly the same error message you got. I managed to get rid of it by patching the compiler as I showed few posts ago. I still couldn't get a compiled file to work
And the reason why you can't get it to work in your browser is that javascript cannot access local files for security reasons, so it cannot load it completely. You need to start up a small local web server. You can do it with:
Code: Select all
python3 -m http.server
It should work (I learned it in the harsh way, so I understand your struggles)
About the FreeBasic compiler, I had exactly the same error message you got. I managed to get rid of it by patching the compiler as I showed few posts ago. I still couldn't get a compiled file to work
Re: What happened to the Emscripten branch?
Yes, Emscripten is working, thanks!You need to start up a small local web server.
However, we have not come close to working FreeBasic and Emscripten :(
Re: What happened to the Emscripten branch?
When trying to compile with FreeBasic, try adding the flag -Wl "-s WASM=0" , as in
It will create a .js file, instead of a .wasm file. It's easier to debug
Code: Select all
fbc -target js-asmjs test.bas -Wl "-s WASM=0"
Re: What happened to the Emscripten branch?
Ok, found one of the issues: in file src/rtlib/js/hinit.c , the lines
must be replaced with:
The reason is explained here: https://emscripten.org/docs/api_referen ... -html5-api :
After that change, it is possible to compile graphical programs for web pages (console mode programs don't work yet)
Code: Select all
// keyboard
emscripten_set_keypress_callback( 0, NULL, 1, fb_hKeyEventHandler );
emscripten_set_keydown_callback( 0, NULL, 1, fb_hKeyEventHandler );
emscripten_set_keyup_callback( 0, NULL, 1, fb_hKeyEventHandler );
// mouse
emscripten_set_mousemove_callback( 0, NULL, 1, fb_hMouseEventHandler );
emscripten_set_mousedown_callback( 0, NULL, 1, fb_hMouseEventHandler );
emscripten_set_mouseup_callback( 0, NULL, 1, fb_hMouseEventHandler );
emscripten_set_dblclick_callback( 0, NULL, 1, fb_hMouseEventHandler );
Code: Select all
// keyboard
emscripten_set_keypress_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, fb_hKeyEventHandler );
emscripten_set_keydown_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, fb_hKeyEventHandler );
emscripten_set_keyup_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, fb_hKeyEventHandler );
// mouse
emscripten_set_mousemove_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, fb_hMouseEventHandler );
emscripten_set_mousedown_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, fb_hMouseEventHandler );
emscripten_set_mouseup_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, fb_hMouseEventHandler );
emscripten_set_dblclick_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, fb_hMouseEventHandler );
The library still used the format of an old version of Emscripten0 or NULL: If building with the option -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 (default), NULL denotes an invalid element. If building with legacy option -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 (not recommended), a default element is chosen automatically based on the event type.
After that change, it is possible to compile graphical programs for web pages (console mode programs don't work yet)
Re: What happened to the Emscripten branch?
Are you working with the modified fbc.bas file? I don't understand the syntax of git patches. Could you drop this patched fbc.bas file somewhere?