Live data from Hacker News

Clang 5 in a Docker container for C++17

solarianprogrammer.com

31–40 of 69 posts

Re: Clang 5 in a Docker container for C++17

#31
post #2

It feels like cargo-cult computer usage. The description states: "Running Clang in a container has the advantage that it is light on resources and won’t mess with your underlying OS.". Containers aren't really light on resources if the host kernel is not Linux and not messing with OS is easily attainable by installing the binaries in a custom prefix directory (e.g. ~/bin). This is especially true for compilers which…

Perhaps if we append "and your underlying OS won't mess with it", then you'll begin to see some value here?

So now docker messes with it?

Re: Clang 5 in a Docker container for C++17

#32
Recent versions of several Linux distributions and FreeBSD have made newer clang and g++ versions available, which both have decent support for C++17 features.

For example, Ubuntu 17.10 provides clang-5.0-3 and g++ 7.2.0. Installing clang 5 there is as easy as

    sudo apt install clang-5.0
It's also easy to install various compilers side-by-side there, without messing up the entire system.

For die hard everyday C++ development, one probably does not want the C++ compiler run in a somewhat restricted container and experience all the potential trouble and limitations.

However, containerizing the compiler is a good way for providing a standardized build environment, because one can pin the exact versions of the compiler, libraries etc.

I have also seen people moving all their not-so-important stuff and/or the components that they do own maintain themselves out into Docker containers, in order to keep their base systems lean and clean. And so they can get rid of the containerized things easily should they become irrelevant. Plus keeping the containerized things relatively stable and unaffected by changes to the base system.

Re: Clang 5 in a Docker container for C++17

#34
post #2

It feels like cargo-cult computer usage. The description states: "Running Clang in a container has the advantage that it is light on resources and won’t mess with your underlying OS.". Containers aren't really light on resources if the host kernel is not Linux and not messing with OS is easily attainable by installing the binaries in a custom prefix directory (e.g. ~/bin). This is especially true for compilers which…

Perhaps if we append "and your underlying OS won't mess with it", then you'll begin to see some value here?

No, it is rather vague what the original article means by "won’t mess with your underlying OS". And your "underlying OS won't mess with it" is equally vague too, IMHO. Providing some examples of "mess with" will be helpful.

Re: Clang 5 in a Docker container for C++17

#36

Recent versions of several Linux distributions and FreeBSD have made newer clang and g++ versions available, which both have decent support for C++17 features. For example, Ubuntu 17.10 provides clang-5.0-3 and g++ 7.2.0. Installing clang 5 there is as easy as sudo apt install clang-5.0 It's also easy to install various compilers side-by-side there, without messing up the entire system. For die hard everyday C++ deve…

> Recent versions of several Linux distributions

Hell, even on CentOS 7 you can install devtoolset-7 and get GCC 7.2.1

Re: Clang 5 in a Docker container for C++17

#37
Check this out: https://github.com/sol-prog

Solarian programmer seems to be a talented C++ coder.

Thanks for the projects.

The Docker post was a niche thing. There's other posts for getting a system running with Clang 5 on other platforms: https://solarianprogrammer.com/2017/12/13/linux-wsl-install-.... Another cool post about C++17 and raspberry pi a few days earlier: https://solarianprogrammer.com/2017/12/08/raspberry-pi-raspb...

Sure, I wouldn't use Clang in a Docker container (heh). But there are some points. If building from LLVM+Clang from source, installing files/headers and such can mess up systems royally. One docker container could theoretically test drive clang everywhere without mucking up a system.

Re: Clang 5 in a Docker container for C++17

#39

Just occurred to me: if Docker is a container software and not a vitalization software, how does it run Linux executables on an OSX host?

“Docker Engine” doesn’t but “Docker for Windows” provides several tools including a wrapper around Hyper-V. I’m sure “Docker for Mac” does something similar.

A year or two ago, it used to spin up Virtual Box.

Re: Clang 5 in a Docker container for C++17

#40

Just occurred to me: if Docker is a container software and not a vitalization software, how does it run Linux executables on an OSX host?

It runs on top of a user-space virtual machine (xhyve, IIRC) that runs on Hypervisor.framework that IS running linux.
Post reply on HN