This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] support for obtaining file basename


On Sat, Jan 02, 2010 at 06:52:28AM -0500, Jakub Jelinek wrote:
> On Sat, Jan 02, 2010 at 11:11:24AM +0100, Robert Millan wrote:
> > Please consider this patch.  It adds support for obtaining file basename via
> > __FILE_BASENAME__.
> > 
> > This would be used by GNU GRUB.  I'll provide some explanation on why this is
> > very necessary for us:
> > 
> >   - Bootloader code is very critical; a bug can render system unbootable. 
> > Additionally, it needs to support a wide range of hardware and firmware. 
> > Because of this, we put extensive debugging support into GRUB.  Debug
> > statements currently rely on __FILE__.
> > 
> >   - We want to support $srcdir != $objdir build setups, and continue supporting
> > them.
> > 
> >   - Some parts of bootstrap code tend to be very size constrained.  Every byte
> > counts, and each debug statement is taking unnecessary space because accessing
> > a file in $srcdir requires either an absolute path or at least a number of
> > '../' components (in Debian, that would be two of them).
> > 
> > Because of this, I would find it very useful if GCC provided __FILE_BASENAME__,
> > or at least an equivalent facility.
> 
> You don't need to add anything to GCC, make is enough.  Just add
> CFLAGS += -D__FILE_BASENAME__=$(<F)
> or something similar.  The advantage is that you can use it with any version
> of GCC and you can customize what exactly do you strip and how etc.
> Adding this kind of bloat to GCC is IMHO unnecessary, next person who will
> want to use something similar will have slightly different opinion on how
> the input filename should be adjusted.
> 
> Best use some non-reserved identifier though, so -DGRUB_FILE_BASENAME=$(<F)
> or something similar instead.

Sounds like this could work.  Thank you

-- 
Robert Millan

  "Be the change you want to see in the world" -- Gandhi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]