public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107513] New: [Feature Request] Implement __attribute__((__nodebug__))
@ 2022-11-02 20:59 roi.jacobson1 at gmail dot com
  2022-11-02 21:06 ` [Bug c++/107513] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: roi.jacobson1 at gmail dot com @ 2022-11-02 20:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107513

            Bug ID: 107513
           Summary: [Feature Request] Implement
                    __attribute__((__nodebug__))
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roi.jacobson1 at gmail dot com
  Target Milestone: ---

Clang has __attribute__((__nodebug__)). When applied for types and functions it
suppresses generation of debug information for those types or functions. This
can greatly reduce binary sizes when compiling with debug symbols.

As a very non representative measure: in a library I'm currently working on, by
applying this attribute to some uninteresting 'forwarding' functions I see a
40% reduction in size (uncompressed and unrepresentative, but still).

It is worth noting that this attribute is already used in libc++ and in some
other libraries (for example Apple SIMD).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/107513] [Feature Request] Implement __attribute__((__nodebug__))
  2022-11-02 20:59 [Bug c++/107513] New: [Feature Request] Implement __attribute__((__nodebug__)) roi.jacobson1 at gmail dot com
@ 2022-11-02 21:06 ` pinskia at gcc dot gnu.org
  2022-11-02 21:23 ` roi.jacobson1 at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-02 21:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107513

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC's artificial attribute should be similar for functions:
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Common-Function-Attributes.html#index-artificial-function-attribute

Which was added in GCC 4.3.0 by r0-83503-gd752cfdb114944.

types GCC does not have one.

I suspect for your usage artificial is enough.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/107513] [Feature Request] Implement __attribute__((__nodebug__))
  2022-11-02 20:59 [Bug c++/107513] New: [Feature Request] Implement __attribute__((__nodebug__)) roi.jacobson1 at gmail dot com
  2022-11-02 21:06 ` [Bug c++/107513] " pinskia at gcc dot gnu.org
@ 2022-11-02 21:23 ` roi.jacobson1 at gmail dot com
  2022-11-02 21:32 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: roi.jacobson1 at gmail dot com @ 2022-11-02 21:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107513

--- Comment #2 from Roy Jacobson <roi.jacobson1 at gmail dot com> ---
I might be using it wrong? But it doesn't seem to do anything:
https://godbolt.org/z/9bdKhz4E7

It would be nice to at least avoid having the function's name in the binary,
clang does it with nodebug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/107513] [Feature Request] Implement __attribute__((__nodebug__))
  2022-11-02 20:59 [Bug c++/107513] New: [Feature Request] Implement __attribute__((__nodebug__)) roi.jacobson1 at gmail dot com
  2022-11-02 21:06 ` [Bug c++/107513] " pinskia at gcc dot gnu.org
  2022-11-02 21:23 ` roi.jacobson1 at gmail dot com
@ 2022-11-02 21:32 ` pinskia at gcc dot gnu.org
  2022-11-02 22:13 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-02 21:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107513

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Roy Jacobson from comment #2)
> I might be using it wrong? But it doesn't seem to do anything:
> https://godbolt.org/z/9bdKhz4E7
> 
> It would be nice to at least avoid having the function's name in the binary,
> clang does it with nodebug.

because it does something different really.
It is not used to reduce debug info but rather to make the debugging experience
better.

It marks the inlined function with DW_AT_artificial.


        .byte   0x1   # DW_AT_decl_file (/app/example.cpp)
        .byte   0x2   # DW_AT_decl_line
        .long   0x35  # DW_AT_type
        .byte   0x3   # DW_AT_inline
        .byte   0x1   # DW_AT_artificial

That is it is actually better than Clang's nodebug for debuggability reasons.

In my view nodebug is a hack rather than actually use DW_AT_artificial
correctly.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/107513] [Feature Request] Implement __attribute__((__nodebug__))
  2022-11-02 20:59 [Bug c++/107513] New: [Feature Request] Implement __attribute__((__nodebug__)) roi.jacobson1 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-11-02 21:32 ` pinskia at gcc dot gnu.org
@ 2022-11-02 22:13 ` redi at gcc dot gnu.org
  2022-11-03 10:34 ` roi.jacobson1 at gmail dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-02 22:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107513

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
But what does DW_AT_artificial do? Does gdb just ignore it? I've never noticed
it helping at all.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/107513] [Feature Request] Implement __attribute__((__nodebug__))
  2022-11-02 20:59 [Bug c++/107513] New: [Feature Request] Implement __attribute__((__nodebug__)) roi.jacobson1 at gmail dot com
                   ` (3 preceding siblings ...)
  2022-11-02 22:13 ` redi at gcc dot gnu.org
@ 2022-11-03 10:34 ` roi.jacobson1 at gmail dot com
  2023-10-31  3:14 ` redi at gcc dot gnu.org
  2023-11-01 14:08 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: roi.jacobson1 at gmail dot com @ 2022-11-03 10:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107513

--- Comment #5 from Roy Jacobson <roi.jacobson1 at gmail dot com> ---
I still think it might be good idea to introduce this for the sake of reducing
debug symbols size. I'm less interested in improving debug experience in this
case, but obviously any improvement to that is welcome as well.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/107513] [Feature Request] Implement __attribute__((__nodebug__))
  2022-11-02 20:59 [Bug c++/107513] New: [Feature Request] Implement __attribute__((__nodebug__)) roi.jacobson1 at gmail dot com
                   ` (4 preceding siblings ...)
  2022-11-03 10:34 ` roi.jacobson1 at gmail dot com
@ 2023-10-31  3:14 ` redi at gcc dot gnu.org
  2023-11-01 14:08 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-10-31  3:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107513

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-10-31
             Status|UNCONFIRMED                 |NEW
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=96780
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The patch for PR 96780 added -ffold-simple-inlines which works for some
specific functions. This attribute would extend that to arbitrary functions.

Confirmed as a very useful extension.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/107513] [Feature Request] Implement __attribute__((__nodebug__))
  2022-11-02 20:59 [Bug c++/107513] New: [Feature Request] Implement __attribute__((__nodebug__)) roi.jacobson1 at gmail dot com
                   ` (5 preceding siblings ...)
  2023-10-31  3:14 ` redi at gcc dot gnu.org
@ 2023-11-01 14:08 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-11-01 14:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107513

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #6)
> The patch for PR 96780 added -ffold-simple-inlines which works for some
> specific functions. This attribute would extend that to arbitrary functions.

I discussed this with Jason and Patrick, and the -ffold-simple-inlines effects
are not appropriate for implementing this attribute, because the attribute
might get used on functions which cannot be trivially folded by the front end.

It would need to be implemented differently, but probably wouldn't be
difficult.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-11-01 14:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02 20:59 [Bug c++/107513] New: [Feature Request] Implement __attribute__((__nodebug__)) roi.jacobson1 at gmail dot com
2022-11-02 21:06 ` [Bug c++/107513] " pinskia at gcc dot gnu.org
2022-11-02 21:23 ` roi.jacobson1 at gmail dot com
2022-11-02 21:32 ` pinskia at gcc dot gnu.org
2022-11-02 22:13 ` redi at gcc dot gnu.org
2022-11-03 10:34 ` roi.jacobson1 at gmail dot com
2023-10-31  3:14 ` redi at gcc dot gnu.org
2023-11-01 14:08 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).