Skip to content

PCH does not support class comment (unless a dictionary is requested) #23132

Open

Description

@pcanal

As discovered during the discussion: #23093 (comment), classes that are in the PCH but do not have a dictionary apparently lose their comments. All other cases works fine (fully interpreted via declaration on the command line or loaded via a file or coming from a pcm).

Note: There is intentionally no dictionary requested of ROOT::Experimental::RHistEngine<unsigned char>.

For example with a build (using commit 34f12c3) with runtime_cxxmodules:BOOL=ON we get:

root [0] auto cl = TClass::GetClass("ROOT::Experimental::RHistEngine<unsigned char>")
(TClass *) 0x887935180
root [1] cl->GetListOfDataMembers()->ls()
OBJ: TListOfDataMembers	TListOfDataMembers	List of TDataMembers for a class : 0
 OBJ: TDataMember	fAxes	 : 0 at: 0x88793c000
 OBJ: TDataMember	fBinContents	 : 0 at: 0x88793c140
 OBJ: TDataMember	fSnapshot	! : 0 at: 0x88793c280
 OBJ: TDataMember	SupportsWeightedFilling	 : 0 at: 0x88793c3c0
root [2] 

use

auto cl = TClass::GetClass("ROOT::Experimental::RHistEngine<unsigned char>");
cl->GetListOfDataMembers()->ls();

to reproduce.

On the other with a build with runtime_cxxmodules:BOOL=OFF we get:

MAC-148901:master-untouched (hahnjo-hist-snapshot-pause) pcanal$ root.exe -b -l
root [0] auto cl = TClass::GetClass("ROOT::Experimental::RHistEngine<unsigned char>")
(TClass *) 0x90d895680
root [1] cl->GetListOfDataMembers()->ls()
OBJ: TListOfDataMembers	TListOfDataMembers	List of TDataMembers for a class : 0
 OBJ: TDataMember	fAxes	 : 0 at: 0x90d74d7c0
 OBJ: TDataMember	fBinContents	 : 0 at: 0x90d74d680
 OBJ: TDataMember	fSnapshot	 : 0 at: 0x90d74d900
 OBJ: TDataMember	SupportsWeightedFilling	 : 0 at: 0x90d74da40

Where the different is:

 OBJ: TDataMember	fSnapshot	! : 0 at: 0x88793c280

which has the correct comment (!)
vs

 OBJ: TDataMember	fSnapshot	 : 0 at: 0x90d74d900

Using a simplistic class:

struct ABC {
  int i; // persistent
  int j; //! transient
};

You can load this class via the command line or via a header file and it will work in all builds. If the same definition is copy/pasted inside hist/histv7/inc/ROOT/RHistEngine.hxx, it will present the same behavior as in the original report.

Activity

  1. dpiparo commented on Aug 22, 2026

    @dpiparo
    Member

    Is this something we ever wanted to implement?
    If I understand correctly https://github.com/root-project/root/blob/master/core/dictgen/src/rootcling_impl.cxx#L2455 comments are propagated to the AST nodes to persistify starting from selected classes.
    This choice was motivated by runtime performance arguments. Creating the PCH takes tens of seconds, and inspecting each end every CXXRecordDecl instance recursively, e.g. including the associated FieldDecl instances, would have a price in terms of time spent creating the pch.

  2. self-assigned this
    on Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions