http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47047
Summary: Support for path translation in __FILE__ Product: gcc Version: 4.1.3 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: preprocessor AssignedTo: unassig...@gcc.gnu.org ReportedBy: jo...@netbsd.org Created attachment 22841 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22841 Implement cpp -iremap __FILE__ expands to full path names in some situation, e.g. if it is used in a header found via -I/some/where. The resulting leak of the header location into the file binary is undesirable in certain situations. For NetBSD, two relevant cases are the visiblity protection in pkgsrc, which effectively turns /usr/pkg/include/foo into /.../work/.buildlink/include/foo and cross-compiling the system, which would leak /.../usr/include/foo instead of /usr/include/foo or the location of the source tree. The attached patch implements a CPP option to match the file path against a list of prefixes and substitute the prefix on match. With this patch, most references to the src and obj locations in NetBSD can be translated into the canonical positions. The patch is the version included in NetBSD against the system gcc, it can be updated if necessary.