Problem with 64 bit gcc 8.4 by dodicat (split from 25215)

General FreeBASIC programming questions.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Problem with 64 bit gcc 8.4 by dodicat (split from 25215)

Post by dodicat »

Problem with 64 bit gcc 8.4

trying to build an optimised dll
command
-Wc -O3 -dll -export

Warning: .drectve `ƒìƒ|$$t¸' unrecognized
Warning: .drectve `ƒÄÂ' unrecognized
Warning: .drectve `ÇD$' unrecognized
Warning: .drectve `ÇD$' unrecognized
Warning: .drectve `Ç$' unrecognized
Warning: .drectve `è' unrecognized
Warning: .drectve `ƒì¸' unrecognized
Warning: .drectve `ƒÄÂ' unrecognized
Warning: .drectve `UWVSƒìL‹t$`‹|$d‰ðƒð ø”À%ÿ' unrecognized
Warning: .drectve `÷؉ñƒñ ù”Áãÿ' unrecognized
Warning: .drectve `‰Ý÷Ý Å…j' unrecognized
Warning: .drectve `ÇD$' unrecognized
Warning: .drectve `ÇD$' unrecognized
Warning: .drectve `‰4$‰|$è' unrecognized
Warning: .drectve `Âu‰èƒÄL[^_]Â' unrecognized
Warning: .drectve `ÇD$' unrecognized
Warning: .drectve `ÇD$' unrecognized
Warning: .drectve `‰4$‰|$è' unrecognized
Warning: .drectve `Ât̉t$‰|$ßl$…ÿyØ' unrecognized
Warning: .drectve `Ý\$8ÝD$8ÙúØ' unrecognized
Warning: .drectve `Ý$è' unrecognized
Warning: .drectve `Ù' unrecognized
Warning: .drectve `ÙÉØÑßàöÄ„Ý' unrecognized
Warning: .drectve `ÝÙÙ|$6f‹D$6€Ìf‰D$4Ùl$4ß|$ Ùl$6¸' unrecognized
Warning: .drectve `‹L$ ‹\$$9ȸ' unrecognized
Warning: .drectve `ع' unrecognized
Warning: .drectve `»' unrecognized
Warning: .drectve `ƒŽ' unrecognized
Warning: .drectve `‰È‰Ú‰L$‰\$ƒÀÿƒÒÿ‰D$‰T$‰4$‰|$è' unrecognized
Warning: .drectve `‹L$‹\$„ÿÿÿ‰È‰Ú‰L$‰\$ƒÀƒÒ' unrecognized
Warning: .drectve `‰D$‰T$‰4$‰|$è' unrecognized
Warning: .drectve `„Øþÿÿ‹L$‹\$ƒÁƒÓ' unrecognized
Warning: .drectve `‹D$ ‹T$$9ȉÐ؃zÿÿÿ½ÿÿÿÿé¬þÿÿÞáÙ|$6f‹D$6€Ìf‰D$4Ùl$4ß|$(Ùl$6‹L$(‹\$,‰Ø' unrecognized
Warning: .drectve `€‰L$ ‰D$$éÿÿÿ' unrecognized
creating import library: C:\Users\Computer\Desktop\fb\WinFBE_Suite\FreeBASIC-1.07.1-gcc-8.4\bin\win32\dlltool.exe --def
...
...
The dll is built, but it fails.
No problem with
FreeBASIC Compiler - Version 1.07.2 (2020-12-25), built for win64 (64bit) (gcc 5.2)
Note also the same problem with gcc 8.1
Can I assume other gcc 8.x have the same problem, probably not, but I can only test gcc 8.1 and 8.4
The test code is very simple.
isprime.bas to an optimised .dll

Code: Select all

 Function isaprime(n As ulongint) As long export
    If (n=2) Or (n=3) Then Return -1
    If n Mod 2 = 0 Then return 0
    If n Mod 3 = 0 Then return 0
    Dim As ulongint limit=Sqr(N)+1
    For I As ulongint = 6 To limit Step 6
        If N Mod (i-1) = 0 Then return 0
        If N Mod (i+1) = 0 Then return 0
    Next I
    Return -1
End Function

 
deltarho[1859]
Posts: 4308
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: WinFBE Editor and FreeBASIC Compiler (All-in-One Package) (V2.2.0 March 26, 2021)

Post by deltarho[1859] »

dodicat wrote:Problem with 64 bit gcc 8.4
The problem is much wider than that.

We get all those warnings with 32 bit as well.

We get all those warnings with later versions of gcc.

In fact this is what happens:

gcc versions 5 and 6: No problems with all optimization levels.

gcc versions 7, 8, 9, 10, and 11: No problems with no optimization. Problems with all optimization levels -O1, -O2 and -O3.

gcc gets better with each new version. There are a few benchmark websites to prove that. However, from my experience gcc 8.3 is the best for FreeBASIC.

gcc is not just used with FreeBASIC. Is anyone else having our problems? I am confident that there are some aspects of fbc which are so ancient they cause issues with the latest versions of gcc.

In my opinion then the culprit is not gcc but fbc.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: WinFBE Editor and FreeBASIC Compiler (All-in-One Package) (V2.2.0 March 26, 2021)

Post by dodicat »

Thanks srvaldez.
Of course there is no problem optimising -O3 e.t.c. when compiling a .c file to .exe file with versions 8.x gcc (I have 8.1 in my 64 bit mingw)
There is a problem optimising -O3 e.t.c. when compiling a .bas file to .exe file with fb with versions 8.x gcc .(as discussed by deltarho[])
(The .x here is either .1 or .4, I have not tested other 8.x)
For a dll, using isprime.c say and using gcc 8.1
e.g.
gcc -O3 isprime.c -shared -o isprimeO3.dll -Wl,--kill-at,--output-def,isprimeO3.def,--out-implib,libcisprimeO3.a
to get isprimeO3.dll
No warnings, but the optimisation doesn't work, the function runs no faster than without -O3.
I don't have a gcc lower than 8.1 in a mingw to test.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: WinFBE Editor and FreeBASIC Compiler (All-in-One Package) (V2.2.0 March 26, 2021)

Post by srvaldez »

dodicat, I have found that sometimes an exe compiled with -O3 is actually slower in execution than if compiled with -O2, overall I prefer -O2 because it's safer
[edit]
apologies to Paul Squires for the off-topic posts
Last edited by srvaldez on Mar 29, 2021 12:28, edited 1 time in total.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: WinFBE Editor and FreeBASIC Compiler (All-in-One Package) (V2.2.0 March 26, 2021)

Post by dodicat »

Hi srvaldez, I tried O1, O2, O3, -Ofast with gcc 8.1 (64 bit 1.07.3) and 8.4.(from the WinFBE Editor -- 1.07.1)
No dll, just a straight compile a .bas file.
Problem--
-O1 ERROR in compile with many warnings
-O2 many warnings, .exe runs with no optimisation, or runs with error.
-O3 -- similar to O2---
-Ofast runs with no optimisation.
I have always been using gcc 5.2 before (official build), I didn't realize there were problems with gcc 8.x )
deltarho[1859]
Posts: 4308
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: WinFBE Editor and FreeBASIC Compiler (All-in-One Package) (V2.2.0 March 26, 2021)

Post by deltarho[1859] »

I have a lot of builds archived. I don't have all of them available in WinFBE's SetCompilerPathsII.

However, this is what I do have.

Code: Select all

8.3 1.07.1
8.3 1.07.2
8.3 1.08
8.4 1.07.1
The 8.4 1.07.1 was WinFBE's V2.17 default. I am now on V2.20 so downloaded V2.17 again. According to 'gcc.exe -v' we have 'gcc version 8.4.0 (MinGW-W64 x86_64-posix-dwarf, built by Brecht Sanders)'. With a file comparison this is identical to my 8.4 1.07.1 so I will assume I got it from WinFBE. V2.20 is back on fbc 5.2. Paul changes the default as often as I change socks. Image

The 8.3 1.07.1 gcc has a modified date of 29 Sept 2019 so I have been using that for 18 months; with very few issues. That build was from Equation Solution and built by srvaldez.

The 8.3 1.07.2 and 8.3 1.08 are updates by me.

The point of the above ramblings is that all of them are working on "No dll, just a straight compile a .bas file." without any issues.

The reason why I have so many gcc 8 builds is because I am a big fan of gcc 8.x.

The reason why I bothered to do the above is because I have been trying to get folk to consider something other than fbc 5.2 for quite some time now. The last thing that I want to see is "I didn't realize there were problems with gcc 8.x" when I don't have any.

What we need is for anyone, preferably more than one, to try and compile dodicats's code as an exe with gcc 8.x - ie no 'export'. If they come back OK, then we have an issue with dodicat's setup and not gcc 8.x.

@srvaldez

You must have a few gcc 8.x versions. What are you getting?
deltarho[1859]
Posts: 4308
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: WinFBE Editor and FreeBASIC Compiler (All-in-One Package) (V2.2.0 March 26, 2021)

Post by deltarho[1859] »

Brecht Sanders?

Found him: WinLibs

We have 7.5.0, 8.4.0, 9.3.0, 10.2.0

It will take quite a bit to get me off 8.3/-O2.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: WinFBE Editor and FreeBASIC Compiler (All-in-One Package) (V2.2.0 March 26, 2021)

Post by dodicat »

I am compiling raw command line.
example
fbc -gen gcc -Wc -O1
No -v or -x or -m (as in WinFBE), which seem fixed.
If I use (command line)
fbc -gen gcc -Wc -O1 -exx
it is fine.
But
fbc -gen gcc -Wc -O1
doesn't compile a file, and O2 and O3 have the results I stated above.
I am not compiling via WinFBE.
I get the errors with fbedit also
example:

Code: Select all

Build error(s)
C:\Users\Computer\Desktop\fb\FreeBASIC-1.07.3-win64-gcc-8.1.0\FreeBASIC-1.07.3-win64-gcc-8.1.0\fbc -gen gcc -Wc -O3 "isprimeopt.bas"
Warning: .drectve `V1ÒSHƒì(Hƒù”Â1À÷ÚHƒù”À‰Ö÷Ø	Æ…ø' unrecognized
Warning: .drectve `I‰ÈAƒà„ð' unrecognized
Warning: .drectve `Hº«ªªªªªªªH‰ÈH÷âHÑêHRH9Á„Ð' unrecognized
Warning: .drectve `H…ɈÔ' unrecognized
Warning: .drectve `fïÀòH*ÁòQÀòX' unrecognized
Warning: .drectve `H‰Ëè' unrecognized
Warning: .drectve `ò
' unrecognized
Warning: .drectve `f/ÁƒÅ' unrecognized
Warning: .drectve `òL,ÐIƒú†„' unrecognized
Warning: .drectve `HºÍÌÌÌÌÌÌÌH‰ØH÷âHÁêH’H9ÃtlH‰Ø¹' unrecognized
Warning: .drectve `Hº“$I’$I’$H÷âH‰ØH)ÐHÑèHÂHÁêHÕ' unrecognized
Warning: .drectve `H)ÐH9Ãu)ë5' unrecognized
Warning: .drectve `LIH‰Ø1ÒI÷ñH…Òt"HƒÁH‰Ø1ÒH÷ñL‰ÁH…ÒtLAM9ÂsÒ¾ÿÿÿÿHƒÄ(‰ð[^Ã' unrecognized
Warning: .drectve `H‰ÈfïÀHÑèL	ÀòH*ÀòXÀéÿÿÿ' unrecognized
Warning: .drectve `ò\ÁòL,ÐIºú?é-ÿÿÿ' unrecognized

Make done
 
I cannot test with fbide of course because of the lower case error.
NOTE:
I get the same problem with vanya's ide (IUP_FB Editor)
A pile of warnings with -O3
deltarho[1859]
Posts: 4308
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: WinFBE Editor and FreeBASIC Compiler (All-in-One Package) (V2.2.0 March 26, 2021)

Post by deltarho[1859] »

I repeat:

"What we need is for anyone, preferably more than one, to try and compile dodicats's code as an exe with gcc 8.x - ie no 'export'. If they come back OK, then we have an issue with dodicat's setup and not gcc 8.x."

If this was the PowerBASIC forum I would have had at least half a dozen responses to that in about an hour. With this forum such a request lands on deaf ears as is almost invariably the case. Different class of membership altogether. Image I don't know why I bother sometimes.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: Problem with 64 bit gcc 8.4 by dodicat

Post by srvaldez »

in reference to viewtopic.php?p=281713#p281713
deltarho[1859] wrote:...
What we need is for anyone, preferably more than one, to try and compile dodicats's code as an exe with gcc 8.x - ie no 'export'. If they come back OK, then we have an issue with dodicat's setup and not gcc 8.x.

@srvaldez

You must have a few gcc 8.x versions. What are you getting?
without the export there are no problems compiling and running dodicat's isaprime code
tried gcc versions 8.1, 8.3, 8.4, 9.3 and 11
the export is what triggers the problem, perhaps an invalid link command option is generated, who knows
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: Problem with 64 bit gcc 8.4 by dodicat

Post by srvaldez »

the only thing that's different when using the export keyword is that it generates

Code: Select all

__asm__( 
	".section .drectve\n"
	"\t.ascii \" -export:\\\"ISAPRIME\\\"\"\n"
);
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Problem with 64 bit gcc 8.4 by dodicat

Post by dodicat »

You can use this simple test code.

Code: Select all

 Function isaprime(n As ulongint) As long export
    If (n=2) Or (n=3) Then Return -1
    If n Mod 2 = 0 Then return 0
    If n Mod 3 = 0 Then return 0
    Dim As ulongint limit=Sqr(N)+1
    For I As ulongint = 6 To limit Step 6
        If N Mod (i-1) = 0 Then return 0
        If N Mod (i+1) = 0 Then return 0
    Next I
    Return -1
End Function

print "Please wait . . ."
dim as double t=timer
print isaprime(18446744073709551557)
print timer-t
sleep


'compile fbc -Wc -O3 in a freebasic distro using gcc 8.something.
'for instance Version 1.07.3 Win 64 release with gcc 8.1.
'Please do not use WinFBE Editor for this test.

 
Please do not use WinFBE editor for this test.
for example using fbedit
options
build options
command
fbc -gen gcc -Wc -O3
Using FreeBASIC-1.07.3-win64-gcc-8.1.0 (The latest official build)
My result with fbedit:

Code: Select all

Warning: .drectve `V1ÒSHƒì(Hƒù”Â1À÷ÚHƒù”À‰Ö÷Ø	Æ…ø' unrecognized
Warning: .drectve `I‰ÈAƒà„ð' unrecognized
Warning: .drectve `Hº«ªªªªªªªH‰ÈH÷âHÑêHRH9Á„Ð' unrecognized
Warning: .drectve `H…ɈÔ' unrecognized
Warning: .drectve `fïÀòH*ÁòQÀòX' unrecognized
Warning: .drectve `H‰Ëè' unrecognized
Warning: .drectve `ò
 ' unrecognized
Warning: .drectve `f/ÁƒÅ' unrecognized
Warning: .drectve `òL,ÐIƒú†„' unrecognized
Warning: .drectve `HºÍÌÌÌÌÌÌÌH‰ØH÷âHÁêH’H9ÃtlH‰Ø¹' unrecognized
Warning: .drectve `Hº“$I’$I’$H÷âH‰ØH)ÐHÑèHÂHÁêHÕ' unrecognized
Warning: .drectve `H)ÐH9Ãu)ë5' unrecognized
Warning: .drectve `LIH‰Ø1ÒI÷ñH…Òt"HƒÁH‰Ø1ÒH÷ñL‰ÁH…ÒtLAM9ÂsÒ¾ÿÿÿÿHƒÄ(‰ð[^Ã' unrecognized
Warning: .drectve `H‰ÈfïÀHÑèL	ÀòH*ÀòXÀéÿÿÿ' unrecognized
Warning: .drectve `ò\ÁòL,ÐIºú?é-ÿÿÿ' unrecognized

Make done
 
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: Problem with 64 bit gcc 8.4 by dodicat

Post by srvaldez »

dodicat
it appears that gcc 8.1 and above don't like the generated export code

Code: Select all

__asm__(
   ".section .drectve\n"
   "\t.ascii \" -export:\\\"ISAPRIME\\\"\"\n"
);
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Problem with 64 bit gcc 8.4 by dodicat

Post by dodicat »

Looks like it srvaldez.
It also doesn't like creating optimised dll's.
Post Reply