@ctfeonly
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Thu Dec 7 04:49:04 UTC 2017
On Thursday, December 07, 2017 03:43:42 Nicholas Wilson via Digitalmars-d
wrote:
> On Thursday, 7 December 2017 at 03:18:57 UTC, Jonathan M Davis
>
> wrote:
> > On Thursday, December 07, 2017 02:09:56 lobo via Digitalmars-d
> >
> > wrote:
> >> On Thursday, 7 December 2017 at 01:21:11 UTC, Nicholas Wilson
> >>
> >> wrote:
> >> > I'd like to add an attribute to indicate that the annotated
> >> > function is only available at compile time so that in cases
> >> > where the operation is invalid at runtime (strings and
> >> > concatenation on a GPU for instance) but the result is only
> >> > used at compile time (for a mixin) the compiler is free to
> >> > not codegen that function.
> >> >
> >> > I can add this to LDC pretty easily, but does anyone else
> >> > have a use for this (e.g. shrinking binary sizes for mixin
> >> > heavy codebases) and would benefit having this as a standard
> >> > thing?
> >>
> >> Shouldn't the linker do this already?
> >>
> >> Once the compiler has CTFE'd the function any call in the code
> >> should be replaced with the function evaluation. The linker
> >> should then drop the code out of the binary because it really
> >> is dead code.
>
> Unfortunately I don't have a linker to do that for me with
> DCompute.
>
> > Regardless, needing something like an attribute to tell the
> > compiler to strip stuff out of the binary seems like a hack to
> > me. It may actually be necessary in some cases, but it just
> > feels like it should be unnecessary.
>
> Do you have any other ideas about how to achieve this other than
> an attribute?
> Having an attribute seems the most simple and straightforward.
It may be that an attribute is required in at least some cases, but it seems
like it shouldn't be and that if the compiler and/or linker isn't smart
enough to strip out stuff that's only used at compile time, then it should
be fixed to be smart enough. However, too often, there's some detail that's
not obvious that makes it so that things can't work they way that it seems
like they should. And of course, I have no clue how whatever you're doing
works if you're not using a linker with dcompute, so I don't know how it
differs from normal. I've never done anything with GPU programming.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list