News for hackers. Stuff that matters.
Re:Linus Torvalds on aliasing by caf on Friday June 08, 2018 @01:52AM (#17262923)
It's important to bear in mind that Linux isn't written in standard C - it's written in a dialect of C implemented by recent-ish versions of GCC (there is a particular minimum GCC version supported), with certain compiler switches.

There's nothing wrong with this - it's an important enough project to be able to make those kinds of demands.

Re:Linus Torvalds on aliasing by stefan_ on Friday June 08, 2018 @03:40AM (#17263409)
Android kernels are built with Clang. So really it's just missing support for MSVC, for obvious reasons.
Re:Linus Torvalds on aliasing by berti on Friday June 08, 2018 @07:30AM (#17264308)
For now, at least [1][2]. See the rest of that thread.. llvm guys really don't want asm goto, and kernel really wants it.

[1] https://lkml.org/lkml/2018/2/14/724 [2] https://lkml.org/lkml/2018/2/14/157

Re:Linus Torvalds on aliasing by stefan_ on Friday June 08, 2018 @12:02PM (#17266745)
Well, yeah, that's what the other commentators here misunderstand. Sure the kernel is C, but a non-optional part is assembly in various forms that obviously is not standardized between compilers. So it takes effort to support kernel building. Google paid up and made that happen.
Re:Linus Torvalds on aliasing by tiberius1900 on Friday June 08, 2018 @04:06AM (#17263512)
Clang was made to support GCC extensions and be as close to a drop-in replacement for GCC as possible. Linux misses support for MSVC, Intel C Compiler, XL C and basically every other C Compiler ever written except for these 2.
Re:Linus Torvalds on aliasing by saagarjha on Friday June 08, 2018 @04:19AM (#17263554)
Clang doesn't support every GCC extension, though. For example, nested functions is something that it doesn't do.
Re:Linus Torvalds on aliasing by geocar on Friday June 08, 2018 @04:43AM (#17263650)
Yup. And that one is a deal-breaker for me.

Nested functions is exactly how you would write it in assembly.

Does anyone know why clang won't support them? "Blocks" are fucking stupid.

Re:Linus Torvalds on aliasing by favorited on Friday June 08, 2018 @06:43PM (#17270327)
Because throwing a trampoline on an executable stack is a hack and a glaring exploitation vector.

http://lists.llvm.org/pipermail/cfe-dev/2015-September/04503...

Re:Linus Torvalds on aliasing by geocar on Saturday June 09, 2018 @06:09AM (#17272306)
Straw man.

GCC doesn't use a trampoline for the following code:

    long f1 (void) { long i = 0; void f2(void) { i++; } f2(); return i; }
    int main() { return f1(); }
So maybe David Chisnall doesn't know what he's talking about? Or maybe he's talking about a specific use case further up the thread. I'm not going to speculate.

But to edify on my "Blocks" are fucking stupid throwaway, in clang you can do this:

    long f1 (void) { __block long i = 0; void (^f2)(void) = ^{ i++; }; f2(); return i; }
    int main() { return f1(); }
which is close enough I could almost paper over the syntax differences with macros, but clang produces unnecessary allocations(!) which are completely unacceptable for my targets and make clang unworkable for me -- even if I could stomach the dogshit assembly that clang produces during testing and continue to use gcc on the packaging server.

Surely clang could simply disallow passing the address of the nested function, if it's trying to protect people from themselves?

Re:Linus Torvalds on aliasing by Uberphallus on Friday June 08, 2018 @03:59AM (#17263485)
And Borland Turbo C, don't forget it.
Re:Linus Torvalds on aliasing by jhasse on Saturday June 09, 2018 @04:27AM (#17272100)
MSVC doesn't support all of C99 anyway.
Re:Linus Torvalds on aliasing by taneq on Friday June 08, 2018 @04:59AM (#17263727)
There's no such (real, usable) language as 'standard C'.
Re:Linus Torvalds on aliasing by IshKebab on Friday June 08, 2018 @06:30PM (#17270260)
Nothing is really written in "standard C".