Author Topic: In troubles trying to display the resulting assembly  (Read 1147 times)

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 49
In troubles trying to display the resulting assembly
« on: November 17, 2022, 01:27:45 pm »
Hi, as a premise I am not expert with GCC technical details, I am using CB with MinGW to develop on Windows.
Often I need to have a look at the resulting assembly but I am having a hard time achieving such a simple task.
Googling around, I noticed I must use the -S option for gcc not to assemble and link the project sources but to rather generate an intermediate assembly file one can inspect.

Unfortunately if I add the "-S" option in the list of Other Compiler options (where all my other options reside and work fine, like -mfma for example) on building I get the following error:

||=== Build: Release in Workbench (compiler: MINGW_x64) ===|
d:\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe:obj\Release\ED_Shared\FastMath32.o|1|syntax error|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 4 warning(s) (0 minute(s), 0 second(s)) ===|



here is the build log:


-------------- Build: Release in Workbench (compiler: MINGW_x64)---------------

g++.exe -Wall -std=c++17 -m64 -O3 -mfma -S -ID:\mingw64 -c E:\SE_SDK\_Workbench\main.cpp -o obj\Release\_Workbench\main.o

g++.exe  -o Workbench.exe obj\Release\ED_Shared\FastMath32.o obj\Release\_Workbench\main.o  -static-libstdc++ -static-libgcc -static -m64 -s  ..\ESD_SDK\libESDToolKit.a -liphlpapi -lgdi32

d:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe:obj\Release\ED_Shared\FastMath32.o: file format not recognized; treating as linker script

d:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe:obj\Release\ED_Shared\FastMath32.o:1: syntax error

collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 4 warning(s) (0 minute(s), 0 second(s))


What should I do from within C::B to have the resulting assembly file(s) to inspect, without having to issue gcc commands manually in a shell ? Thanks in advance for any relevant support !

« Last Edit: November 17, 2022, 01:31:09 pm by Elena »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1261
Re: In troubles trying to display the resulting assembly
« Reply #1 on: November 17, 2022, 05:56:46 pm »
The compiler saves the generated assembly in main.o, and the linker tries to interpret it as an object file. See the first answer here for more information.

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 49
Re: In troubles trying to display the resulting assembly
« Reply #2 on: November 17, 2022, 09:27:09 pm »
Geez! I could never have figured out it saved the asm as main.o and not main.s  :o :o I will check the link thx

Offline jordi

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: In troubles trying to display the resulting assembly
« Reply #3 on: November 17, 2022, 09:32:40 pm »
Try to use -save-temps option which will leave all the temporary files including the .s file

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 49
Re: In troubles trying to display the resulting assembly
« Reply #4 on: November 17, 2022, 10:45:47 pm »
Thank you ALOT Jordi, the -save-temps option does *exactly* what I needed, wow  :D :D :D :D :D :D