Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
What monster is llvm?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
patrix_neo
Guru
Guru


Joined: 08 Jan 2004
Posts: 520
Location: The Maldives

PostPosted: Wed Jun 27, 2018 8:46 pm    Post subject: What monster is llvm? Reply with quote

I have compiled this pile a lot of times. I just want to understand it's underpinnings and dependency. Why does it require such a humongous time to compile?
As if it was an operating system of it's own. It feels wrong for what it's doing. Disk management. As I have understood, it's a logical volume management...system.

EDIT: That was wrong of me. Obviously it has to do with Objective C. Oh gosh. Anytime a objective C program is installed and a new version exists of llvm, you just got burned?
For me that is in extent of about 1,5 hr of compiling time. No matter what the time, just would be fun to know why.


Last edited by patrix_neo on Wed Jun 27, 2018 8:54 pm; edited 1 time in total
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3310
Location: Rasi, Finland

PostPosted: Wed Jun 27, 2018 8:54 pm    Post subject: Reply with quote

You're mixing llvm and lvm. ;)
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
patrix_neo
Guru
Guru


Joined: 08 Jan 2004
Posts: 520
Location: The Maldives

PostPosted: Wed Jun 27, 2018 8:54 pm    Post subject: Reply with quote

Zucca wrote:
You're mixing llvm and lvm. ;)

True dat, yo. :) I kind of mixed things up a little...sorry.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Wed Jun 27, 2018 9:56 pm    Post subject: Reply with quote

LLVM is the compiler apple uses because they're scared of GPL3, so unsurprisingly they don't bother making it work well outside of those $10k+ iMac Pro things with half a TB of RAM and 20+ CPU cores.

then again, GCC is getting fat too lately...
Back to top
View user's profile Send private message
zerodaysfordays
n00b
n00b


Joined: 27 Jun 2018
Posts: 3
Location: Boston

PostPosted: Thu Jun 28, 2018 1:05 pm    Post subject: Re: What monster is llvm? Reply with quote

LLVM is a compiler intermediate-representation that's considered more modular than GCC's; when you see it as a dependency, it's because the program needs to be generating efficient machine code. It takes a long time to compile because it's a very complex piece of software and does several optimizations on the IR code. I'm not sure what it has to do with Objective-C specifically, other than the fact that clang (the reference compiler frontend using LLVM) builds in support for Objective-C unconditionally, unlike GCC.
_________________
tsarfox on IRC
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Thu Jun 28, 2018 10:22 pm    Post subject: Reply with quote

Ant P wrote:
LLVM is the compiler apple uses
It is true that Apple uses llvm, but I wouldn't call it a compiler. It's a compiler back end.
Ant P wrote:
they don't bother making it work well outside of those $10k+ iMac Pro things with half a TB of RAM and 20+ CPU cores.
And this is not true! Clang and llvm work well on Macs, but they also work well on non-Macs. For example, clang is the default C Compiler on FreeBSD nowadays - and it works pretty well on small desktop machines as well as on big servers.
Back to top
View user's profile Send private message
C5ace
Guru
Guru


Joined: 23 Dec 2013
Posts: 472
Location: Brisbane, Australia

PostPosted: Fri Jun 29, 2018 9:07 am    Post subject: Reply with quote

Software coded in C++ compiles much slower than if it's coded in C.
Back to top
View user's profile Send private message
patrix_neo
Guru
Guru


Joined: 08 Jan 2004
Posts: 520
Location: The Maldives

PostPosted: Fri Jun 29, 2018 10:21 pm    Post subject: Re: What monster is llvm? Reply with quote

zerodaysfordays wrote:
LLVM is a compiler intermediate-representation that's considered more modular than GCC's; when you see it as a dependency, it's because the program needs to be generating efficient machine code. It takes a long time to compile because it's a very complex piece of software and does several optimizations on the IR code. I'm not sure what it has to do with Objective-C specifically, other than the fact that clang (the reference compiler frontend using LLVM) builds in support for Objective-C unconditionally, unlike GCC.


It actually produce objective-C++ binaries, in the realm of CLang code. Yes? Then I was thinking of all .cpp code that might use this approach. Sorry, I was a bit too general in my saying. Might still be.
EDIT: As I still read, CLang is an llvm 'native' compiler when compiling C/C++/Objective-C. I learn as I go. So it's in the line of USE=+CLang emerge -1 llvm. Code are not limited to Objective-C. I kind of got that wrong - oops!
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3310
Location: Rasi, Finland

PostPosted: Sat Jun 30, 2018 6:13 pm    Post subject: Reply with quote

C5ace wrote:
Software coded in C++ compiles much slower than if it's coded in C.
I don't code C or C++, but I beleive this is highly depended of what is being coded. Also did you meant to say that the compiled binary is slower?
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Sat Jun 30, 2018 6:37 pm    Post subject: Reply with quote

Zucca wrote:
C5ace wrote:
Software coded in C++ compiles much slower than if it's coded in C.
I don't code C or C++, but I beleive this is highly depended of what is being coded

Sure, you can write a C++ program which is essentially just a C program.
However, if you really use C++ features, in particular templates, then the compiler has to parse quite complex and huge data structures. Something which practically never happens in C.
If you would do this in C, all this work would have been left to the code author - essentially he would have to rewrite most of the code such that all this can be done by simple CPP text processing (without any sanity type checks) or much less efficient by emulating template classes by void pointers. Both is horrible and the reason why C is hardly used in really complex projects if sophisticated data structures are required.
Quote:
Also did you meant to say that the compiled binary is slower?

Probably not, since the opposite is actually the case: Unless you choose the CPP option (which is unmanagable when some complexity level is reached), templates usually generate better code.
Back to top
View user's profile Send private message
saturnalia0
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2016
Posts: 128

PostPosted: Sat Jun 30, 2018 9:02 pm    Post subject: Reply with quote

Delphi has Generic types, which is something like C++'s templates from the programmer's POV, yet compile times are much better (comparing with g++). In fact I've worked on large Delphi projects with lower compile times than much smaller C projects on the same hardware (gcc/Embarcadero's compiler), which is probably due to the single-pass nature of Delphi's compilers.
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Sun Jul 01, 2018 4:36 am    Post subject: Reply with quote

saturnalia0 wrote:
Delphi has Generic types

I am not familiar with the Delphi implementation, but I suspect its generic types are implemented via something like void pointers in C. This means you can compile modules with these generic types, but the generated generic code has one more pointer indirection (perhaps even more) for each access of the stored type.
In contrast, in C++, the generated code does not have such an overhead, but the price you have to pay is that you have to recompile every needed template for every module that needs it. In practice, this means that for a project you actually compile the full standard library STL (and in case that you use complex GUI classes also those) many times which makes the compilation so slow (but OTOH the generated code so effective). This is also one of the reasons why e.g. jumbo-build (combining many modules to one) of chromium is so effective.
In theory, it might be possible to write a C++-compiler which somehow "truly" compiles templates, but this is probably so difficult that no-one ever dared to write one: You would have to do some actual compiling during linking. Perhaps this could be combined with flto, but not in the way this is implemented now. The complexity of the language itself is the main disadvantage of C++.
Back to top
View user's profile Send private message
saturnalia0
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2016
Posts: 128

PostPosted: Sun Jul 01, 2018 10:45 pm    Post subject: Reply with quote

All I found was these 10 year old tech notes from Embarcadero mentioning that

Quote:

The implementation of generics in Delphi, like in other static languages, is not based on a
runtime framework, but is handled by the compiler and the linker, and leaves almost nothing to
runtime mechanism. Unlike virtual function calls that are bound at runtime, template methods
are generated once for each template type you instantiate, and are generated at compile time!
We'll see the possible drawbacks of this approach, but, on the positive side, it implies that the
generic classes are as efficient as plain classes, or even more efficient as the need for runtime
cats is reduced.


So I guess it's somewhat like C++'s templates.
Back to top
View user's profile Send private message
patrix_neo
Guru
Guru


Joined: 08 Jan 2004
Posts: 520
Location: The Maldives

PostPosted: Mon Jul 02, 2018 4:10 pm    Post subject: Reply with quote

Delphi sound much like the issue with the blob of the nvidia-driver with the linux kernel to me. You have a mass of things not able to run through the compiler. ( forget this one, sorry )
I do have a question, relevant to the topic though. Have C++ progressed to a certain stable state it actually can be used? If so, when was the breaking point?
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Mon Jul 02, 2018 7:10 pm    Post subject: Reply with quote

patrix_neo wrote:
Have C++ progressed to a certain stable state it actually can be used?

Definitely.
Quote:
If so, when was the breaking point?

I would say with the release of the C++11 standard.
With this standard most of the previous C++ problems have been solved by well-thought new concepts based on the previous 10 years of experience with C++.
The newer standards C++-14 and C++-17 (and presumably C++-20) contain minor fixees of these new concepts for corner cases, but no really essential change was necessary since then.

Just to give one example: Since the very beginning of C++ you could have implemented an auto_ptr with a destructor which automatically frees its content when it gets out of scope. (Eventually, this even became a part of the standard library STL, unforunately).
Although this looks very elegant at a first glance, it had serious problems: For instance, it causes subtle runtime errors if you store it in a std::vector. Indeed, if the vector enlarges and must shift its content, it would move the pointer (which could only be implemented by copying and deleting the old pointer, hence freeing the content and letting the copy point to an invalid address).
With C++11, there is now a move semantics which avoids this problem. (The move semantics is related with the new rvalue concept which is very technical; fortunately, as a "normal" C++ programmer you do not have to know these technical details, since the standard library just does the right thing).
Moreover, the "correct" variant of auto_ptr - which is now called unique_ptr - has the copy semantics erased (that you can do this is also a C++11 feature).
This means that if you should put this pointer into a "bad" implementation of vector (e.g. in your own class) which does not use the move semantics but the "bad" method of copying+deleting (the only available method in C++98), you would now get a compile time error instead of a subtle runtime error.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum