[PATCH] Handle properly somewhat special cases of -main-file-name

Lubos Lunak l.lunak at centrum.cz
Fri May 2 04:29:37 PDT 2014


On Friday 11 of April 2014, Eric Christopher wrote:
> 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.

 So how about this patch?

 As said elsewhere, something like

 cd /output ; clang -c -g -gsplit-dwarf /source/a.cpp

 may need to be turned by a distributed build system into something like

 cd / ; clang -c -x c - -g -gsplit-dwarf -o /tmp/fhqtewdsg.o

 These options allow getting the same .o as with the first command by adding

 -fmain-file-name /source/a.cpp -fdebug-compilation-dir /output -fsplit-dwarf-file /output/a.dwo

> >> On Fri, Apr 4, 2014 at 5:02 AM, Lubos Lunak <l.lunak at centrum.cz> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-allow-fmain-file-name-also-in-driver.patch
Type: text/x-diff
Size: 22462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140502/f5d12976/attachment.patch>


More information about the cfe-commits mailing list