Is FreeBasic still continued to develop?
Of course, defining 'unreadable' code will always be subjective. However, if you had to choose between FB being what it currently is, or requiring you to write code like the C emitter produces, which would you pick? :P
Machine code is 'readable by humans', it's just not user-friendly. Just like you can eat a crayon but it's not made for consumption etc...
Machine code is 'readable by humans', it's just not user-friendly. Just like you can eat a crayon but it's not made for consumption etc...
That's because you are knowledgable in low level usage of C. People knowledgable in assembler probably will the same for decent assembler output.AGS wrote:I do not really understand why the output produced is referred to as non readable by humans.
Note also that it is not just the language, but also another runtime (calls into the gcc runtime, and internal FB functions)
Btw, does GCC really allow $ in identifiers? Is that legal C?
Last edited by marcov on Jan 30, 2010 14:14, edited 2 times in total.
It is not legal, unless added in recent standards, since my K&R 2nd edition says on p192 about identifiers;cha0s wrote:I thought the same thing when I saw that, crazy...marcov wrote:Btw, does GCC really allow $ in identifiers? Is that legal C?
An identifier is a sequence of letters and digits, the first character must be a letter and underscore counts as a letter.
IOW roughly like Pascal, except that Pascal standardly does not support the underscore as first char. (though many compilers do)
On the GCC output front:
forget about the need to fully install mingw on Windows (tm) - it's not needed!
(you might need to install it temporarily in order to extract 2 files - see below)
Let's assume freebasic is installed into "c:\freebasic" and you use MinGW files...
Now do the following:
1.) Copy gcc.exe into:
"c:\freebasic\bin\win32\"
where all the other needed files are (like as, ld etc.)
2.) Create the following directory:"
"c:\freebasic\bin\libexec\gcc\mingw32\3.4.5\"
(stupid hardcoded directory structure "..\libexec\gcc\mingw32\3.4.5\")
3.) Copy cc1.exe into:
"c:\freebasic\bin\libexec\gcc\mingw32\3.4.5\"
Now fbc should compile (-gen gcc) without MinGW installed because actually only 2 files are needed (gcc.exe and cc1.exe).
Other needed files like libgcc.a come already with the January 24th build of freebasic.
Hope this works on your machine as it does on mine.
(tested with the simple "hello.bas" gui example)
Suppose more testing needs to be done though.
Enjoy!
fsw
BTW1: cc1 is pretty big so you could shrink it with upx.
BTW2: if this approach works for everyone maybe gcc.exe and cc1.exe could be included into the daily builds... (if the resulting build is not to big)
forget about the need to fully install mingw on Windows (tm) - it's not needed!
(you might need to install it temporarily in order to extract 2 files - see below)
Let's assume freebasic is installed into "c:\freebasic" and you use MinGW files...
Now do the following:
1.) Copy gcc.exe into:
"c:\freebasic\bin\win32\"
where all the other needed files are (like as, ld etc.)
2.) Create the following directory:"
"c:\freebasic\bin\libexec\gcc\mingw32\3.4.5\"
(stupid hardcoded directory structure "..\libexec\gcc\mingw32\3.4.5\")
3.) Copy cc1.exe into:
"c:\freebasic\bin\libexec\gcc\mingw32\3.4.5\"
Now fbc should compile (-gen gcc) without MinGW installed because actually only 2 files are needed (gcc.exe and cc1.exe).
Other needed files like libgcc.a come already with the January 24th build of freebasic.
Hope this works on your machine as it does on mine.
(tested with the simple "hello.bas" gui example)
Suppose more testing needs to be done though.
Enjoy!
fsw
BTW1: cc1 is pretty big so you could shrink it with upx.
BTW2: if this approach works for everyone maybe gcc.exe and cc1.exe could be included into the daily builds... (if the resulting build is not to big)
fsw,
MINGW was already installed, soI just followed your instructions as described above. Even a simple, print "Hello World" won't compile without a bunch of errors I don't undrstand.
On WINXP SP3 I get:
C:\FreeBASIC\fbc -s console -arch 686 -w pedantic -v -gen gcc "test1.bas"
FreeBASIC Compiler - Version 0.21.0 (12-21-2009) for win32 (target:win32)
Copyright (C) 2004-2008 The FreeBASIC development team.
Configured as standalone
objinfo enabled using FB BFD header version 217
compiling: test1.bas -o test1.c
assembling: C:\FreeBASIC\bin\win32\gcc.exe -c "test1.c" -o "test1.o"
linking: -T "C:\FreeBASIC\lib\win32\i386pe.x" -subsystem console -s --stack 1048576,1048576 -L "C:\FreeBASIC\lib\win32" -L "./" "C:\FreeBASIC\lib\win32\crt2.o" "C:\FreeBASIC\lib\win32\crtbegin.o" "test1.o" -o "test1.exe" -( -luser32 -lfb -lgcc -lmsvcrt -lkernel32 -lmingw32 -lmingwex -lmoldname -lsupc++ "C:\FreeBASIC\lib\win32\fbrt0.o" -) "C:\FreeBASIC\lib\win32\crtend.o"
Warning: resolving _fb_End by linking to _fb_End@4
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _fb_Init by linking to _fb_Init@12
test1.o:test1.c:(.text+0x6f): undefined reference to `fb_StrAllocTempDescZEx'
test1.o:test1.c:(.text+0x87): undefined reference to `fb_PrintString'
test1.o:test1.c:(.text+0x93): undefined reference to `fb_Sleep'
linking failed: error code 1
Build error(s)
MINGW was already installed, soI just followed your instructions as described above. Even a simple, print "Hello World" won't compile without a bunch of errors I don't undrstand.
On WINXP SP3 I get:
C:\FreeBASIC\fbc -s console -arch 686 -w pedantic -v -gen gcc "test1.bas"
FreeBASIC Compiler - Version 0.21.0 (12-21-2009) for win32 (target:win32)
Copyright (C) 2004-2008 The FreeBASIC development team.
Configured as standalone
objinfo enabled using FB BFD header version 217
compiling: test1.bas -o test1.c
assembling: C:\FreeBASIC\bin\win32\gcc.exe -c "test1.c" -o "test1.o"
linking: -T "C:\FreeBASIC\lib\win32\i386pe.x" -subsystem console -s --stack 1048576,1048576 -L "C:\FreeBASIC\lib\win32" -L "./" "C:\FreeBASIC\lib\win32\crt2.o" "C:\FreeBASIC\lib\win32\crtbegin.o" "test1.o" -o "test1.exe" -( -luser32 -lfb -lgcc -lmsvcrt -lkernel32 -lmingw32 -lmingwex -lmoldname -lsupc++ "C:\FreeBASIC\lib\win32\fbrt0.o" -) "C:\FreeBASIC\lib\win32\crtend.o"
Warning: resolving _fb_End by linking to _fb_End@4
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _fb_Init by linking to _fb_Init@12
test1.o:test1.c:(.text+0x6f): undefined reference to `fb_StrAllocTempDescZEx'
test1.o:test1.c:(.text+0x87): undefined reference to `fb_PrintString'
test1.o:test1.c:(.text+0x93): undefined reference to `fb_Sleep'
linking failed: error code 1
Build error(s)
As soon *.c, *.s and *.o files are generated the "fbc->gcc->cc1->as" chain is working...nobozoz wrote:fsw,
MINGW was already installed, soI just followed your instructions as described above. Even a simple, print "Hello World" won't compile without a bunch of errors I don't undrstand.
On WINXP SP3 I get:
C:\FreeBASIC\fbc -s console -arch 686 -w pedantic -v -gen gcc "test1.bas"
FreeBASIC Compiler - Version 0.21.0 (12-21-2009) for win32 (target:win32)
Copyright (C) 2004-2008 The FreeBASIC development team.
Configured as standalone
objinfo enabled using FB BFD header version 217
compiling: test1.bas -o test1.c
assembling: C:\FreeBASIC\bin\win32\gcc.exe -c "test1.c" -o "test1.o"
linking: -T "C:\FreeBASIC\lib\win32\i386pe.x" -subsystem console -s --stack 1048576,1048576 -L "C:\FreeBASIC\lib\win32" -L "./" "C:\FreeBASIC\lib\win32\crt2.o" "C:\FreeBASIC\lib\win32\crtbegin.o" "test1.o" -o "test1.exe" -( -luser32 -lfb -lgcc -lmsvcrt -lkernel32 -lmingw32 -lmingwex -lmoldname -lsupc++ "C:\FreeBASIC\lib\win32\fbrt0.o" -) "C:\FreeBASIC\lib\win32\crtend.o"
Warning: resolving _fb_End by linking to _fb_End@4
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _fb_Init by linking to _fb_Init@12
test1.o:test1.c:(.text+0x6f): undefined reference to `fb_StrAllocTempDescZEx'
test1.o:test1.c:(.text+0x87): undefined reference to `fb_PrintString'
test1.o:test1.c:(.text+0x93): undefined reference to `fb_Sleep'
linking failed: error code 1
Build error(s)
It looks like you have linking problems as the linker doesn't find certain _fb_ functions.
---
Are you able to compile with:
fbc -R -gen gcc test1.bas
?
I have no problems at all...
---
Are you able to compile with "-gen gcc" and the environment variable:
set GCC=YOUR_DRIVE_AND_PATH\MinGW\Bin\gcc.exe
utilizing the full MinGW install?
fsw,
I put "GCC=C:\MinGW\Bin\gcc.exe" in BOTH 'User Environment' and 'System Environment' because I didn't know which.
fbc -R -gen gcc test1.bas
Still no joy.
BTW, what is "i386pe.x" used for in the linker? I renamed it and tried to recompile. The linker doesn't seem to care that "i386pe.x" is missing.
Jim
Edit_1: This compiles:
The test1.c file appears and the test1.exe appears.
compiling: test1.bas -o test1.c
assembling: C:\MinGW\Bin\gcc.exe -c "test1.c" -o "test1.o"
linking: -T "C:\FreeBASIC\lib\win32\i386pe.x" -subsystem console -s --stack 1048576,1048576 -L "C:\FreeBASIC\lib\win32" -L "./" "C:\FreeBASIC\lib\win32\crt2.o" "C:\FreeBASIC\lib\win32\crtbegin.o" "test1.o" -o "test1.exe" -( -lfb -lgcc -lmsvcrt -lkernel32 -lmingw32 -lmingwex -lmoldname -lsupc++ "C:\FreeBASIC\lib\win32\fbrt0.o" -) "C:\FreeBASIC\lib\win32\crtend.o"
Warning: resolving _fb_End by linking to _fb_End@4
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _fb_Init by linking to _fb_Init@12
Make done
Edit_2: FB WIN32 SVN compile from 01-24-10 is required for -gen gcc to work correctly. I was using SVN compile from 2? December 2009. Sorry.
I put "GCC=C:\MinGW\Bin\gcc.exe" in BOTH 'User Environment' and 'System Environment' because I didn't know which.
fbc -R -gen gcc test1.bas
Still no joy.
BTW, what is "i386pe.x" used for in the linker? I renamed it and tried to recompile. The linker doesn't seem to care that "i386pe.x" is missing.
Jim
Edit_1: This compiles:
Code: Select all
Dim As Integer a
a=3314
compiling: test1.bas -o test1.c
assembling: C:\MinGW\Bin\gcc.exe -c "test1.c" -o "test1.o"
linking: -T "C:\FreeBASIC\lib\win32\i386pe.x" -subsystem console -s --stack 1048576,1048576 -L "C:\FreeBASIC\lib\win32" -L "./" "C:\FreeBASIC\lib\win32\crt2.o" "C:\FreeBASIC\lib\win32\crtbegin.o" "test1.o" -o "test1.exe" -( -lfb -lgcc -lmsvcrt -lkernel32 -lmingw32 -lmingwex -lmoldname -lsupc++ "C:\FreeBASIC\lib\win32\fbrt0.o" -) "C:\FreeBASIC\lib\win32\crtend.o"
Warning: resolving _fb_End by linking to _fb_End@4
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _fb_Init by linking to _fb_Init@12
Make done
Edit_2: FB WIN32 SVN compile from 01-24-10 is required for -gen gcc to work correctly. I was using SVN compile from 2? December 2009. Sorry.
Last edited by nobozoz on Jan 31, 2010 6:08, edited 2 times in total.
-
- Posts: 453
- Joined: Dec 24, 2005 2:32
- Location: WA - USA
- Contact:
Glad there is C talent on this forum that should help the emitter project along. Sure wish some of you C guys were interested in a cross platform ANSI C Basic interpreter. ;-)
I now understand what Victor meant by "not for human consumption".
BCX has been in development for over 10 years and it's still evolving.
I now understand what Victor meant by "not for human consumption".
BCX has been in development for over 10 years and it's still evolving.
v1ctor has used every gcc extension to the C standard he could find :) And the list of GCC extensions to the c language is long, very long.
Just check out
http://gcc.gnu.org/onlinedocs/gcc-2.95. ... html#SEC87
One of the extensions is the use of $ in identifiers.
As to compiling, this is what I did to get things working.
I installed the precompiled binaries you can get from this topic
http://www.freebasic.net/forum/viewtopic.php?t=12614
and extracted the zip to c:\beta_fbgcc (path could be anything you want it to be).
Then I copied gcc.exe and cc1.exe to c:\beta_fbgcc\bin\win32. I tried to compile a file but got no result (just errors).
Apparently the libraries could not be be found (cc1 could not be found either) so I copied the essential libraries to c:\beta_fbgcc\bin\win32 and then ran the following command (active directory: c:\beta_fbgcc\bin\win32):
Mind you, I was running gcc from the directoy where gcc was installed so finding cc1.exe was not an issue and as the needed libs were in the same dir as gcc finding those was not a problem either.
Setting the path did not seem to help (that's why I copied the files to the bin directory and ran gcc from there). These are the libraries I copied to bin\win32 to get a 'minimal' program to work:
OS used: Win2K SP4.
Just check out
http://gcc.gnu.org/onlinedocs/gcc-2.95. ... html#SEC87
One of the extensions is the use of $ in identifiers.
As to compiling, this is what I did to get things working.
I installed the precompiled binaries you can get from this topic
http://www.freebasic.net/forum/viewtopic.php?t=12614
and extracted the zip to c:\beta_fbgcc (path could be anything you want it to be).
Then I copied gcc.exe and cc1.exe to c:\beta_fbgcc\bin\win32. I tried to compile a file but got no result (just errors).
Apparently the libraries could not be be found (cc1 could not be found either) so I copied the essential libraries to c:\beta_fbgcc\bin\win32 and then ran the following command (active directory: c:\beta_fbgcc\bin\win32):
resulting in an executable called test.exe...\..\fbc -gen gcc ..\..\test.bas
Mind you, I was running gcc from the directoy where gcc was installed so finding cc1.exe was not an issue and as the needed libs were in the same dir as gcc finding those was not a problem either.
Setting the path did not seem to help (that's why I copied the files to the bin directory and ran gcc from there). These are the libraries I copied to bin\win32 to get a 'minimal' program to work:
- crt2.o
crtbegin.o
crtend.o
dllcrt2.o
fbrt0.o
gcrt2.o
libmingw32.a
libmingwex.a
OS used: Win2K SP4.
NO. Do it yourself. UPX increases the BLOAT of packages.fsw wrote:BTW1: cc1 is pretty big so you could shrink it with upx.
So only those 2 files are required to use the -gen GCC ? Still 6 MiB of additional bloat :-\BTW2: if this approach works for everyone maybe gcc.exe and cc1.exe could be included into the daily builds... (if the resulting build is not to big)
I was unable to compile the Windows version from svn so I went ahead and installed the TDM-GCC from http://www.tdragon.net/recentgcc/ so I could have an updated (ver 4.x) gcc compiler.
Got the latest fb build from the forum
I added a GCC environment variable .
On Win7: control panel -> system -> advanced system settings -> Environment variables -> New -> GCC for variable name and c:/path/to/gcc/gcc.exe
Seems to work fine with -gen gcc although there are many errors and warnings on certain sources where a standard compile issues none.
James
Got the latest fb build from the forum
I added a GCC environment variable .
On Win7: control panel -> system -> advanced system settings -> Environment variables -> New -> GCC for variable name and c:/path/to/gcc/gcc.exe
Seems to work fine with -gen gcc although there are many errors and warnings on certain sources where a standard compile issues none.
James
More that the linker sees object files from various sources whose alignment for fixups don't match. You get this a lot on *nix systems, (particularly non x86, like x86_64 and ppC).fsw wrote: It looks like you have linking problems as the linker doesn't find certain _fb_ functions.
My (admitted wild) guess is that it doesn't work because the runtime lib is compiled with the old CG. Probably all compiled via -gen gcc, or nothing, so that the alignment and other borderconditions for symbols match.