Author Topic: Names of compiler executables: Self-built vs Official  (Read 15084 times)

Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 57
Names of compiler executables: Self-built vs Official
« on: June 30, 2021, 05:09:59 pm »
I have installed Code::Blocks (Release 20.03  rev 11983 (2020-03-12 18:24:30)   gcc 8.1.0 Windows/unicode - 64 bit) where I have created several compiler configurations for a GCC compiler (using MSYS2 mingw64 toolchains), one of them is set as the default. All works fine as expected.

However, when I launch a nightly (svn12446) or a self-built C::B (commit da3cdd7), I get notified that a compiler executable was not found. When checking the executable names, I have noticed that in the nightly/self-built CB, the names for GCC and G++ executables are wrongly prefixed with "mingw32-":


When I launch the CB v20.03 after that, the names are thankfully still correct:


The original "GNU GCC Compiler" is affected in the same way.

Any ideas what am I doing wrong?
« Last Edit: June 30, 2021, 05:18:42 pm by PB »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Names of compiler executables: Self-built vs Official
« Reply #1 on: June 30, 2021, 06:19:56 pm »
It is likely the auto compiler detect code that did the change.

But, a dev said no to me adding a feature to disable it!

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Names of compiler executables: Self-built vs Official
« Reply #2 on: June 30, 2021, 07:15:54 pm »
Try this patch and let me know if it works: https://sourceforge.net/p/codeblocks/tickets/374/#13f6
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 57
Re: Names of compiler executables: Self-built vs Official
« Reply #3 on: June 30, 2021, 07:27:05 pm »
Try this patch and let me know if it works: https://sourceforge.net/p/codeblocks/tickets/374/#13f6

I will, assuming I can manage it.

Just for the record:
1. I did not press <Autodetect> in compiler settings.
2. Those two compilers are named like that (no "mingw32-" prefix) also in the old GCC v8 installations provided by mingw-64 project (e.g. i686-8.1.0-posix-sjlj-rt_v6-rev0).
3. The installation for "GNU GCC Compiler", which is also affected by this, points to C:\TDM-GCC-32, which is not an MSYS.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Names of compiler executables: Self-built vs Official
« Reply #4 on: June 30, 2021, 08:00:56 pm »
Try this patch and let me know if it works: https://sourceforge.net/p/codeblocks/tickets/374/#13f6

I will, assuming I can manage it.

Just for the record:
1. I did not press <Autodetect> in compiler settings.
2. Those two compilers are named like that (no "mingw32-" prefix) also in the old GCC v8 installations provided by mingw-64 project (e.g. i686-8.1.0-posix-sjlj-rt_v6-rev0).
3. The installation for "GNU GCC Compiler", which is also affected by this, points to C:\TDM-GCC-32, which is not an MSYS.

When you start Code::Blocks it runs a auto detect compiler routine!

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 57
Re: Names of compiler executables: Self-built vs Official
« Reply #5 on: June 30, 2021, 08:34:37 pm »
When you start Code::Blocks it runs a auto detect compiler routine!

When this may mean modifying my carefully set and working compiler settings behind my back, doing this may not be for the best.

And, how comes this does not happen with v20.03?
« Last Edit: June 30, 2021, 08:37:03 pm by PB »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Names of compiler executables: Self-built vs Official
« Reply #6 on: June 30, 2021, 09:13:56 pm »
Can you reproduce the problem reliably? Is any other setting getting lost?
We had some reports in the past that the default.conf file is truncated after a crash or some other unknown reason.
Could this be happening to you? Are you running multiple instances of C::B?

Auto-detection should happen only when your settings are clean/empty/on-first-run. If you see auto-detection in other cases it would be good if you could isolate the cause, so we could try to debug and fix the problem.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 57
Re: Names of compiler executables: Self-built vs Official
« Reply #7 on: June 30, 2021, 09:29:24 pm »
Try this patch and let me know if it works: https://sourceforge.net/p/codeblocks/tickets/374/#13f6

I tried and the only difference from v20.03 is that upon launching patched C::B, Compilers auto-detection dialog is shown with compiler "GNU GCC MingW64 Compiler" having "Invalid" status. The compilers in existing GCC-based toolchains are still prefixed with "mingw-"; however, those newly added ones (e.g., "GNU GCC MingW32 Compiler" or "GNU GCC TDM-32 Compiler" are not.

When I check that invalid compiler [YOUR ANSWER IS ALREADY THERE. SEARCH THE FORUMS!] in Global compiler settings, it has an empty installation directory. Additionally, its "Make program" is set to "make.exe" but I think it should be "mingw32-make.exe" just as in other mingw-based distributions?

Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 57
Re: Names of compiler executables: Self-built vs Official
« Reply #8 on: June 30, 2021, 09:47:54 pm »
Can you reproduce the problem reliably? Is any other setting getting lost?
We had some reports in the past that the default.conf file is truncated after a crash or some other unknown reason.
Could this be happening to you? Are you running multiple instances of C::B?

Yes, it is always the same when I run a nightly or a self-built C::B.

I have not noticed any other setting being lost.

I do not experience C::B crashes nor am I running its multiple instances.

If the config file were truncated; how comes the compiler settings are OK when I launch v20.03? I thought all the settings are shared, being stored in %APPDATA%\CodeBlocks?

But looking at the default.conf, my compiler settings for compiler "msys2-mingw-w64-i686" look like this
Code
<msys2_mingw_w64_i686>
    <NAME>
        <str>
            <![CDATA[msys2-mingw-w64-i686]]>
        </str>
    </NAME>
    <PARENT>
        <str>
            <![CDATA[gcc]]>
        </str>
    </PARENT>
    <MASTER_PATH>
        <str>
            <![CDATA[C:\msys64\mingw32]]>
        </str>
    </MASTER_PATH>
    <DEBUGGER_CONFIG>
        <str>
            <![CDATA[gdb_debugger:msys2-mingw-w64-i686]]>
        </str>
    </DEBUGGER_CONFIG>
</msys2_mingw_w64_i686>

So it seems that the names of the executables are not actually stored in the file but assumed by C::B based on the "parent" compiler (here GCC). This was corroborated when I changed "C compiler" from "gcc.exe" to "agcc.exe" and saved the setting, resulting into
Code
<C_COMPILER>
    <str>
        <![CDATA[agcc.exe]]>
    </str>
</C_COMPILER>
being added, so it appears only "overriden" settings such as executable names are actually stored in the default.conf. This explains why the settings keep being correct in v20.03 after being wrong in a self-built C::B.

But if no one else sees this, perhaps this is just some glitch on my setup, so you can safely label it a non-issue.

« Last Edit: June 30, 2021, 09:53:29 pm by PB »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Names of compiler executables: Self-built vs Official
« Reply #9 on: June 30, 2021, 10:56:51 pm »
But if no one else sees this, perhaps this is just some glitch on my setup, so you can safely label it a non-issue.
Can you start from a clean state and try to reproduce the problem and post the exact steps?
Probably moving the whole %APPDATA%\CodeBlocks folder to the side would be enough to reset everything related to autodetection.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 678
Re: Names of compiler executables: Self-built vs Official
« Reply #10 on: July 01, 2021, 04:17:07 pm »
Some things do not add up.

PB,
What compiler(s) do you have installed and what directory are they installed in? I have all of the compilers in ticket 374 plus Cygwin and MS Visual Studio 2019 CE.
Can I please get a copy of the default.conf and the new/modified compiler and option files you are currently using so I can have a look at them tomorrow and test them as it is too late tonight for me to look at it.

Be aware the options_gcc.xml file looks for the mingw32 files as per the following options_gcc.xml file snippet below, so when creating a new compiler from this can cause issues when the default.conf is deleted as the executable will revert to mingw32 until the compiler settings are changed.
<CodeBlocks_compiler_options>
    <if platform="windows">
        <Program name="C"         value="mingw32-gcc.exe"/>
        <Program name="CPP"       value="mingw32-g++.exe"/>
        <Program name="LD"        value="mingw32-g++.exe"/>
        <Program name="DBGconfig" value="gdb_debugger:Default"/>
        <Program name="LIB"       value="ar.exe"/>
        <Program name="WINDRES"   value="windres.exe"/>
        <Program name="MAKE"      value="mingw32-make.exe"/>
    </if>
    <else>
        <Program name="C"         value="gcc"/>
        <Program name="CPP"       value="g++"/>
        <Program name="LD"        value="g++"/>
        <Program name="DBGconfig" value="gdb_debugger:Default"/>
        <Program name="LIB"       value="ar"/>
        <Program name="WINDRES"   value=""/>
        <Program name="MAKE"      value="make"/>
    </else>


Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 57
Re: Names of compiler executables: Self-built vs Official
« Reply #11 on: July 01, 2021, 06:29:57 pm »
Can you start from a clean state and try to reproduce the problem and post the exact steps?

  • I have Code::Blocks v20.03 and I have also installed the latest nightly (rev12462).
  • I have removed folder %APPDATA%\CodeBlocks when Code::Blocks was not running.
  • I launched v20.03, it asked about stuff indicating it was a clean run. Among else it told me it could not find any compiler which was not surprising as I do not have any in the PATH or known location.
  • When running v20.03 I have set installation directory for "GNU GCC Compiler" to point "C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-sjlj-rt_v6-rev0\mingw32" and verified the names for the first three tools were correct (i.e., without "mingw32-" prefix).
  • When running v20.03 I have built and ran a Hello World C++ application to make sure everything works as expected.
  • I did not change any other setting in v20.03.
  • I launched the nightly, it immediately showed a pop-up complaining about a compiler executable not found.
  • When running the nightly, I went to the compiler settings, looked at settings for "GNU GCC Compiler" and again, the names for the first three tool names were incorrectly prefixed with "mingw32-".

To conclude, even after removing all Code::Blocks settings, I still experience the same issue I described in the first post of this thread. The issue is not with custom compiler configurations, the issue is rooted in the "GNU GCC Compiler", the custom compiler configurations derived from this compiler just inherit it.

Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 57
Re: Names of compiler executables: Self-built vs Official
« Reply #12 on: July 01, 2021, 06:56:14 pm »
What compiler(s) do you have installed and what directory are they installed in?
Please read my previous post where I believe the issue is not with custom compiler configurations in C::B but with the base "GNU GCC Compiler".

I have 6 packages by mingw-64 project installed in their default locations in  %ProgramFiles(x86)% and %ProgramFiles%:
i686-8.1.0-posix-sjlj-rt_v6-rev0
i686-8.1.0-win32-sjlj-rt_v6-rev0
i686-8.1.0-posix-dwarf-rt_v6-rev0
x86_64-8.1.0-posix-seh-rt_v6-rev0
x86_64-8.1.0-posix-sjlj-rt_v6-rev0
x86_64-8.1.0-win32-seh-rt_v6-rev0

I also have 2 mingw- and GCC-based MSYS2 packages installed in the default location (c:\msys64):
mingw-w64-i686-toolchain
mingw-w64-x86_64-toolchain

I have GCC v9 based TDM-GCC-32 and TDM-GCC-64 installed in C:\. I also have MSVS 2017 and 2019 which I never used in C::B.

None of the compilers are in the PATH. I did not have C::B compiler configurations for all of them but those few I had I could switch between in v20.03 with no issues.

Be aware the options_gcc.xml file looks for the mingw32 files as per the following options_gcc.xml file snippet below, so when creating a new compiler from this can cause issues when the default.conf is deleted as the executable will revert to mingw32 until the compiler settings are changed.
<CodeBlocks_compiler_options>
    <if platform="windows">
        <Program name="C"         value="mingw32-gcc.exe"/>
        <Program name="CPP"       value="mingw32-g++.exe"/>
        <Program name="LD"        value="mingw32-g++.exe"/>
        <Program name="DBGconfig" value="gdb_debugger:Default"/>
        <Program name="LIB"       value="ar.exe"/>
        <Program name="WINDRES"   value="windres.exe"/>
        <Program name="MAKE"      value="mingw32-make.exe"/>
    </if>
    <else>
        <Program name="C"         value="gcc"/>
        <Program name="CPP"       value="g++"/>
        <Program name="LD"        value="g++"/>
        <Program name="DBGconfig" value="gdb_debugger:Default"/>
        <Program name="LIB"       value="ar"/>
        <Program name="WINDRES"   value=""/>
        <Program name="MAKE"      value="make"/>
    </else>

This looks incorrect to me.

In mingw-64 project with GCC 8.1 distributions, the 32-bit installations (e.g., i686-8.1.0-posix-dwarf-rt_v6-rev0) have unprefixed gcc and g++ executables as well as those prefixed with  "i686-w64-mingw32-", e.g., i686-w64-mingw32-gcc.exe. The 64-bit ones (e.g., x86_64-8.1.0-posix-seh-rt_v6-rev0) also have both unprefixed and prefixed executables, with prefix being "x86_64-w64-mingw32-", e.g. x86_64-w64-mingw32-gcc.exe.

Interestingly, in MSYS mingw64 packages with GCC the 32-bit one has only unprefixed executables while the 64-bit one has both unprefixed and prefixed with "x86_64-w64-mingw32-".

TDM-GCC: both 32- and 64-bit installations have prefixed and unprefixed executables, the prefix being "mingw32-" for 32-bit and "x86_64-w64-mingw32-" for 64-bit. I think the difference is that TDM uses uses the original MinGW distribution for 32-bit package while the 64-bit one is based on mingw-64 project.


If the default "parent" compiler "GNU GCC Compiler" will have gcc and g++ with a prefix, the solution to my "problem" would be to remove the prefix from custom compiler configurations. This needs to be done just once for each configuration (or perhaps just once in the "GNU GCC Compiler" itself).

So it is a minor issue, it is just surprising if one does not know where the prefix in the custom configuration came from all of a sudden.
« Last Edit: July 01, 2021, 07:10:33 pm by PB »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Names of compiler executables: Self-built vs Official
« Reply #13 on: July 02, 2021, 03:41:46 am »
Interestingly, in MSYS mingw64 packages with GCC the 32-bit one has only unprefixed executables while the 64-bit one has both unprefixed and prefixed with "x86_64-w64-mingw32-".

My MSys2 mingw32/bin has "i686-w64-mingw32-" prefix are you sure you looked at the full folder?

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 57
Re: Names of compiler executables: Self-built vs Official
« Reply #14 on: July 02, 2021, 04:23:52 pm »
My MSys2 mingw32/bin has "i686-w64-mingw32-" prefix are you sure you looked at the full folder?
Sorry, you are right I somehow managed to miss those files.

Although it seems that people moved away from MinGW to mingw-64, I have also downloaded the original MinGW package (with GCC 9.2). It has the unprefixed gcc and g++ executables and is the only package of all I tried having them also prefixed with "mingw32-".

The question remains: It seems that all relevant mingw distributions have gcc.exe and g++.exe so why use the prefix (be it correct or incorrect) for them?