GCC Version requirements to compile FB

Linux specific questions.
dodicat
Posts: 7525
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: GCC Version requirements to compile FB

Post by dodicat »

my assembler:
GNU assembler version 2.38 (x86_64-w64-mingw32) using BFD version (Binutils for MinGW-W64 x86_64, built by Brecht Sanders) 2.38
I am still nearly sure -gen gas64 worked on my first try.
srvaldez
Posts: 3027
Joined: Sep 25, 2005 21:54

Re: GCC Version requirements to compile FB

Post by srvaldez »

I am inclined to think that there's something wrong with the Dir function or the "Dir.bi" or both
adeyblue
Posts: 197
Joined: Nov 07, 2019 20:08

Re: GCC Version requirements to compile FB

Post by adeyblue »

I think my ld is from nuwen not winlibs and SARG's

Code: Select all

Dir("*.*")
print "END"
Sleep
works here

Code: Select all

C:\shared\FBSamples>%newfbc64% -gen gas64 -v dir2.bas
FreeBASIC Compiler - Version 1.10.0 (2022-06-20), built for win64 (64bit)
Copyright (C) 2004-2022 The FreeBASIC development team.
standalone
target:       win64, x86-64, 64bit
backend:      gas64
compiling:    dir2.bas -o dir2.asm (main module)
assembling:   C:\freebasic\bin\win64\as.exe --64 --strip-local-absolute "dir2.asm" -o "dir2.o"
linking:      C:\freebasic\bin\win64\ld.exe -m i386pep -o "dir2.exe" -subsystem console -T "C:\freebasic\lib\win64\fbextra.x" --stack 2097152,2097152 -L "C:\freebasic\lib\win64" -L "." "C:\freebasic\lib\win64\crt2.o" "C:\freebasic\lib\win64\crtbegin.o" "C:\freebasic\lib\win64\fbrt0.o" "dir2.o" "-(" -lfb -lgcc -lmsvcrt -lkernel32 -luser32 -lmingw32 -lmingwex -lmoldname -lgcc_eh "-)" "C:\freebasic\lib\win64\crtend.o"

C:\shared\FBSamples>dir2
END

C:\shared\FBSamples>C:\freebasic\bin\win64\ld.exe --version
GNU ld (GNU Binutils) 2.38
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

C:\shared\FBSamples>C:\freebasic\bin\win64\as.exe --version
GNU assembler (GNU Binutils) 2.33.1
Copyright (C) 2019 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-w64-mingw32'.

C:\Users\Adrian\desktop>dumpbin /headers \\operavirt\shared\fbsamples\\dir2.exe | more
Microsoft (R) COFF/PE Dumper Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file \\operavirt\shared\fbsamples\\dir2.exe

PE signature found

File Type: EXECUTABLE IMAGE

FILE HEADER VALUES
            8664 machine (x64)
              12 number of sections
        62C333BE time date stamp Mon Jul 04 19:38:54 2022
           49200 file pointer to symbol table
             996 number of symbols
              F0 size of optional header
              26 characteristics
                   Executable
                   Line numbers stripped
                   Application can handle large (>2GB) addresses

OPTIONAL HEADER VALUES
             20B magic # (PE32+)
            2.38 linker version
            5800 size of code
            9200 size of initialized data
            B600 size of uninitialized data
            14F0 entry point (00000001400014F0)
            1000 base of code
       140000000 image base (0000000140000000 to 000000014005EFFF)
            1000 section alignment
             200 file alignment
            4.00 operating system version
            0.00 image version
            5.02 subsystem version
               0 Win32 version
           5F000 size of image
             600 size of headers
           64EE5 checksum
               3 subsystem (Windows CUI)
             160 DLL characteristics
                   High Entropy Virtual Addresses
                   Dynamic base
                   NX compatible
          200000 size of stack reserve
          200000 size of stack commit
          100000 size of heap reserve
            1000 size of heap commit
               0 loader flags
              10 number of directories
               0 [       0] RVA [size] of Export Directory
           18000 [     CB0] RVA [size] of Import Directory
               0 [       0] RVA [size] of Resource Directory
            A000 [     24C] RVA [size] of Exception Directory
               0 [       0] RVA [size] of Certificates Directory
           1B000 [      88] RVA [size] of Base Relocation Directory
               0 [       0] RVA [size] of Debug Directory
               0 [       0] RVA [size] of Architecture Directory
               0 [       0] RVA [size] of Global Pointer Directory
            8400 [      28] RVA [size] of Thread Storage Directory
               0 [       0] RVA [size] of Load Configuration Directory
               0 [       0] RVA [size] of Bound Import Directory
           18308 [     2B8] RVA [size] of Import Address Table Directory
               0 [       0] RVA [size] of Delay Import Directory
               0 [       0] RVA [size] of COM Descriptor Directory
               0 [       0] RVA [size] of Reserved Directory
----
Edit: Just downloaded current Winlibs (msvcrt) and it doesn't crash with that ld and as either. Neither does Avata's original code, optimisations or not, with the winlibs GCC 12.1 or Gas64. Weird.
C:\shared\FBSamples>C:\freebasic\bin\win64\as.exe --version
GNU assembler (Binutils for MinGW-W64 x86_64, built by Brecht Sanders) 2.38
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms ofthe GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-w64-mingw32'.

C:\shared\FBSamples>C:\freebasic\bin\win64\ld.exe --version
GNU ld (Binutils for MinGW-W64 x86_64, built by Brecht Sanders) 2.38
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms ofthe GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
Maybe it's the support files being built differently? I only swapped in the ld, as and gcc exes (and the gcc libexec folder), everything in my 64-bit lib directory is from June last year.
----
Edit edit: fbc64 / libfb from the daily builds and everything else from winlibs-x86_64-posix-seh-gcc-12.1.0-mingw-w64msvcrt-10.0.0-r2.7z and both still works fine. Super weird
SARG
Posts: 1493
Joined: May 27, 2005 7:15
Location: FRANCE

Re: GCC Version requirements to compile FB

Post by SARG »

I got ld and as from nuwen (version 2.37) ---> always a crash.
Indeed very weird.

I'll install a full and fresh 1.09 and change ld.

Edit : with the fresh install if ld is changed either winlibs 2.38 or nuwen 2.37 --> crash
adeyblue
Posts: 197
Joined: Nov 07, 2019 20:08

Re: GCC Version requirements to compile FB

Post by adeyblue »

Ah ok, now I see. The exes work on Windows 7, they don't on recent Server 2019 17763.

Anyway, it's very likely because of this
https://github.com/freebasic/fbc/blob/0 ... _dir.c#L17

It looks like the handle from FindFirstFile has become a memory allocation on Win10 instead of just a handle, and with the extra exe flags from new mingw, it's more likely to be a full 64-bit value and if it is, the address gets chopped in half and it don't work.

Fixed
https://github.com/freebasic/fbc/pull/380
SARG
Posts: 1493
Joined: May 27, 2005 7:15
Location: FRANCE

Re: GCC Version requirements to compile FB

Post by SARG »

Not easy to find. Congratulations :D

Indeed while debugging I saw that a value > 32bit caused the crash and no crash if value <32bit. But it was a parameter in a system function so not easy to understand the initial reason of the crash.
coderJeff
Site Admin
Posts: 3942
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: GCC Version requirements to compile FB

Post by coderJeff »

Update: adeyblue's fix is merged to fbc/master. Thanks.
Axle
Posts: 41
Joined: May 31, 2022 6:49
Location: Australia

Re: GCC Version requirements to compile FB

Post by Axle »

Coolman wrote: Jul 03, 2022 10:47 hello. always use the default gcc version of a linux distribution to compile programs. for example i installed in a lxd container (ubuntu 20.04) gcc version 11 to test compare the speed of a program... when i transferred it to the real system, it didn't work because it was incompatible with GLIBC. note that with gcc 10, it worked. probably this version doesn't depend on a different version of GLIBC. in any case, to avoid problems, stick to the official gcc version.
The current Gcc Version (default) for 20.04 is 9.4.0 so I have stayed with that. I'll see how it rolls when I test the FB raylib/gui binders with it.

Thank you
Axle
Post Reply