GCC compiler question

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

GCC compiler question

Post by UEZ »

deltarho[1859] wrote:
UEZ wrote:The compiler / gcc stuff is at the moment a little bit mystery to me...
In what way?
I opened a new topic not to hijack the Wormhole effect one.

How can I use gcc from different resources such as MiniGW or mingw-w64? If I download the Windows binaries and copy gcc to FreeBASIC\bin\win32\, FreeBASIC\bin\libexec\gcc\ then usually it doesn't work.

How it the concept to use such sources within FB? What must I do?
deltarho[1859]
Posts: 4310
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: GCC compiler question

Post by deltarho[1859] »

That is as much as a mystery to me as it is to you. One thing that I do know is that it is much more complicated than simply replacing one gcc with another and it is easy to get it wrong.

There are a few guys on the forum who are well acquainted with building gcc toolchains so perhaps one of them will be good enough to help you.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: GCC compiler question

Post by srvaldez »

@UEZ
from my experience, different mingw-gcc tool-chains have different dependencies for the gcc and binutils like as, ld and ar
you would need to include those dependency DLL's also, unless you use fbc that's integrated in the mingw toolchain
also, msys2 has a different directory structure, instead of having cc1.exe in libexec it has it in lib
but there's one major disadvantage of using the msys2 toolchain for standalone FB distribution, it has a bunch of dependency DLL's that must be included, you can use the Explorer Suite https://ntcore.com/?page_id=388 to see the dendencies of a dll or exe
also, some libraries compiled with gcc are not compatible between different gcc versions, for example gmp
I think that it also applies to libraries and dll's compiled with FB, so you really should build FB with the respective gcc version rather than simply copying different gcc versions into the FB distribution
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: GCC compiler question

Post by Tourist Trap »

UEZ wrote: How it the concept to use such sources within FB? What must I do?
For instance, I downloaded gcc-8.1.0-for-FB-win32-gengcc:
gcc-8.1.0-for-FB-win32-gengcc/
...bin/
......libexec/
......win32/
What to do next?
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: GCC compiler question

Post by srvaldez »

@TT
you copy libexec to FreeBASIC-1.07.1-win32-gcc-8.1.0/bin and copy the gcc.exe that's in win32 to FreeBASIC-1.07.1-win32-gcc-8.1.0/bin/win32
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: GCC compiler question

Post by systemctl »

Too cubersome. What if I could compile FreeBASIC from source on environments like Cygwin or MSYS2? I think we just need minor changes in the build script since the directory structure of them is just like what on Linux. Anyway, do you wonder the same as me why FreeBASIC is not packaged by Linux distributions although it license is totally compatible? Nearly all of the distros have packages for Free Pascal and Lazarus but not FreeBASIC. And if we changed the build script to make it possible we could just ask the Cygwin or MSYS2 maintainer to include a FreeBASIC package. No need to compile from source. Just fire up the package manager and done.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: GCC compiler question

Post by srvaldez »

systemctl wrote:Too cubersome. What if I could compile FreeBASIC from source on environments like Cygwin or MSYS2?
you can build it with msys2 no problems, although I prefer to use a different gcc toolchain than what msys2 provides due to the dll dependencies
but you can use the msys2 shell using a different gcc toolchain, simply copy the distribution of your choice into msys64 and you are good to go, but I would stay away from updating msys2 using pacman after that.
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

Re: GCC compiler question

Post by UEZ »

@srvaldez: I had also the experience that gcc and its tools have dependency (imports) to other lib*.dll files but at the end when all needed DLL were copied although compiling is not possible. I can see several sub directories in FreeBASIC\bin\libexec\gcc\. Why are they different? Why subdirectories at all for one file called cc1.exe? For version 8.1.0 it is i686-w64-mingw32. Maybe I've just copied some of the gcc releases and that's the reason for several folders...

With WinFBE and ctools by deltarho[1859] I can switch between the different gcc versions. That's a great addition.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: GCC compiler question

Post by srvaldez »

the gcc toolchain provided by equation are statically linked, only standard Windows dll dependencies like msvcrt.dll or user32.dll
I don't know about compiler internals, obviously FB and gcc use certain directory structures to function.
TeeEmCee
Posts: 375
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: GCC compiler question

Post by TeeEmCee »

I would suggest not combining the FB and GCC/msys directory trees, so you can more cleanly upgrade. On Windows I have msys/mingw and multiple FB versions all in separate directories, and switch between them by changing my PATH. You just need to install a copy of FB that's built either for mingw or mingw-w64 as appropriate, and doesn't include GCC.

(Offtopic: On the topic of msvcrt.dll, both mingw and mingw-w64 run against msvcrt.dll which is present on Windows 95+, while anything compiled with Visual C++ will probably depend on a versioned CRT runtime .dll that needs to be shipped with the .dll. Newer versions of Windows do include some bugfixes to msvcrt.dll but the ABI and semantics are unchanged. mingw and mingw-w64 wrap some of the functions in msvcrt.dll to make them C99-conformant.)
marcov
Posts: 3462
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: GCC compiler question

Post by marcov »

systemctl wrote:Nearly all of the distros have packages for Free Pascal and Lazarus but not FreeBASIC.
It is often just a matter of getting somebody to do the work, but maintaining some reference (or last known good) debian package files (Ubuntu, Debian) and RPM spec (Fedora,Suse etc) files definitely helps. Most of the work was done by FPC devels or users.

The only exception is Raspbian, because a longtime FPC user was one of the founders :-)

Getting the package accepting required making them understand self-bootstrapping, which is a whole different ballpark though. It required patience to defer endless questions like "can't you use translator X" or "can't you rewrite in C" etc etc, till they just gave up, and maintain an own bootstrapping chain based on known good binaries.

P.s. we still maintain standalone binaries from before msys.... (C) 2005.
Post Reply