Colour/line highlighting on local instance

69 views
Skip to first unread message

Brian O'Kennedy

unread,
Oct 10, 2022, 6:30:01 AM10/10/22
to Compiler Explorer Discussion
Hi, 

I've managed to set up a local instance of Compiler Explorer (yay!), pointing to my specific instance of G++ 12.1 built using the Nix package manager. Compilation works, but the colour highlighting of source lines and assembly is missing. 

When selecting the default system compiler (g++ 4.3) this does however work correctly. 

I suspect the problem is that the binary tools on my distro are too old to understand the output from my 12.1 compiler, but I'm not sure if this is the case, or which tool I need to persuade Compiler Explorer to use from Nix instead. 

Any tips on what I can look at to track the problem down?

Thanks
 Brian

Matt Godbolt

unread,
Oct 10, 2022, 9:30:21 AM10/10/22
to compiler-explo...@googlegroups.com
That's an odd one! If you're not ticking the "compile to asm" we highlight based on the output of the compiler directly.

If you are ticking "compile to asm" then we use `objdump` to disassemble and annotate the compiled execution.  If this is happening maybe as you say your system objdump is out of date. You can steer Compiler Explorer to use your nix objdump by editing/or creating etc/config/c++.local.properties with the contents:

objdumper=/path/to/your/nix/objdump

Let us know how you get on!

--matt

--
You received this message because you are subscribed to the Google Groups "Compiler Explorer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to compiler-explorer-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/compiler-explorer-discussion/58c987c8-666d-4a7b-8775-faf36d2b1b94n%40googlegroups.com.


--
Matt
(he/him)

Brian O'Kennedy

unread,
Oct 10, 2022, 10:26:43 AM10/10/22
to compiler-explo...@googlegroups.com
Thanks for the quick response!

I had already set the objdumper to use my Nix based one, and in fact ticking 'Compile to binary' makes the colour highlighting work, which is a step forward. It seems that using the direct compiler output does not, which probably invalidates my former theory of incompatible tools. 

I've attached the unfiltered assembly output from the system g++ (theirs.S) and my local build of g++ 12.1 (mine.S) here. Mine is notably missing the .loc and .file directives, so I assume I need to fiddle with the debug information settings for the compiler until I get those? 

Thanks
 Brian

You received this message because you are subscribed to a topic in the Google Groups "Compiler Explorer Discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/compiler-explorer-discussion/Zmx6No2Bb3w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to compiler-explorer-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/compiler-explorer-discussion/CAFWXXN0S9pxOQfO8W5m15hysJg0JNhRRrvEeEW7%3D7OLjghBasQ%40mail.gmail.com.
mine.S
theirs.S

Brian O'Kennedy

unread,
Oct 10, 2022, 10:49:18 AM10/10/22
to compiler-explo...@googlegroups.com
FWIW, adding "-gstabs" seems to do the trick, but I'm unsure if this is the best route forward. 

Matt Godbolt

unread,
Oct 10, 2022, 12:14:00 PM10/10/22
to compiler-explo...@googlegroups.com
Oh that's super odd! There must be something weird in the compiler you've built...and that we don't parse its output correctly (!).  We force-include `-g` to make debug output (which ought to be dwarf I think?) but as you say it's missing in yours! Yours has `.debug_line` info, so ... I wonder.

Do you know what your compiler was built with? (Just for us to learn!)? Ours are built with: https://github.com/compiler-explorer/gcc-builder/blob/0eb7b81e754ea0ffb1e7eb0f1d833300f66b2151/build/build.sh#L154-L173 (if that helps?)







--
Matt
(he/him)

Brian O'Kennedy

unread,
Oct 11, 2022, 2:07:36 PM10/11/22
to compiler-explo...@googlegroups.com
I'm still chasing the cause of the difference. My compiler was built off a local install of NixOs/nixpkgs (https://github.com/NixOS/nixpkgs) at this point: 


We have various layers of extra configuration around this, but nothing that looks specific to tweaking the compiler settings. I have managed to build a local gcc 12.1 that works, as well as one that doesn't, but it is sadly quite difficult to tell what causes the difference in assembly output, given the many layers of Nix involved. 

Running the correctly functioning version with "g++ -dumpspecs"

*asm_debug: %{%:debug-level-gt(0):%{gstabs*:--gstabs;:%{g*:}}} %{fdebug-prefix-map=*:--debug-prefix-map %*} *asm_debug_option: %{%:debug-level-gt(0):%{!gstabs*:%{g*:%{%:dwarf-version-gt(4):--gdwarf-5 ;%:dwarf-version-gt(3):--gdwarf-4 ;%:dwarf-version-gt(2):--gdwarf-3 ;:--gdwarf2 }}}}


And the version that does not produce .loc entries, with "g++ -dumpspecs"

*asm_debug: %{%:debug-level-gt(0):%{gstabs*:--gstabs;:%{g*:--gdwarf2}}} %{fdebug-prefix-map=*:--debug-prefix-map %*} *asm_debug_option:  

This all leads me to think the problem is entirely on my side, with the g++ in use not configured correctly (somehow) to produce debug symbols in dwarf-5. 

Thanks for your time, I think Compiler Explorer is off the hook here. There isn't much you can do if the assembly is lacking in debug information I guess!

Brian





Reply all
Reply to author
Forward
0 new messages