8 ms·
OpenBSD switches the default compiler on amd64 and i386 to clang
- saghm 9y agoWhat's the easiest way to view the actual commit diff? I'm curious about what version of clang they're using, as the message indicates that they were using gcc4 before, which is fairly old.
- pdonis 9y agoThey also appear to be using CVS, which is even older. :-)
- saghm 9y agoTouche!
- bluejekyll 9y agoGood god. Seriously? There are so many much better options, and of course the obvious Git... I remember working with CVS, it was horrendous; I'm surprised a project of this size is still on CVS.
- andrewchambers 9y agoI don't think they like GPL, so the number of better options decreases rapidly.
- bluejekyll 9y agoIs there some reason this would come into play for the source management tool?
- yellowapple 9y agoIdeally, the source management tool(s) would be included with the OS (so that the OS can self-host), which means that it's a factor for the same reason why OpenBSD has preferred non-copyleft licenses for (most of) the rest of the system.
- saghm 9y agoIIRC, Gentoo still uses CVS as well (which is arguably more fundamental to the project since it's source-based). The original creator of the OS now works on Funtoo, which is based on Gentoo but uses git.
- jbergstroem 9y agoSwitched roughly two years ago: https://www.gentoo.org/news/2015/08/12/git-migration.html https://www.gentoo.org/news/2015/08/12/git-migration.html It was an interesting migration project to follow seeing how the portage tree is huge.
- deleted 9y ago[deleted]
- bch 9y ago> IIRC, Gentoo still uses CVS... Somebody corrected this (Gentoo VC software) later, but NetBSD does also still use CVS. Repo conversions are indeed big, interesting projects. I've closely-witnessed/been-peripherally-involved in a few, and there were some interesting papers written about various conversions years ago[0], when both git and mercurial were new and iirc monotone still had interest. [0] both Mozilla and Sun were publishing their analysis and growing pains
- ams6110 9y agoCVS works for them, so they keep using it. The devil you know, etc.
- bluejekyll 9y agoSVN is a relatively painless migration, and is better simply because of a single changlist number to track like perforce. Personally I advocate for Git, in leu of that, mercurial. CVS was so painful, it's just hard for me to imagine that people aren't actively figuring out a way off of it. It's literally one step above RCS...
- ams6110 9y agoWhen all your tooling is built around source repository X, and you understand how it all works, and you understand its quirks and how to avoid them, and you have demonstrated repeatedly the ability to hit release target dates consistently year after year, what then is the sound rationale to switch to source repository Y, and spend the considerable effort to change everything, just so you can keep doing what you are doing now?
- bluejekyll 9y agoI'm impressed that they are able to do that. I'm not going to enumerate all the advantages of Git like tools over CVS here. I do know the pain of migration. I've done it at multiple companies, and am currently figuring it out for an extremely large codebase to get off of Perforce and onto Git. There are significant productivity gains with Git across organizations that make it a worthwhile investment.
- X86BSD 9y agoI personally prefer Fossil. It's a really nice little SCM with all sorts of neat features like built in wiki and great documentation.
- azinman2 9y agoIt's interesting to me to see this project be both so innovative in security domains, yet so backwards in usability. I was trying to install openbsd on a new router this week, and I had a hell of a time trying to repartition the disk such that it didn't pre-allocate partitions for X11 (which I had no use for). I could delete partitions but then I got empty spaces and seemingly no good way to resize via the primitive CLI. I googled around and found this thread [1], where someone suggested a GUI installer to help novice users install it, which got this reply: "Uh no. The OpenBSD installation routine is perfect as is. I would not want to see a GUI installer on my favourite BSD." Really, perfect? Could not be possibly improved? And because you don't want a GUI, no one should have one? All the rest of the replies were similar to boot. I went back to Linux as I can only imagine what the rest of running it is like. Sometimes old stubborn cranks can really get in the way of progress. [1] http://daemonforums.org/showthread.php?t=8580 http://daemonforums.org/showthread.php?t=8580
- Zelmor 9y agoIt is one of the reasons, according to past contributors, why the project participation stagnates. Old devs have their flags and config all set up, and don't want to change to a new source control system just to get new kids on the block. A good example of how bds operating systems are being developed for the developers themselves, not for public use.
- brynet 9y agoOpenBSD's been at it for awhile.. Yes, CVS; .. on top of which they invented read-only anonymous source control: https://www.openbsd.org/papers/anoncvs-paper.pdf https://www.openbsd.org/papers/anoncvs-paper.pdf Of course you're free to use the, far more recent, GitHub mirror: https://github.com/openbsd https://github.com/openbsd
- drewg123 9y agoI imagine gcc4 was used due to it being the last gcc available before gcc moved to GPLv3. At least that's why FreeBSD stuck with it as the base compiler.
- saghm 9y agoGood point! I hadn't thought of that. That being said, I thought that GPL was compatible with BSD; is that not the case for GPLv3, or was this more of an ideological choice by the OpenBSD developers? Edit: Not sure what the reason for downvoting an honest question is; from Googling, I can't find anything about incompatibility between GPL and BSD, and I didn't express any opinion about the merits of BSD vs. GPL.
- notaplumber 9y agohttps://www.openbsd.org/policy.html https://www.openbsd.org/policy.html
- saghm 9y agoTo save others who might read this thread some time, the specifics of this issue are described by this: "For historical reasons, the OpenBSD base system still includes the following GPL-licensed components: the GNU compiler collection (GCC) with supporting binutils and libraries, GNU CVS, GNU texinfo, the mkhybrid file system creation tool, and the readline library. Replacement by equivalent, more freely licensed tools is a long-term desideratum."
- snuxoll 9y agoI mean, in the case of a C compiler your code is mere data so license compatibility isn't really the concern. BSD projects don't care for the anti-tivoization clause in the GPLv3 because it restricts where the software can be deployed, the GPLv2 was acceptable because there was no better alternative at the time and, again code was data in the case of a compiler.
- Someone 9y ago
- voutilad 9y agoOpenBSD has had a github mirror for awhile now. The commit is here: https://github.com/openbsd/src/commit/bc04e837fd81a3001f68f102c770b45a53840885 https://github.com/openbsd/src/commit/bc04e837fd81a3001f68f1... As for clang version, it looks to be 4.0.0 per https://github.com/openbsd/src/commit/53d771aafdbe5b919f264f53cba3788e2c4cffd2 https://github.com/openbsd/src/commit/53d771aafdbe5b919f264f...
- saghm 9y agoAwesome, thanks a bunch!
- Freaky 9y agoIf you want to dig through history, FreshBSD may be of use: https://v4.freshbsd.org/project/openbsd/src?q=clang https://v4.freshbsd.org/project/openbsd/src?q=clang
- cpach 9y agoSide-note: In the changed file, the first line is “$OpenBSD: bsd.own.mk,v 1.186 2017/07/26 19:44:42 robert Exp $”. Does anyone know if this line is updated by CVS or some other tool?
- gkya 9y agoThat's a CVS keyword, it's updated when the file is checked out or after it's committed. 1.186 is the most recent version of that file.
- deleted 9y ago[deleted]
- deleted 9y ago[deleted]
- Gracana 9y agohttp://cvsweb.openbsd.org/cgi-bin/cvsweb/src/share/mk/bsd.own.mk.diff?r1=1.185&r2=1.186 http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/share/mk/bsd.ow...
- justin66 9y agoWhat's the meaning of "default compiler" in this context? Will the kernel be built with clang or gcc?
- thesmallestcat 9y agocc
- justin66 9y agoWhich was gcc, until today. Has that changed?
- thesmallestcat 9y agoIt's a symlink. And yes, there is no other meaning of "switching the default compiler." The effect is that any tooling that uses `cc` (like the `CC` implicit variable in Make) will now use `clang` rather than `gcc`. So any software built on the system uses clang unless you force it to use something else. No idea if they will still distribute gcc by default.
- justin66 9y agoWhat I'm getting from your comment is that they're switching everything over to building with clang, including the kernel. That's interesting (it's a bold move) since there have been a few systems over the years that set aside a separate compiler just for building the kernel.
- Crontab 9y agoThe commit sounds like the people using OpenBSD for these processors will have two compilers installed. I am not a programmer but I am curious: how does one select GCC as a compiler if the default is Clang? Just change what CC links to?
- voutilad 9y agoFor projects that use configuration frameworks it's often just setting an environment variable like CC or CXX to point to the compiler(s) you want and they'll use those particular binaries when building. If there is a symlink it's probably ill advised to change it since it would be system-wide.
- kev009 9y agoMake and most other build systems respect the CC and CXX variables. Switching compilers is a very common thing among systems developers.. bootstrapping OS builds, crosscompiling for a different arch, getting compiler feedback from another compiler, etc
- bch 9y agoThere are env variables as others have mentioned, and additionally in NetBSD it's configurable in mk.conf[0]. I know, Net is not Open, but they look remarkably similar in this toolchain regard for system/package builds. Can't speak to Free or Dragon Fly, though. I wouldn't be surprised if they've diverged. [0] https://wiki.netbsd.org/tutorials/pkgsrc/clang/ https://wiki.netbsd.org/tutorials/pkgsrc/clang/
- dman 9y agoAny idea if they are switching to using lld as the system linker as well?
- milcron 9y agoBased on this mailing list thread, I would assume so. https://marc.info/?l=openbsd-tech&m=148961125932497&w=2 https://marc.info/?l=openbsd-tech&m=148961125932497&w=2
- dman 9y agoExcellent! I have a soft spot for openbsd as a workstation os. Will give it a try again once this hits a release.
- Cieplak 9y agoWhat are some cool ways to introduce vulnerabilities into LLVM so that even "secure" languages like Rust are vulnerable to software-based exploits?
- adrianN 9y agoBecome a regular contributor to LLVM for some time to build trust and then sneak in some complex optimization that under some rareish circumstances leads to exploitable binaries.
- eicossa 9y agoOP's probably a script kiddie who thought "Hacker News" meant the other type of hacker.
- ketralnis 9y agoI'd imagine they're mostly the same kinds you could have in gcc
- pksadiq 9y ago> I'd imagine they're mostly the same kinds you could have in gcc Except that you'll have to provide your real identity for copyright assignments. It may be hard create fake identities unless you are related to some big 3 letter agencies.
- jwilk 9y agoHow does FSF verify that the identity you claim is real?
- wuch 9y agoNow that OpenBSD has an optimizing compiler maybe they will notice and fix dataraces in their pthread_mutex_lock implementation. Currently they use broken double-checked locking pattern when mutex is lazy initialized with PTHREAD_MUTEX_INITIALIZER.
- wuch 9y agoIn case someone is interested, here is relevant code [0]. Notice that mutexp is read without any synchronization, and _spinlock further down uses different lock than one in initialization code (former is specific to this mutex and latter a global one). There is no happens before relationship between mutex initialization and mutex locking. Thus, if different thread reads non-null value of *mutexp, there is no guarantee that writes done to the mutext structure itself will be visible. Given strong memory model of amd64 and i386, compiler would have to reorder pointer publication and structure initialization in pthread_mutex_init, unlikely but certainly a valid change given lack of synchronization. [0] https://github.com/openbsd/src/blob/0ecb71b5ec9e4b22a484606f2e1eedce2a292e2d/lib/librthread/rthread_sync.c#L86 https://github.com/openbsd/src/blob/0ecb71b5ec9e4b22a484606f...
- Ded7xSEoPKYNsDd 9y agoCorrect me if I'm wrong, but I think a compiler that doesn't do link-time-optimization has to assume that the _spinlock() function can write to mutexp (e.g. through a global variable), and therefore it cannot reorder anything around it.
- wuch 9y agoI think you are looking at the side that does the reading. I was actually thinking about the other side that does the writing (inside pthread_mutex_init), where those two things are not separated by any function calls and are more readily reordered. Not to mention that it would be problematic on architectures with relaxed memory model either way.
- marios 9y agoHave you reported this bug upstream ?
- deleted 9y ago[deleted]
- anon_d 9y agoThis is a big deal! Weren't the OpenBSD pretty clang-hostile a few years back? Maybe I'm mixing up them and the suckless people? I think I remember that they were even trying to move away from gcc to something home-grown and simpler, since gcc is such a huge dependency and even uses c++ now.
- teamhappy 9y agoI think their biggest grief was the potential switch to the Apache license.
- shakna 9y ago> I think I remember that they were even trying to move away from gcc to something home-grown and simpler You remember pcc, "Portable C Compiler", which, though currently actively developed [0], has a not-so-dependable history. 1.0 released in 2011, 1.1 in 2014, and no releases since. pcc was merged in, but with the spotty history, taken out of base again. > Weren't the OpenBSD pretty clang-hostile a few years back? Not quite. LLVM was evaluated for the main compiler back in 2013 [1], but the main drawbacks was LLVM can't be used for every platform that OpenBSD supports. They also go on to talk about how every open compiler is painful, because there are no LTS releases. Compiler bugs were a major problem for OpenBSD, and I doubt its changed enough for that to not be the case. [0] Mailing list is still going strong, and patches are still coming in and merging. (http://marc.info/?l=pcc-list http://marc.info/?l=pcc-list) [1] Long read, but in-depth: http://marc.info/?l=openbsd-misc&m=137530560232232 http://marc.info/?l=openbsd-misc&m=137530560232232
- deleted 9y ago[deleted]
- deleted 9y ago[deleted]
- fithisux 9y agoI thought they were fan of pcc. In any case, if they drop gcc, then please keep pcc active.
- yazr 9y agoWhere does CLANG vs GCC debate stand in 2017 I know CLANG is used in many research projects (which are often committed to the branch). And i assume many, many legacy projects stick with GCC.
- sprash 9y agoPeople choose CLANG mainly because of its license. But GCC still produces faster binaries.
- DominikD 9y agoNot really, this depends on the code being compiled/run, e.g.: http://www.phoronix.com/scan.php?page=article&item=gcc7-clang4-jan&num=2 http://www.phoronix.com/scan.php?page=article&item=gcc7-clan... GCC however has many more platforms supported, so in certain use cases LLVM is out of the question entirely. That being said: for OS development (and many other projects) predictable and correct is more important than fast. Optimizations that lead to these performance gains are oftentimes harmful given that code is typically far from perfect.
- floatboth 9y ago(what's with the CAPSLOCK, it's lowercase clang) Such blanket statements are not useful. Actually different compilers win on different benchmarks. Look at any test e.g. https://www.phoronix.com/scan.php?page=article&item=gcc8-clang5-znver1&num=2 https://www.phoronix.com/scan.php?page=article&item=gcc8-cla... — GCC is faster for FFTs, clang is faster for matrix factorization, … they trade blows basically.
- DSMan195276 9y agoWorth keeping in mind they didn't do this because they think `clang` is better then the current `gcc` as far as compiling goes, they did it because they don't want to use `gcc` past version 4.3.0 since versions 4.3.0 and up are GPLv3. So this is more a comparison of the current `clang` vs. old `gcc` - obviously not much of a fair comparison.
- drudru11 9y ago
- efficax 9y agoThis is awesome. It's going to save so many headaches building/porting C++ based code on OpenBSD. Hurrah.
- fromme2you 9y agoAwesome? Maybe... https://www.bitrig.org/ https://www.bitrig.org/
- voutilad 9y agoNote, latest amd64 snapshots reflect the switch to clang if folks are curious and want to experiment: > cc -v OpenBSD clang version 4.0.0 (tags/RELEASE_400/final) (based on LLVM 4.0.0) Target: amd64-unknown-openbsd6.1 Thread model: posix InstalledDir: /usr/bin