Re: [PATCH 0/4] -ffreestanding/-fno-builtin-* patches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 25, 2020 at 12:57:22AM +0900, Masahiro Yamada wrote:
> 
> 
> To prevent transformation from foo() into bar(),
> there are two ways in Clang to do that;
> -fno-builtin-foo, and -fno-builtin-bar.
> There is only one in GCC; -fno-buitin-foo.
> 
> Is this correct?
> 

It looked that way from previous experimentation, but...

> 
> 
> I just played the optimization
> from printf("helloworld\n") to puts("helloworld").
> 
> https://godbolt.org/z/5s4ded
> 
> 
> -fno-builtin-puts cannot prevent clang
> from emitting puts.
> Is it because clang does not support
> -fno-builtin-puts?

Ugh. clang doesn't have __builtin_puts() but it optimizes printf() into
puts(). It doesn't have __builtin_putchar() but will optimize
printf("c") into putchar('c').

And it has .. half of __builtin_fwrite()? fwrite() of a single byte gets
optimized into fputc(), fprintf() of a string literal gets optimized
into fwrite(), -fno-builtin-fwrite prevents both optimizations, but
__builtin_fwrite() gives a compile error.

I give up.



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux