Freebasic 1.20.0 Development

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
SARG
Posts: 1770
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Freebasic 1.20.0 Development

Post by SARG »

thrive4 wrote: Oct 03, 2023 12:24 Brecht Sanders MinGW-W64 reference possibly rather excessive in compiled exe with gcc
An easy way is to change fbextra.x file, located in lib\win64 or lib\win32, by adding this line *(.rdata$zzz). See below modified file.
Doing this remove all the occurances when the compilation is made.

It's also possible to remove them from the executables/objects using objcopy -R .rdata$zzz <executable/object name>
Even usable on the tools/objects provided with Freebasic.

Code: Select all

/* This linker script snippet is passed to ld as an implicit linker script that
   should augment the linker's default linker script. It's supposed to drop the
   objinfo section (FB compile time information) that may be added to some/all
   objects if objinfo was enabled in fbc, since this information is just bloat
   in the final binary. */
SECTIONS
{
  /DISCARD/ :
  {
    *(.fbctinf)
    *(.rdata$zzz)
  }
}
INSERT AFTER .data;

edit : with this small code size 21.5 --> 19.5

Code: Select all

dim as integer a
a=99
erik
Posts: 39
Joined: Dec 28, 2020 17:27
Location: Krasnoyarsk
Contact:

Re: Freebasic 1.20.0 Development

Post by erik »

Improvement: Adding a warning for narrowing data type conversion.

For example:

Code: Select all

Dim Big As LongInt
Dim Small As Short = Big    ' <-- the warning
                                "narrowing conversion, possible data loss"
                                is needed here
Another example:

Code: Select all

Dim Small As Short
Small = &hFFFFFFFF     ' <-- a warning is needed here
More example:

Code: Select all

Dim Big As UInteger
Dim Small As Integer = Big    ' <-- a warning is needed here
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

Re: Freebasic 1.20.0 Development

Post by oyster »

I do expect these features are implemented in freebasic itself, but not as an external lib
1. uniformal index and slice syntax like python does, for string, array and every index-able variant, which supports positive/negative index, omit-able index for slice
2. String Interpolation
3. "for each" for string/array/...
4. raw-string, multiline string without string escaping
5. Universal Function Call Syntax(UFCS), so that `func(variable, arguments)` can be written as `variable.func(arguments)`

`
Last edited by oyster on Jan 08, 2024 5:29, edited 2 times in total.
Xusinboy Bekchanov
Posts: 792
Joined: Jul 26, 2018 18:28

Re: Freebasic 1.20.0 Development

Post by Xusinboy Bekchanov »

Could you please see why this line does not work in fbc 1.20.0 - 64-bit (it works fine in 32-bit):
https://github.com/XusinboyBekchanov/My ... r.bas#L505

But this line works correctly in fbc 1.10.0 in both 32-bit and 64-bit.

This problem was reported in this thread:
https://freebasic.net/forum/viewtopic.p ... 42#p301242
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Freebasic 1.20.0 Development

Post by TJF »

Any compiling by
FreeBASIC Compiler - Version 1.20.0 (2023-05-20), built for linux-arm (32bit)
with backend
gcc (Debian 12.2.0-14) 12.2.0
on kernel
5.19.8 (bookworm)
fails by message
cc1: error: ‘-mfloat-abi=hard’: selected architecture lacks an FPU
but works with option

Code: Select all

fbc -Wc -march=armV7-a+fp test.bas
(overriding the default "-march=armv7-a")

Regards
coderJeff
Site Admin
Posts: 4342
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Freebasic 1.20.0 Development

Post by coderJeff »

TJF wrote: Nov 24, 2023 9:30

Code: Select all

fbc -Wc -march=armV7-a+fp test.bas
(overriding the default "-march=armv7-a")
Do you know an '-march' that would be seen as 'generic' across many targets? I asked around before the fbc 1.10.0 release and sounded like armv7-a was fairly generic - like expectation was that it would be usable on enough systems that a user could bootstrap and build a new fbc and supporting libraries for their particular distro.
Xusinboy Bekchanov
Posts: 792
Joined: Jul 26, 2018 18:28

Re: Freebasic 1.20.0 Development

Post by Xusinboy Bekchanov »

Xusinboy Bekchanov wrote: Nov 22, 2023 6:11 Could you please see why this line does not work in fbc 1.20.0 - 64-bit (it works fine in 32-bit):
https://github.com/XusinboyBekchanov/My ... r.bas#L505

But this line works correctly in fbc 1.10.0 in both 32-bit and 64-bit.

This problem was reported in this thread:
https://freebasic.net/forum/viewtopic.p ... 42#p301242
It turns out that this is a problem with ld.exe, in daily builds the version of ld.exe is 2.24, and in fbc 1.10.0 the version of ld.exe is 2.34, if you install ld.exe version 2.34 in daily builds there will be no problems. SARG found a solution to this problem, thanks to him for that.
Xusinboy Bekchanov
Posts: 792
Joined: Jul 26, 2018 18:28

Re: Freebasic 1.20.0 Development

Post by Xusinboy Bekchanov »

I can't compile this example in version 1.20:
https://github.com/XusinboyBekchanov/Vi ... llaControl

It gives an error:

Code: Select all

21:46:45: Compilation: "D:\FreeBasic\fbc_win64_mingw_0835_2023-11-19\fbc_win64_mingw\fbc.exe"  -b "MDIMain.frm" -v -x "..\MDIScintilla\MDIScintillaControl64.exe" -s gui -i "D:\GitHub\VisualFBEditor\Controls\MariaDBBox" -i "D:\GitHub\VisualFBEditor\Controls\MyFbFramework" -i "D:\GitHub\VisualFBEditor\Controls\ScintillaControl" -i "D:\GitHub\VisualFBEditor\Controls\SQLite3" -i ".\Controls\MyFbFramework\inc" -p ".\Controls\MyFbFramework\Lib" -d _DebugWindow_=67152

21:46:45: FreeBASIC Compiler - Version 1.20.0 (2023-11-19), built for win64 (64bit) 
21:46:45: Copyright (C) 2004-2023 The FreeBASIC development team. 
21:46:45: standalone 
21:46:45: target :       win64, x86-64, 64bit
21:46:45: backend :      gcc
21:46:45: compiling :    MDIMain.frm -o MDIMain.c (main module)
Aborting due to runtime error 3 (file I/O error) at line 66 of src\compiler\lex.bas()

21:46:47: Found Messages (1 Pos).
21:46:47: Do not build file. Elapsed Time: 1,99 Seconds
coderJeff
Site Admin
Posts: 4342
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Freebasic 1.20.0 Development

Post by coderJeff »

Xusinboy Bekchanov wrote: Nov 25, 2023 17:10 I can't compile this example in version 1.20:
https://github.com/XusinboyBekchanov/Vi ... llaControl
1) Looks like a bug *related* to https://sourceforge.net/p/fbc/bugs/994/ where I made recent changes

2) After fixing that - looks like some bad error recovery or other unexpected syntax - never seen this one before, so will have to investigate:
D:\fbrepo\vfbe.git\Examples\MDIScintillaControl>fbc-win64 -b MDIMain.frm -i ../../../mff.git
D:\fbrepo\vfbe.git\Examples\MDIScintillaControl\MDIChild.frm(10) error 23: File not found, "ScintillaControl.bi"
src\compiler\ast-node-call.bas(582): assertion failed at ASTIGNORECALLRESULT: ((n->sym->pattrib and FB_PROCATTRIB_RETURNBYREF) <> 0) =0


3a) And after giving the path to the missing include directory, this looks like should be corrected from user code:
D:\fbrepo\vfbe.git\Examples\MDIScintillaControl>fbc-win64 -b MDIMain.frm -i ../../../mff.git -i ../../Controls/ScintillaControl

Code: Select all

MDIMain.c: In function '_Z13FINDCOUNTWSTRRKwS0_RPu7INTEGER':
MDIMain.c:49982:9: warning: ignoring return value of 'realloc' declared with attribute 'warn_unused_result' [-Wunused-result]
49982 |         realloc( *(void**)FINDS$1, (uint64)((COUNT$1 << (3ll & 63ll)) + 8ll) );
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3b) And this seems unexpected:

Code: Select all

MDIMain.asm: Assembler messages:
MDIMain.asm:19146: Error: unsupported instruction `mov'
Xusinboy Bekchanov
Posts: 792
Joined: Jul 26, 2018 18:28

Re: Freebasic 1.20.0 Development

Post by Xusinboy Bekchanov »

coderJeff wrote: Nov 25, 2023 19:33 3a) And after giving the path to the missing include directory, this looks like should be corrected from user code:
D:\fbrepo\vfbe.git\Examples\MDIScintillaControl>fbc-win64 -b MDIMain.frm -i ../../../mff.git -i ../../Controls/ScintillaControl

Code: Select all

MDIMain.c: In function '_Z13FINDCOUNTWSTRRKwS0_RPu7INTEGER':
MDIMain.c:49982:9: warning: ignoring return value of 'realloc' declared with attribute 'warn_unused_result' [-Wunused-result]
49982 |         realloc( *(void**)FINDS$1, (uint64)((COUNT$1 << (3ll & 63ll)) + 8ll) );
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The controls are located in the IDE Controls folder, but projects can be saved in different folders. The IDE itself enables the selected controls using the -i switch (-i "D:\GitHub\VisualFBEditor\Controls\ScintillaControl").
coderJeff
Site Admin
Posts: 4342
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Freebasic 1.20.0 Development

Post by coderJeff »

Xusinboy Bekchanov wrote: Nov 25, 2023 20:41
re 1) SARG sent you an updated fbc.exe, and sounded like it worked OK. I will patch fbc soon. Thank-you for testing.

re 2) I will investigate later it looks like bad error recovery only, and not bad code generation.

re 3a) The result of Reallocate() is thrown away - you can fix it
https://github.com/XusinboyBekchanov/Vi ... t.bas#L138

re 3b) This ASM block looks like is for 32-bit only, and hacks on fbc string internals
https://github.com/XusinboyBekchanov/Vi ... ct.bas#L72
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Freebasic 1.20.0 Development

Post by TJF »

coderJeff wrote: Nov 25, 2023 11:35 Do you know an '-march' that would be seen as 'generic' across many targets?
Thanks for your attention, but no, sorry. I just trial-and-error tested findings from the internet. The solution at least runs on a BeagleBoneBlack with TI am3358 CPU.

BTW, I found an other issue: this code (minimal extract from https://github.com/dtjf/libpruio)

Code: Select all

#DEFINE PRUIO_DEF_AVRAGE  0
#DEFINE PRUIO_DEF_SDELAY  0
#DEFINE PRUIO_DEF_ODELAY  0

TYPE AS UBYTE UInt8
TYPE AS ULONG UInt32

TYPE AdcSteps
  AS UInt32 _
    Confg _ '*< Context for configuration register.
  , Delay   '*< Context for delay register.
END TYPE

TYPE AdcSet
'...
  AS AdcSteps St_p(16)
'...
END TYPE

TYPE AdcUdt
'...
  AS AdcSet PTR _
    Init _     '*< Initial subsystem configuration, used in the destructor PruIo::~PruIo().
  , Conf       '*< Current subsystem configuration, used in PruIo::config().
'...
  DECLARE FUNCTION setStep CDECL( _
    BYVAL AS UInt8 _
  , BYVAL AS UInt8 _
  , BYVAL AS UInt8  = PRUIO_DEF_AVRAGE _
  , BYVAL AS UInt8  = PRUIO_DEF_SDELAY _
  , BYVAL AS UInt32 = PRUIO_DEF_ODELAY) AS ZSTRING PTR
END TYPE

FUNCTION AdcUdt.setStep CDECL( _
    BYVAL Stp AS UInt8 _
  , BYVAL ChN AS UInt8 _
  , BYVAL  Av AS UInt8  = PRUIO_DEF_AVRAGE _
  , BYVAL SaD AS UInt8  = PRUIO_DEF_SDELAY _
  , BYVAL OpD AS UInt32 = PRUIO_DEF_ODELAY) AS ZSTRING PTR
'...
  WITH *Conf.St_p(Stp)
    VAR a = ABS((Av > 1) + (Av > 2) + (Av > 4) + (Av > 8))
    .Confg = (a SHL 2) + (ChN SHL 19)
    .Delay = (OpD AND &h3FFFF) + (SaD SHL 24)
  END WITH : RETURN 0
END FUNCTION
compiled with former versions but fails in 1.20 by message
$ fbc -Wc -march=armV7-a+fp 1-20.bas
1-20.bas(44) error 265: Symbol not a CLASS, ENUM, TYPE or UNION type, before '.' in 'WITH *Conf.St_p(Stp)'
1-20.bas(46) error 18: Element not defined, Confg in '.Confg = (a SHL 2) + (ChN SHL 19)'
1-20.bas(47) error 18: Element not defined, Delay in '.Delay = (OpD AND &h3FFFF) + (SaD SHL 24)'
But it's working when using nested WITH blocks like

Code: Select all

  ''WITH *Conf.St_p(Stp)
  WITH *Conf
  WITH .St_p(Stp)
  '...
Regards
Xusinboy Bekchanov
Posts: 792
Joined: Jul 26, 2018 18:28

Re: Freebasic 1.20.0 Development

Post by Xusinboy Bekchanov »

coderJeff wrote: Nov 25, 2023 21:03
Xusinboy Bekchanov wrote: Nov 25, 2023 20:41
re 3a) The result of Reallocate() is thrown away - you can fix it
https://github.com/XusinboyBekchanov/Vi ... t.bas#L138
Thanks, I fixed it. This had not been noticed by me before. This was an example from one of the IDE users.
https://github.com/XusinboyBekchanov/Vi ... 8a7947ddab
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Freebasic 1.20.0 Development

Post by TJF »

coderJeff wrote: Nov 25, 2023 11:35 Do you know an '-march' that would be seen as 'generic' across many targets?
What about omitting the -march option?
$ /usr/bin/../bin/gcc -march=armv7-a -S -nostdlib -nostdinc -Wall -Wno-unused -Wno-main -Werror-implicit-function-declaration -O0 -fno-strict-aliasing -frounding-math -fno-math-errno -fwrapv -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables -Wno-format "1-20.c" -o "1-20.asm"
cc1: error: ‘-mfloat-abi=hard’: selected architecture lacks an FPU
$ /usr/bin/../bin/gcc -S -nostdlib -nostdinc -Wall -Wno-unused -Wno-main -Werror-implicit-function-declaration -O0 -fno-strict-aliasing -frounding-math -fno-math-errno -fwrapv -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables -Wno-format "1-20.c" -o "1-20.asm"
$
Regards
coderJeff
Site Admin
Posts: 4342
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Freebasic 1.20.0 Development

Post by coderJeff »

TJF wrote: Nov 26, 2023 1:44 BTW, I found an other issue: this code (minimal extract from https://github.com/dtjf/libpruio)
Looks like a variation of this bug https://sourceforge.net/p/fbc/bugs/811/
We fixed operator precedence in fbc 1.10.0

Code: Select all

WITH *Conf.St_p(Stp)
must now be:

Code: Select all

WITH (*Conf).St_p(Stp)
Post Reply