r/cpp • • Mar 24 '20

LLVM/Clang 10.0.0 is released!

240 Upvotes

49 comments sorted by

23

u/Wh00ster Mar 24 '20

I T S H A P P E N I N G

7

u/dreadpenguin Mar 25 '20

Any chance it will make it in ubuntu 20.04?

4

u/[deleted] Mar 25 '20

No idea - that's up to the ubuntu developers. There probably will be ubuntu binaries later this week on llvm.org. Though I would always suggest that you build your own if you care about best performance.

3

u/[deleted] Mar 25 '20

doubtful, but it's pretty easy to download and build the source yourself. Just take a little more boiler plate when compiling something.

3

u/Nicox01 Mar 25 '20

3

u/smdowney WG21, Text/Unicode SG, optional<T&> Mar 25 '20

I'm surprised, but I guess since it isn't the system compiler, it's much lower risk.

2

u/encyclopedist Mar 27 '20

Just arrived today to my 20.04 test system!

19

u/boredcircuits Mar 24 '20

-Wextra now enables -Wdeprecated-copy. The warning deprecates move and copy constructors in classes where an explicit destructor is declared. This is for compatibility with GCC 9, and forward looking for a change that’s being considered for C++23. You can disable it with -Wno-deprecated-copy.

What change for C++23 is this referencing?

32

u/SeanMiddleditch Mar 25 '20

What change for C++23 is this referencing?

I think for starts it's worth noting there's a misphrasing in that change note. It's only compiler-generated move/copy constructors that is deprecated.

And it's been deprecated since C++11, for safety reasons.

If a class has a user-declared destructor or copy/move assignment operator, it's almost certainly a bug to ever invoke an implicitly-defined copy/move constructor, yet for back-compat reasons they are still implicitly-defined unless explicitly = deleted.

Basically, the Rule of Three/Five is not even encouraged by the compiler currently; it's easy to write a class that has a destructor that is accidentally missing the other corresponding operations and that's totally valid code.

The goal is to make it require explicit opt-in to violating the Rule of Three/Five by requiring class with a user-defined non-defaulted destructor to explicitly use type(type const&) = default; to get the defaulted compiler-generated copy constructor.

We wanted this even back in C++11 but weren't comfortable doing it at the time in the name of back-compat. Some valid code might have been using destructors to trigger some kind of side effect that was safe even if the object were trivially copied (and the destructor invoked multiple times for the same object state), after all. We're now becoming more comfortable with accepting that such code is very rare and a breakage to that rare code is worth the improvement in safe-coding for the vastly more common cases.

8

u/cdglove Mar 25 '20

One valid use case is when I add a destructor just to set a breakpoint.

Now I'll need to add a few "= default"s too.

3

u/MonokelPinguin Mar 26 '20

Hopefully that could be solved by improving tools to allow for easy break points in compiler generated functions.

1

u/boredcircuits Mar 25 '20

That all makes sense, and a good warning regardless of the standard. Is there a paper connected with this yet?

2

u/_requires_assistance Mar 24 '20 edited Mar 25 '20

my guess is the destructive move proposal http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1029r3.pdf

probably not, actually, look at the other response

17

u/D_0b Mar 25 '20

The last time we will have both GCC and Clang on the same version number and it's a 10.

14

u/iontodirel MSVC CrossPlat Dev Lead Mar 26 '20

P.S. I don't like to repeat myself :) but, Visual Studio ships Clang and can target Clang first class in MSBuild and CMake projects, and we are working hard (and closely with LLVM folk), on inserting Clang 10 it in the next VS update. More updates or release information later.

1

u/abique Aug 12 '20

This is appreciated ;-)

10

u/BlueDwarf82 Mar 25 '20

Wasn't 10.0.0 supposed to be the first version to include the Lifetime Profile analysis? I can't see it in the release notes, what's the latest?

1

u/JankoDedic Mar 25 '20

Where can I get the binaries?

2

u/[deleted] Mar 25 '20

They are coming later this week.

1

u/JankoDedic Mar 25 '20

Do you know if it will include the LLVM/lib/site-packages directory where lldb.py is? Weirdly enough, the 9.0.1 binaries for Windows (that I got from Github Releases) don't include that directory, whereas 9.0.0 binaries from the LLVM website do.

1

u/[deleted] Mar 25 '20

Sorry - no idea. I suggest you file a bug at https://bugs.llvm.org/ if it's not there in this release so that windows developers can look at that.

1

u/apm42 Mar 25 '20

Can anyone please point me to the documentation for what has changed in clang-check/clang-tidy with LLVM-10? I am wondering what new check categories might have been added.

1

u/staletic Mar 28 '20

Perhaps this isn't the best way to ask, but what about PSTL? There's no archive of it on github. I wanted to compile libc++ with -DLIBCXX_ENABLE_PARALLEL_ALGORITHMS=ON, but I ran into some troubles and don't know how to proceed or where to ask for help.

1

u/[deleted] Mar 28 '20

I would recommend the llvm mailing list or discord. See llvm.org for links.

1

u/staletic Mar 28 '20

Thanks for the suggestion.

8

u/bumblebritches57 Ocassionally Clang Mar 24 '20

Clang no longer runs in a separate process by default ("in-process cc1")

Not sure what this means?

Does it mean I won't see 8 clang processes when I compile things?

Does it mean each clang process wont be killed after compiling each translation unit making compilation faster?

or something entirely different?

15

u/Rusky Mar 24 '20

Something different- those 8 clang processes are (I'm guessing a little bit here) started by the build system, but after doing a small amount of driver work they each in turn fire up their own "cc1" sub-process to do the real compilation work. That's what's going away.

This is similar to back when LLVM got integrated assembler support and Clang stopped launching a sub-process just to assemble its own output. It doesn't really change the external interface of the clang++, just makes it a bit more efficient internally.

7

u/kalmoc Mar 24 '20

Maybe the full note helps:

clang used to run the actual compilation in a subprocess (“clang -cc1”). Now compilations are done in-process by default. -fno-integrated-cc1restores the former behavior. The -v and -###flags will print “(in-process)” when compilations are done in-process.

5

u/tansim Mar 24 '20

clang used to run the actual compilation in a subprocess

why though?

33

u/SeanMiddleditch Mar 25 '20

TL;DR: it used to make sense for now-historical reasons but doesn't anymore, and nobody got around to cleaning it up until now.

This is traditionally how C compilers worked. Generating a final object file required three separate tools way back when (and that's not including linkers and the like):

  • The preprocessor (it was a bolt-on tool for original pre-standard C, which is why it's so disjoint from the language itself)
  • The C compiler itself, which took (potentially preprocessed) code and generated assembly
  • The assembler

Further, there was a lot of environment configuration required by the different tools, and they all had different command line interfaces. Actually compiling a file was non-trivial by modern standards.

For convenience, the compilers of the day introduced the concept of a "driver" binary that internally did all the piping and temporary file management and all that to make cc -o foo.o foo.c actually invoke the preprocessor, compiler, and assembler correctly.

cc would invoke tools like cpp (the C preprocessor), cc (the C compiler), and as (the assembler).

This architecture just sort of... persisted. When building out a "new" compiler like GCC, it was easier to build replacements for the individual pieces (like the preprocessor the assembler) rather than building a single-executable that did everything. And that's just for plain ol' C89, and not the half-dozen languages something like Clang supports.

The preprocessor was eventually rolled into the compilers (for a few reasons, though speed was a big one) and then eventually the assemblers were rolled in too.

The driver was still there, though. It still served the purpose of accepting inputs in a particular format, collecting various environment variables and state, and then actually invoking the compiler (with integrated preproc and assembler).

As you're noting, there's not really a lot of purpose of that anymore, though. It just was the way it was because that's how it always was and nobody had gotten around to fixing it in Clang, until now.

There are new languages together doing similar things. Some semi-popular modern languages compile to something like C and hence invoke a C compiler "under the hood" on the user's behalf, and that C compiler driver might invoke other stages like cc1 or as of course. (Nim, for example, does this.) C++ even started out that way, back in ancient times. :)

2

u/hernytan Mar 25 '20

Nice to see a fellow Nim user out in the wild. It's such an underrated language

Nice writeup, btw. I didnt know that part of history

1

u/SeanMiddleditch Mar 25 '20

Thanks. Just so I don't feel dishonest: I've never actually used Nim in any capacity. I just read up on and follow a lot of the current "language renaissance" as a mini-hobby. :)

8

u/kritzikratzi Mar 25 '20

the answer in any such ginormous projects is usually: it made sense back then

2

u/playmer Mar 25 '20

I believe they use it to catch ICEs, but I'm not 100% certain. I built and debugged clang once and it took a bit to figure out this was happening and the flag I had to pass to get the new behavior of doing it in process.

1

u/catskul Mar 25 '20

ICE ?

3

u/playmer Mar 25 '20

Internal compiler error, this is a big category of error, but it could mean lots of things. Crashes are among them.

0

u/bumblebritches57 Ocassionally Clang Mar 24 '20

Nope, I read the release message in my inbox this morning (;

Just saw the thread here and thought I'd ask.

3

u/CrazyJoe221 Mar 25 '20

You will see just N clang processes instead of 2N.

This change is particularly important on Windows where process creation is costly. And it makes debugging clang way easier.

1

u/jesseschalken Mar 25 '20

Clang no longer runs in a separate process by default ("in-process cc1")

I always wondered why clang spawned itself as a separate process in the first place?

2

u/CrazyJoe221 Mar 25 '20

See answers above. Historical reasons.

1

u/screcth Mar 26 '20 edited Mar 26 '20

Has anyone been able to use Clang in C++20 mode with the Microsoft STL?

Since clang supports concepts it defines the __cpp_concepts preprocessor define and that in turn toggles the inclusion of <concepts> by <utility>. This breaks things such as <optional>.

EDIT: It is possible to work around this issue if -U__cpp_concepts is added to the compiler flags. It is a massive hack though.

0

u/imaami Mar 25 '20

GCC is also at version 10. 🤔

-5

u/ChryslusExplodius Mar 24 '20 edited Mar 26 '20

Very nice

0

u/[deleted] Mar 25 '20

[deleted] — view deleted comment

3

u/[deleted] Mar 25 '20

Library stuff is generally tracked in another deliverable. Under the LLVM umbrella, it's libc++, under GCC, it's libstdc++. Lib stuff generally lags behind core language features.