I modified the compiler to skip the intermediate passage, and compile directly from C to object code, on the emscripten target (other targets should be unaffected). The issues reported by VANYA seem to be gone, in that way. It is not possible to get the .s file, now, only the .c file, but since the .s file didn't work well (and since I doubt anyone would need an intermediate assembly file for something that will be compiled to Javascript) I guess it should work.
Well, this is another patch:
Code: Select all
--- fbc.bas 2020-08-31 20:48:38.000000000 +0200
+++ src/compiler/fbc.bas 2020-11-11 21:49:25.602909281 +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 = @".o"
end if
if( stage = 1 ) then
@@ -2975,12 +2975,15 @@
ln += "-fPIC "
end if
- ln += "-S -nostdlib -nostdinc -Wall -Wno-unused-label " + _
- "-Wno-unused-function -Wno-unused-variable "
if( fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_JS ) then
+ ln += "-S -nostdlib -nostdinc -Wall -Wno-unused-label " + _
+ "-Wno-unused-function -Wno-unused-variable "
ln += "-Wno-unused-but-set-variable "
else
+ 'if Emscripten is used, we will skip the assembly generation and compile directly to object code
+ ln += "-c -nostdlib -nostdinc -Wall -Wno-unused-label " + _
+ "-Wno-unused-function -Wno-unused-variable "
ln += "-Wno-warn-absolute-paths -s ASYNCIFY=1 -s RETAIN_COMPILER_SETTINGS=1 "
end if
@@ -3152,6 +3155,13 @@
end if
endif
end if
+
+ if( fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_JS ) then
+ 'We will skip assemble stage, since it is already performed by Emscripten
+ function = TRUE
+ exit function
+ end if
+
ln += """" + hGetAsmName( module, 2 ) + """ "
ln += "-o """ + *module->objfile + """"
ln += fbc.extopt.gas