On Fri, Apr 4, 2014 at 9:08 AM, Lubos Lunak <[email protected]> wrote: > On Friday 04 of April 2014, David Blaikie wrote: >> The comment in CGDebugInfo.cpp says that -main-file-name will contain >> only the file name, with no path information. Are there cases where >> that is not true when -main-file-name is passed from the Clang driver, >> rather than by the user in your example below? >> >> If the driver provides this guarantee and the user violates it when >> passing an undocumented flag manually, I don't see a need to support >> it - but if there is such a need, it'd be good to >> understand/documemnt/discuss it. > > I think the driver always only passes the filename, but I do pass it > explicitly, since I feed the source from stdin and the source or even its > directory don't exist (distributed compiling, the same way with the patch > for -dwarf-split-file). > > And actually case 2) without using the option explicitly results in > DW_AT_name becoming "/-" (I don't know why the driver doesn't simply pass the > name as it is, which wouldn't need the code that attempts to rebuild it > later). > > As for "undocumented", the documentation status of the option is about the > same like with many others - it's just in the .td file including its > description. The description says quite clearly what the option does, it > doesn't say it's internal, it works fine (except for these small problems), I > even checked the sources to be sure, and I don't see why Clang should forbid > usage of the option if I know what I'm doing (and would have to resort to > ugly hacks otherwise). >
There's no guarantee that the option will continue to exist at all so I'd really prefer that you not use it. Any time you have to use -Xclang to set something then it's not an exposed option that you should be using. That said, if we can come up with a structured set of uses for this sort of compilation strategy rather than piecemeal then we should discuss it and how it'll fit into the driver. -eric >> On Fri, Apr 4, 2014 at 5:02 AM, Lubos Lunak <[email protected]> wrote: >> > The handling of -main-file-name in CGDebugInfo::CreateCompileUnit() can >> > result in incorrect DW_AT_name in somewhat special cases: >> > >> > 1) >> > $ touch /tmp/a.cpp >> > $ >> > clang++ -Wall -c /tmp/a.cpp -g -o /tmp/a.o -Xclang -main-file-name >> > -Xclang /new/path/a.cpp $ readelf -wi /tmp/a.o | grep DW_AT_name >> > <12> DW_AT_name : (indirect string, offset: >> > 0x15): /tmp/new/path/a.cpp >> > >> > 2) >> > $ touch /tmp/a.cpp >> > $ cd / >> > $ cat /tmp/a.cpp | clang++ -Wall -x >> > c++ -c - -g -o /tmp/a.o -Xclang -main-file-name -Xclang a.cpp >> > $ readelf -wi /tmp/a.o | grep DW_AT_name >> > <12> DW_AT_name : (indirect string, offset: 0x15): /a.cpp >> > >> > The attached patch fixes those. Ok to commit? > -- > Lubos Lunak > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
