Open petrock99 opened 3 months ago
When I click the Green Checkmark to see the compilation options used the compiler on the left shows:
-gdwarf-4 -g -o output.s -masm=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-13.1.0 -fcolor-diagnostics -fno-crash-diagnostics -std=c11 -O3 -g -march=alderlake -mtune=alderlake example.c
and the compiler on the right shows:
-fcolor-diagnostics -fno-crash-diagnostics
Sadly, if I add -gdwarf-4
, -masm=intel
and --gcc-toolchain=/opt/compiler-explorer/gcc-13.1.0
to the add_compile_options
section in the CMakeLists.txt the problem still reproduces.
Another thing that is interesting is the compiler section on the left has slightly different assembly for the vfmadd213pd instruction:
left: [rdi + 16]
right: [rdi+0x10]
It's decimal vs hex. I'm not sure if that is related to this bug or not, or if I somehow enabled some formatting feature.
ASM shown when using CMake, is equivalent to using 'Link to binary' when compiling a file directly. (It is compiled and then the executable is disassembled with objdump)
There is no equivalent to -S
when using CMake and this is also not possible to implement, sorry.
Sure you can.
To build without linking, substitute add_library
for add_executable
in the CMakeLists.txt
file. Since the CMakeLists.txt
is on your servers, you can parse & modify them on the fly, right? cmake
also supports nested CMakeLists.txt
files. So you could nest the users CMakeLists.txt
into your own CMakeLists.txt
and copy/modify the state how you like. I haven't tried that, but in theory it could work.
To get .s files use -save-temps
instead of -S
. Works like a charm with icx, gcc & clang. I'm not sure about other compilers. I've attached a sample project to demonstrate this working.
unzip TestCMakeASM.zip
cd TestCMakeASM
cmake . -DCMAKE_C_COMPILER=icx -DCMAKE_BUILD_TYPE=Release
make
less test.s
Hope that helps.
Should I file a new bug or can this one be re-opened? Thanks.
You're free to send a PR
Sadly, due to my job I'm not allowed to contribute to open source projects. I wish I could.
Could the 'wont-fix' flag be removed? Thanks.
Describe the bug
If I set up source editor to use
icx-2023.1.0
with some C code that usesAVX2 Intrinsics
there will be comments next to some of the corresponding assembly instructions. i.e.# AlignMOV convert to UnAlignMOV
,# ymm0 = (ymm1 * ymm0) + mem
or the ever important# 32-byte Spill
.But if I build the same exact code with cmake these comments are missing. Maybe I'm missing a flag in the CMakeLists.txt to enable this feature in Compiler Explorer?
Steps to reproduce
Expected behavior
Both compiler sections should show identical content, including the assembly comments.
square:
vmovupd ymm1, ymmword ptr [rdi] # AlignMOV convert to UnAlignMOV vmovupd ymm0, ymmword ptr [rdi + 8] # AlignMOV convert to UnAlignMOV vfmadd213pd ymm0, ymm1, ymmword ptr [rdi + 16] *# ymm0 = (ymm1 ymm0) + mem**
Reproduction link
https://godbolt.org/z/v7zqfv9vd
Screenshots
Operating System
macOS 14.5
Browser version
Safari 17.5