Author Topic: Code::Blocks converting Linker options mentioned in a txt file to whole command  (Read 664 times)

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12
We are using Code::Blocks 16 version. We are using RVDS 3.1 as compiler and I see that the Linker options are provided in a .txt file for codeblocks in one of our Release.cbp files. Sample below.
<Linker>
               <Add option="--via=NetStack_Data\CB\release\release-NuNet\ObjPathFile.txt" />
               <Add option="--via=NetStack_Data\CB\release\$(PROJECT_NAME)\ObjPathFile.txt" />

The issue is code::blocks is converting the options in this .txt file into a whole command line while compiling using armar.exe and since the cmd prompt does not allow more than 8191 characters to be keyed in, the command is failing.

We have one server where Code::Blocks is running a older version 10. There this issue is not observed and the armar.exe is passing as the file is given as its argument by code::blocks.

Please let me know if anyone has come across this issue and if there has been any known fix. Do let me know if you need any more information regarding the same.

Thank you,
Sri

Online stahta01

  • Lives here!
  • ****
  • Posts: 5943
    • My Best Post
I would suggest looking at each version of CB build log and trying to see what difference is the cause of your issue.

Edit: It is not clear from your post whether CB or your compiler driver is causing the problem.
compiler driver is often the c++ compiler.

Tim S.
« Last Edit: October 06, 2017, 04:04:46 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1519
if you have a question, always post the full rebuild log and the expected compiler command line. To get the full build log:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12
Thanks for the responses. The build log in the working server passes the linker step as below.

armar.exe -r -s ..\output\NetStack-release-NuNet.a --via NetStack_Data\CB\release\release-NuNet\ObjPathFile.txt

Whereas in the non-working server it fails with the below error.

Execution of 'armar.exe -r -s ..\output\NetStack-release-NuNet.a NetStack_Data\CB\release\release-NuNet\macbsp\firmware\common\source\StdLibLib.o ..............' failed.

Here the arguments passed in the objpathfile.txt are getting converted into the whole command.

Both the servers are Windows 2008 R2.
Working server has Code::Blocks 10.05 version.
Non-working server has Code::Blocks 16.01 version.


The full build log files are 3MB size each and hence cannot attach to the post. Please let me know if you need any more information regarding the same.

Online stahta01

  • Lives here!
  • ****
  • Posts: 5943
    • My Best Post
Looks like advanced compiler options difference in the working Code::Blocks.

The default option on CB 16.01 is
Code: [Select]
cmd /c if exist $static_output del $static_output
$lib_linker -r -s $static_output $link_objects

The working CB has had $link_objects removed and likely $link_options was added in its place.
No Idea, if a CB Developer or an end user did the change.

To see/change the advance compiler options in CB 16.01
Settings -> Compiler
Select the compiler you wish to change or check value
Select tab "Other Settings" to the far right
Click on "Advanced Settings" Button
On Tab, "Commands" Select "Link object files to static Library"
On CB 16.01 you should see
Code: [Select]
cmd /c if exist $static_output del $static_output
$lib_linker -r -s $static_output $link_objects
I would suggest trying to replace it with
Code: [Select]
cmd /c if exist $static_output del $static_output
$lib_linker -r -s $static_output $link_options

NOTE: The above will break the compiler for normal static linking!!!

Tim S.


C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12
Thanks for the update @stahta01

The working & non-working CB both has the below option only.
$lib_linker -r -s $static_output $link_objects
I have attached the screenshot of the same for reference.

But I went ahead and changed it according to your suggestion in CB16 & started compiling the log. The build now failed with the below error.

cmd /c if exist ..\output\NetStack-sim-NuNet.a del ..\output\NetStack-sim-NuNet.a
armar.exe -r -s ..\output\NetStack-sim-NuNet.a
Running target post-build steps
armar.exe -r -s ..\output\NetStack-sim-NuNet.a --via NetStack_Data\CB\sim\sim-NuNet\ObjPathFile.txt
Fatal error: L3904U: Could not open via file 'NetStack_Data\CB\sim\sim-NuNet\ObjPathFile.txt'.
Process terminated with status 1 (4 minute(s), 20 second(s))
1 error(s), 64 warning(s) (4 minute(s), 20 second(s))
../../../build/common/generic_arm.mk:733: recipe for target `generic_arm_compile_execute_compiler_with_post_link_checker' failed
cygmake[1]: *** [generic_arm_compile_execute_compiler_with_post_link_checker] Error 1
cygmake[1]: Leaving directory `/cygdrive/c/data/work/asivakum/p411codebase-sim02/2.0bk/plc_proc/nwmanagement/firmware/NetStack'
Makefile:49: recipe for target `compile' failed
cygmake: *** [compile] Error 2

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12
Since the settings mentioned below are same across both the working / non-working server, I had to revert them back to the original as full build is not working with these options. Current settings are mentioned below.
$lib_linker -r -s $static_output $link_objects

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12
This is the command that failed in the build again.

Execution of 'armar.exe -r -s ..\output\NetStack-sim-NuNet.a NetStack_Data\CB\sim\sim-NuNet\macbsp\firmware\common\source\StdLibLib.o NetStack_Data\CB\sim\sim-NuNet\nucleus\firmware\common\Nucleus\cipher_suite\ncs_cfg.o NetStack_Data\CB\sim\sim-NuNet\nucleus\firmware\common\Nucleus\cipher_suite\src\ncs_3des.o NetStack_Data\CB\sim\sim-NetStack_Data\CB\sim\sim-NuNet\nwmanagement\firmware\NetStack\source\net\hosts.o NetStack_Data\CB\sim\sim-NuNet\nwmanagement\firmware\NetStack\source\webserv\http_psr.o NetStack_Data\CB\sim\sim-NuNet\nwmanagement\firmware\NetStack\source\webserv\ws_tasks.o' in 'C:\data\work\asivakum\p411codebase\2.0bk\plc_proc\nwmanagement\firmware\NetStack\targets' failed.

Please let me know if you need any more information for further debug / help on the same.

Online stahta01

  • Lives here!
  • ****
  • Posts: 5943
    • My Best Post
Try building from the command line. The error looks like a bad compiler error to me.

Also, you need to post information about your compiler.

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

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12
We are using ARM RVDS 3.1 compiler. Please let me know if you need any more information regarding this one.

From command line as well as from GUI, we are receiving the same error.

Attached is the screenshot for the compiler in CB.
« Last Edit: October 09, 2017, 01:37:23 pm by srikanthsivasai »

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12
With the same compiler, below is the output of the same command passing in CB 10.

armar.exe -r -s ..\output\NetStack-sim-NuNet.a
      Code  (inc. data)  RO Data    RW Data    ZI Data      Debug   File Name
         0          0          0          0          0     699256   NetStack_Data\CB\sim\sim-NuNet\nucleus\firmware\common\Nucleus\webserv\src\upl_plgn.o
      Code  (inc. data)  RO Data    RW Data    ZI Data      Debug   File Name
       456         84       2565        320        180     702407   NetStack_Data\CB\sim\sim-NuNet\nucleus\firmware\common\Nucleus\webserv\src\web_ssl.o
      Code  (inc. data)  RO Data    RW Data    ZI Data      Debug   File Name
         0          0          0         40          0     160760   NetStack_Data\CB\sim\sim-NuNet\source\net\hosts.o
      Code  (inc. data)  RO Data    RW Data    ZI Data      Debug   File Name
       774        110          0          0          0     703917   NetStack_Data\CB\sim\sim-NuNet\nucleus\firmware\common\Nucleus\webserv\src\wsn.o
      Code  (inc. data)  RO Data    RW Data    ZI Data      Debug   File Name
       324         32          0          0          0     701914   NetStack_Data\CB\sim\sim-NuNet\nucleus\firmware\common\Nucleus\webserv\src\wsf.o
      Code  (inc. data)  RO Data    RW Data    ZI Data      Debug   File Name
      3048        652        435          0          0     716785   NetStack_Data\CB\sim\sim-NuNet\source\webserv\http_psr.o
      Code  (inc. data)  RO Data    RW Data    ZI Data      Debug   File Name
      2964        442          0          4        620     714948   NetStack_Data\CB\sim\sim-NuNet\source\webserv\ws_tasks.o
Output size is 182.94 MB
Running target post-build steps
armar.exe -r -s ..\output\NetStack-sim-NuNet.a --via NetStack_Data\CB\sim\sim-NuNet\ObjPathFile.txt

Online stahta01

  • Lives here!
  • ****
  • Posts: 5943
    • My Best Post
We are using ARM RVDS 3.1 compiler. Please let me know if you need any more information regarding this one.

From command line as well as from GUI, we are receiving the same error.

Attached is the screenshot for the compiler in CB.

So, the problem is in the compiler or something else on the computer with the problem.

Tim S.
« Last Edit: October 09, 2017, 01:48:12 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12
Sorry I am very new to CB. Hence asking the same thing again, as I dont see any difference in the servers when comparing other settings.

But the CB output is different for this particular line itself, as in CB10 - its taking the file, but in CB16 - its processing the whole command.

Do you still think this could be a compiler issue?

Online stahta01

  • Lives here!
  • ****
  • Posts: 5943
    • My Best Post
You said the same error happened when you ran the command on the command line!
Unless you ran a bad command on the command line; I do not know what you did.
Do you?

This means the problem is not in code::blocks.

NOTE: Since, the last image you last posted is NOT from a standard Code::Blocks; you should post your question on the site you got your modified version of code::blocks from.

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

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1519
i still don't see a full rebuild log, but ok

Quote
Execution of 'armar.exe -r -s ..\output\NetStack-sim-NuNet.a NetStack_Data\CB\sim\sim-NuNet\macbsp\firmware\common\source\StdLibLib.o NetStack_Data\CB\sim\sim-NuNet\nucleus\firmware\common\Nucleus\cipher_suite\ncs_cfg.o NetStack_Data\CB\sim\sim-NuNet\nucleus\firmware\common\Nucleus\cipher_suite\src\ncs_3des.o NetStack_Data\CB\sim\sim-NetStack_Data\CB\sim\sim-NuNet\nwmanagement\firmware\NetStack\source\net\hosts.o NetStack_Data\CB\sim\sim-NuNet\nwmanagement\firmware\NetStack\source\webserv\http_psr.o NetStack_Data\CB\sim\sim-NuNet\nwmanagement\firmware\NetStack\source\webserv\ws_tasks.o' in 'C:\data\work\asivakum\p411codebase\2.0bk\plc_proc\nwmanagement\firmware\NetStack\targets' failed.
this shows that the execution ot armar.exe fails... what if you execute this line in a cmd?
Code: [Select]
armar.exe -r -s ..\output\NetStack-sim-NuNet.a NetStack_Data\CB\sim\sim-NuNet\macbsp\firmware\common\source\StdLibLib.o NetStack_Data\CB\sim\sim-NuNet\nucleus\firmware\common\Nucleus\cipher_suite\ncs_cfg.o NetStack_Data\CB\sim\sim-NuNet\nucleus\firmware\common\Nucleus\cipher_suite\src\ncs_3des.o NetStack_Data\CB\sim\sim-NetStack_Data\CB\sim\sim-NuNet\nwmanagement\firmware\NetStack\source\net\hosts.o NetStack_Data\CB\sim\sim-NuNet\nwmanagement\firmware\NetStack\source\webserv\http_psr.o NetStack_Data\CB\sim\sim-NuNet\nwmanagement\firmware\NetStack\source\webserv\ws_tasks.o
Note: you need to have the compiler in your "PATH" variable. You can set your PATH variable on windows by typing
Code: [Select]
set PATH=%PATH%;PATH_TO_YOUR_COMPILERin the cmd

If the execution fails then you have a problem on your pc and this problem has nothing to do with codeblocks. If the execution does not fail you have a problem with codeblocks and you should post a build log... It would be a good idea to obfuscate the paths from the log...

Code: [Select]
But the CB output is different for this particular line itself, as in CB10 - its taking the file, but in CB16 - its processing the whole command. then please post both logs... We do not know what differs if you don't tell us...
CB 10 is probably 6 years old. There where a lot things that changed (but there should not be any change in the build chain unless it was a bug...)...

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1519
ok, i re read all your post and i have a few questions:
1) What is in the NetStack_Data\CB\release\release-NuNet\ObjPathFile.txt file and how is it created?
2) Where is this file? relative to the project file?
3) Can you tell us more about your build process?

Online stahta01

  • Lives here!
  • ****
  • Posts: 5943
    • My Best Post
Note: The compiler website implies the compiler is only for 32 bit windows OS.

Post the Operating System (OS) for both working and not working setups.

Also, post the full CB version info for both working and not working setups.

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

Online stahta01

  • Lives here!
  • ****
  • Posts: 5943
    • My Best Post
Also, post the path to the CB Project file for both working and non working setups.

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

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12
Operating system OS for both working / non-working setups.
Windows 2008 R2 Standard 64-bit.
I have attached snippets of the CB version for both working / non-working servers.
The path to the CB project is relative & is existing where the below command is executing for both working / non-working setups
Entering directory 'C:\..........\NetStack'
Execution of 'armar.exe -r -s ..\output\NetStack-sim-NuNet.a.......' failed.


Please let me know if you need any more information regarding the same.

Thank you,
Sri

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12

@Bluehazzard

1) What is in the NetStack_Data\CB\release\release-NuNet\ObjPathFile.txt file and how is it created?
This file is having the paths for object files. This is being created as the full command armar.exe -r -s ..\output\NetStack-sim-NuNet.a along with the object files in the command line is failing, as the characters are exceeding the 8191 limit. Hence all the files are being passed as txt file.
2) Where is this file? relative to the project file? Yes it is present in the above mentioned dir and the dir starts from the path where CBP file is residing.
3) Can you tell us more about your build process?
I have attached the CB Project file for your reference. Please let me know if you need any more information regarding the same.

I cannot attach fulle build log, as its exceeding the limit set for the size of the attachments in this forum.

Thank you,
Sri

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12
Working & non-working build logs attached.

Thank you,
Sri

Online stahta01

  • Lives here!
  • ****
  • Posts: 5943
    • My Best Post
Ask the person who built the cb 10.05 what changes they did to the source code.

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

Online stahta01

  • Lives here!
  • ****
  • Posts: 5943
    • My Best Post
I strongly suggest if the person who customized the CB 10.05 build has left the company that you make a backup of the CB 10.05 programs and config files. And, then move them to the non-working computer.

It is either that or pay someone a lot of money to fix the problem.

Edit2: You might also try finding a version of software from http://www.emblocks.org because while your modified CB 10.05 does not look like that. It is the closest fork of CB that I know of based on your toolchain setting screen you posted.
Note: The www.emblocks.org no longer exists; so, it might be hard to find a copy unless you use the wayback machine.

Tim S.
« Last Edit: October 09, 2017, 08:04:13 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1519
Hi, i now understand your problem...
Sadly i don't see a easy solution. There are multiple problems we have to solve.
As stahta01 mentioned your old codeblocks version is not a normal codeblocks, but a fork. We have no information about how this fork works so we can not apply this in "normal" codeblocks.
I also do not understand how this fork distinguishes between when he should use the  "--via" text file and when the internal object file lists.

"Our" codeblocks version always puts the object files to the "ar" command so the command line gets to long, also when you use the via command. If you remove the object file list from the command obviously normal compiling will not work.

Lets try to find a solution:
1) The command line to the linker is to long, so lets try to shorten it:
Solution:
In the project file you provided there are ca 800 files. The mean filename length is 8 characters so it should be possible to limit the object file length to a length so that the command line does not exceed the windows limit. You can shorten the object output folder path to something like
Code: [Select]
.o\$(PROJECT_NAME)\ in Project->Properties->Build targets->Objects output dir
this should reduce the file length. With this you do not need the --via command line
Problems:
This solution is not quite problem resistant. Add some files and your build process is broken again...

2) Use always the --via command:
As stahta01 showed in your post use this command in the advanced compiler options
Code: [Select]
cmd /c if exist $static_output del $static_output
$lib_linker -r -s $static_output $link_options
but now you have to generate a text file with object files for all your projects.
2.1) A intermediate way would be to use a different compiler for the targets with many object files and the normal options for "short" projects
2.2) You can generate the object file list with codeblocks scripting so this all can be made quite transparent


3) Use makefiles for all this and use a custom makefile project

PS. How do you generate this text file with the object files? From hand?

Offline srikanthsivasai

  • Multiple posting newcomer
  • *
  • Posts: 12
@bluehazzard & @stahta01 you are exactly right. This is a forked version and not a full exe. It looks like all the builds have been designed in view of how this forked version reacts to certain commands. So I had to uninstall the latest version and copy back the old version to make this one working.

I really appreciate all your time & patience in figuring out the root cause for the issue. Thanks a lot.

Thank you,
Sri