11 ms·
Extracting the abstract syntax tree from GCC
- spork1 12y agocomparing emacs to xcode/idea made me lol
- gumby 12y ago> comparing emacs to xcode/idea made me lol Why did it? Emacs is a great development environment. It allows you to focus on the code and supports debugging right next to your code, same as an ide. It is an ide. Emacs lacks some features of xcode/eclipse et al but in exchange it has power they lack. Why shouldn't it gain some of their features? (I am assuming you loled because you considered emacs weaker. My apologies if I got the sense backwards).
- GFK_of_xmaspast 12y agoI've been programming in emacs since 1992, 2014 was the year I finally gave up and started to move into IDEs (having to target android was the primary motivation for using something else, but I'm rapidly getting spoiled, and am going to shell out for clion once it's done). There's stuff I miss about emacs, and I'll keep using it for text files and r code and other stuff (it's still my primary python editor until I get around to trying pycharm), but by and large I think I'm done with it for c/c++.
- yarrel 12y agoI know. XCode really doesn't compare in terms of usability, stability, range of available options, and documentation. Sad really.
- 72deluxe 12y agoHere on HN, Xcode bashing is second only to C++ bashing. What's wrong with xcode? It has static analysis complete with annotations, integration with instruments for thread / network / CPU / memory monitoring, integration with lldb, code completion, code folding, quick navigation, details about callers and callees from any function, details about generated code (so you can look at the preprocessed code), the same with assembly (if you so desire!), test integration, class hierarchies, documentation for relevant functions (same as man, documentation for Apple SDKs) but IS missing refactoring for C++ (it does C and Obj-C). Which bit about all of that is missing?? (other than refactoring C++) I am using 6.1.1 and I haven't had it crash for the past 6 months, using it 7.5 hours a day (and 3 hours a night too). 6.0 was buggy as anything but 6.1.1 is rock-solid for me.
- bedatadriven 12y agoThis is precisely what we do in Renjin in order to translate C/Fortran to Java: https://github.com/bedatadriven/renjin/blob/master/tools/gcc-bridge-plugin/src/main/c/plugin.c https://github.com/bedatadriven/renjin/blob/master/tools/gcc... This little plugin simply dumps GCC's gimple to JSON, yielding for example: https://github.com/bedatadriven/renjin/blob/master/tools/gcc-bridge/src/test/resources/org/renjin/gcc/dqrdc2.f.json https://github.com/bedatadriven/renjin/blob/master/tools/gcc... LLVM's design looks very attractive, but for scientific computing Fortran is really important, and AFAICT, LLVM doesn't have an intermediate representation comparable to Gimple: LLIR seems to be at the level of the registers rather than the nice abstract Gimple, but perhaps I just haven't looked deep enough.
- bedatadriven 12y agoI should mention that the only problem we have this approach is that neither the AST structure nor the plugin API is guaranteed to be stable between releases, so if you want to use Renjin's full tool chain, you have to be able to install a copy of GCC 4.6.x locally, which only gets more difficult over time. This is the actual point of debate: RMS wants to keep these APIs moving targets in order to discourage Intel or whoever from writing a compiler that just shells out to gcc to handle all of the parsing. Unfortunately, fully GPL'd, open-sourced projects like our own (and who knows how many others that were never even started because of these artificial hurdles) are the ones most affected.
- buttproblem 12y ago> LLVM doesn't have an intermediate representation comparable to Gimple: LLIR seems to be at the level of the registers rather than the nice abstract Gimple LLVM variables are sometimes called registers but they are machine independent. The bit width is arbitrary (e.g., you can create a 129-bit integer). The use of the term register is a misleading analogy; often LLVM-IR is compared to assembly language so the use of the term register was also used. I do not know GIMPLE and couldn't find a good description of the IR instructions. But, it seems that LLVM IR is somewhat similar to low GIMPLE.
- bedatadriven 12y ago
- zeograd 12y agoAs much as I love GNU tools "universe", I feel that this ideological position of RMS regarding GCC future is hurting more libre software than it does good. That's a bit saddening.
- astrodust 12y agoThe GPL principle of "all your code belongs to everyone" is infuriating to say the least, and the efforts of those to force this on people is even more damaging to the open-source community. Free, open-source software has helped considerably in the last twenty years. That's why I think licenses like MIT or BSD help keep software free and truly open: Use it for what you see fit without any obligation on your part. That's free.
- jimrandomh 12y agoJust let GCC die already. Not only is LLVM free from this issue, it's technically superior across the board. The general replacement of GCC with LLVM in most applications appears sufficiently inevitable that investing more effort into GCC is wasteful.
- frozenport 12y agollvm cant build a working Linux kernel.
- hga 12y agoI'm pretty sure no one is working hard to fix that right now because GCC does, and for many many more backends, especially solidly. We'll really know things are at a tipping point when LLVM starts to acquire a bunch of solid back ends. I will personally count it as all over if/when Atmel AVR 8 bit is supported.
- sanxiyn 12y agoPreliminary port of LLVM to AVR does exist. http://sourceforge.net/projects/avr-llvm/ http://sourceforge.net/projects/avr-llvm/
- hga 12y agoThat effort died roughly a year and a half ago, but it's been forked, e.g.: https://github.com/dylanmckay/avr-llvm https://github.com/dylanmckay/avr-llvm So, yeah, I should gather my robes and prepare to deliver a Biblical "Repent, sinner, for the end is nigh!"
- sanxiyn 12y agoIt can. Patches are here: http://llvm.linuxfoundation.org/index.php/Main_Page http://llvm.linuxfoundation.org/index.php/Main_Page
- 12y ago
- userbinator 12y agoIsn't GCC itself GPL with all the source available? IANAL, but AFAIK that means as long as you release your modifications under GPL too, it doesn't violate any license. Or are they saying that GCC doesn't actually use an AST somehow, which doesn't match at all with my (admittedly limited) knowledge of it? I'm someone who has experience with what can be done in terms of extending/modifying software even without any source code, so my perspective on things like this are more like... "you have the source and an explicit license to modify it, and no intention of keeping your changes proprietary, so just do it!" Either that or move to clang/LLVM, which I think would be better in the long term.
- TheDong 12y agoThe issue is not that the plugin wouldn't be gpl; it would. The concern is that the AST dumped is not code, but an artifact, and thus can be used by proprietary software and make proprietary software better. I could write a program that compiles your gcc-produced AST for a new architecture, and not GPL it because the AST itself probably isn't GPL protected. That's the fear.
- laichzeit0 12y agoThe fear that someone else might be "better" than you so you're intentionally going to make it impossible for them to even compete is a really dumb argument. Imagine if this was done in sports. And that seems to have been the whole intention behind this. Make sure no non-GPL backend can be used because god forbid it's better than ours. The shame!
- jordigh 12y ago> The fear that someone else might be "better" than you so you're intentionally going to make it impossible for them to even compete is a really dumb argument. Imagine if this was done in sports. It is done in sports. Most sports forbid you from taking drugs that enhance your performance, or are seggregated by sex in order to account for the "natural" (?) unequal distribution of muscular mass across sexes, because we think these would be unfair advantages. The idea here is that the big proprietary software companies are not playing on a level field, since they are not disclosing their source code. The GPL, as I understand rms's intentions, is designed to inhibit that advantage and force everyone to play fairly: if you take code, you must give back code. I don't understand much about the particulars of this case, and public opinion seems to be heavily slanted against rms. Nobody seems to agree with him here, but he's been considered a fool in the past when he was more of a Cassandra. His positions usually come from past experiences he's had. Someone else mentioned elsewhere in this thread that historically the fear was of Intel using gcc as a frontend for icc. Seeing how Intel still contributes code to gcc and how they still maintain icc and how they still love publishing non-free software, perhaps this is still a valid fear. Or perhaps everyone is just using LLVM already for this purpose and it's not likely they would use gcc instead. I don't know. I don't want to cast an opinion on this case beyond what I've already said. Maybe rms is wrong or maybe he's right.
- jesuslop 12y agoExcuse me, but what's so wrong with the existence of a proprietary gcc backend?
- rwmj 12y agoHistory. RMS was worried that "someone" (basically, Intel) would be able to take the gcc frontend and attach the icc (very fast, proprietary) backend to it, thus creating a compiler which could compile the whole GNU stack, producing very fast code. This would entice people to use a non-free compiler. Since then LLVM came along and made the whole point moot, since it has a modular front end which can parse all the gcc extensions.
- yarrel 12y agoUsers are not free to study and modify it to suit their purposes and fix bugs. See here: https://www.gnu.org/philosophy/free-sw.html https://www.gnu.org/philosophy/free-sw.html
- listic 12y ago"misuse of GCC front ends" While Stallman's intent is the opposite, this is sounds awfully like the kind of thinking of big companies that are so easy to hate, where one can "misuse" a binary by reverse-engineering it.
- wging 12y agoIt was my understanding that people have already extended emacs in the usual way to do lots, using llvm or clang, and that this argument is only about trying to do things that can make it into emacs proper. Is that not right?
- tacos 12y agoHe played this game with precompiled headers a decade ago and there's STILL barely any support for it in the GNU tools. When a debate around implementing precompiled headers ten years after everyone else gets them requires lawyers to get involved, maybe freedom isn't ringing as clearly as we were promised. There's something fundamentally weird about the whole dev ecosystem wrt developer productivity. Next time you're sitting in front of an 8 CPU box with an SSD trying to solve a CPAN or library dependency, watching one C file compile once every three seconds, perhaps think about why things always wind up like this. I super respect Stallman's position but at some point you have to look around (and beyond!) and say "why are we working with crippled tools?" With few exceptions all the core projects are uncontributable at this point. And RMS isn't even the worst; he's just the most consistent and predictable.
- ploxiln 12y agoThe tools really aren't that bad. There are many common open source c projects, most notably the linux kernel, which can easily use all your cores and compile tens of objects a second. Compiling crazy c++ codebases are painful for everyone, and in fact were a primary inspiration for the handful of people at Google who created Go, with a primary goal of fast compiles, at some reasonable expense to disk and run-time efficiency.
- falcolas 12y agoBecause RMS' stance has nothing to do with your productivity, and has everything to do with giving you the right to look at every single detail of GCC and make it work better for yourself. If he did open it up for a proprietary component to make its way into GCC (while avoiding the licensing terms), and it becomes mainstream, you have lost that right to view and modify the software that runs on your box, and that is something he does not view as acceptable. Ultimately, it's his decision; it's based on his work, and the contributors agreed to his terms. That he makes it freely available with the condition that it remains freely available is a bonus, not a right.
- kps 12y ago> the right to look at every single detail of GCC and make it work better for yourself. And yet, the referenced discussion breaks down into RMS on one side and people who want to make gcc work better for themselves on the other.
- willvarfar 12y agoAt Symbian we used a GCC backend called GCCXML http://gccxml.github.io/HTML/Index.html http://gccxml.github.io/HTML/Index.html to parse our c++ code to drive various scripts and tools. It never did function bodies, but then we never needed it to. This was over 10 years ago now; frustrating that GCC has ever made clang necessary :(
- overgard 12y agoThis is why I prefer the BSD license for everything I do. In Stallman's universe, "freedom" only exists as long as it furthers his cause. What a waste. As far as I'm concerned, if I write something and release the source, I'm more than happy with people using it for whatever they want.
- deleted 12y ago[deleted]
- eggnet 12y agoThis seems analogous to the stable kernel ABI difference between Linux and FreeBSD. But I haven't seen any particularly deep articles comparing them, and our treatment of the respective project leaders.
- insaneirish 12y ago> It took many years before the GNU Compiler Collection (GCC) changed its runtime library exemption in a way that allowed for GCC plugins, largely because of fears that companies might distribute proprietary, closed-source plugins. Am I the only one who finds it ironic that purported "free as in freedom" software is/was being held back because of fears of what someone can do with that freedom? Though once useful, the GPL and especially the AGPL are harmful, restrictive licenses that have outlived their usefulness and in no way represent "freedom".
- deleted 12y ago[deleted]
- Sanddancer 12y agoStallman's held this view for a very long while. About fifteen years ago, he told someone to memory hole a GCC target to emit JVM bytecode [1] because of the vague threat that someone could take that, create a theoretical frontend that worked on JVM bytecode, and feed /that/ result into a proprietary compiler. Stallman's fear of the proprietary bogeyman has hamstrung GCC and Free toolchains from being a platform anywhere near as decent as other projects in providing realtime feedback into program design. [1] http://gcc.gnu.org/ml/gcc/2001-02/msg00895.html http://gcc.gnu.org/ml/gcc/2001-02/msg00895.html
- rayiner 12y agoThe most free world is not the one where there are the fewest restrictions. Restricting peoples' natural freedom to kill each other or steal from each other, for example, arguably makes everyone more free. The GPL is based on the same principle. Restricting certain antisocial behavior increases net freedom.
- hga 12y ago"natural freedom to kill each other" Although that's not a binary thing, I have the natural and legal right to kill in legitimate self-defense. In rare situations, stealing is allowed to prevent a greater loss. In this case, most of us, even those of us who don't like the GPL in practice like me, are not primarily arguing the GPL, but RMS's stewardship of GCC and GNU Emacs about something that's allowed in I believe every FOSS license. Just not in these two projects under the aegis of the FSF. Unless and until they fork, or RMS is somehow convinced, whic history says is not the way to bet.
- glenjamin 12y agoThe summary from this seems to be that RMS is against having a non-free tool consume the output of a free tool? Is that an accurate summary? If so this seems like a very strange position to take to me.
- anon1385 12y agoYou have to understand the perspective of the FSF. They view non-free software as fundamentally morally evil. In the same way that most people today view slavery as fundamentally wrong. The comparison to slavery is one RMS and the FSF often make themselves. To extend the analogy: if picking cotton was only economically viable if done with slave labour, then most people would agree we are better off not picking cotton at all. Similarly the FSF position is that if solving a problem using computers is only possible in a way that uses or enables non-free software, then we are better off not using computers to solve that problem at all.
- hga 12y agoIn his inimitable style, Theo de Raadt, extremely annoyed by a 2007 effort to GPL a driver that OpenBSD reverse engineered with much sweat, notes that RMS has been perfectly fine with GCC having code to run on, and built binaries for, closed platforms.... This GCC stuff is very much a shades of grey situation in practice.
- sesutton 12y agoIts hard for me to come up with a way in which this is not RMS advocating restricting the freedom of users of GCC. If he is so opposed to proprietary software using GCC output why not use a license that prohibits that? Its not even too late for new versions since the FSF owns the copyright to all GCC code.
- overgard 12y agoThat's the great irony of the copyleft movement -- it's about restricting what people can do under the guise of "freedom". RMS doesn't want people to "misuse" his software, but his version of misuse is "use it for a purpose that doesn't advance GNU." He's willing to cripple his software so that some theoretical entity that doesn't actually exist and does not agree with his politics can't misuse it. On a practical level, if people wanted to execute that particular "misuse" (IE use it in non-GPL software, which I would just call a "use"), they would obviously use clang. Clang is basically better at this point anyway. Basically what I'm trying to say is that RMS is a nutcase.
- MrBuddyCasino 12y agoYep, and its a classic RMS move. This happened before: http://www.jwz.org/doc/lemacs.html http://www.jwz.org/doc/lemacs.html
- nothrabannosir 12y agoIt is ironic, but not necessarily nuts. Another case of removing freedoms to promote freedom is much of criminal law. Why does the state restrict my freedom to kill people? When your freedom reduces the global "freedom", the sum of everyone's freedoms after your action, it might make sense to prevent it. In spite of, and because: freedom. Not saying the way RMS is doing it is good, that's a different matter. But restricting freedom, for freedom? Yes, very possible. RMS may be nuts, that doesn't stop him from being right. Which, by the way, he turns out to have been on many more counts than some of us initially thought.
- belorn 12y ago
- nemoniac 12y agoAccording to GNU, the second of the four essential freedoms is the right to study how the program works (among other things). One could argue that Stallman is not acting within the spirit of this right by being deliberately obstructive and obfuscatory.
- RandomCode 12y agoI trhe CIA really wanted to be evil, they would publish GCC shit so dumb fucks copy them.
- nanolith 12y agoTypically, it's not a good idea to argue with RMS. The pragmatic approach would be to just write the plugin for GCC, and keep it separate. GNU can certainly control what is mainlined, but the GPL is not violated simply by creating a GPL plugin that provides a useful output target. If Emacs were enhanced to support a standardized file format which contains the relevant information, then it could accept this format from any tool. The GCC plugin could output this format, as could Clang/LLVM. Because the format is universal, it likely would be mainlined. Then, it's up to the user. If the user wants to integrate the two, the user can apply the appropriate patch to GCC to incorporate this independent plugin. Likely, many downstream package maintainers would add this as a standard option if demand were high enough. This is the very freedom that RMS has advocated for. It can be done without poking the bear.
- hga 12y agoYou're ignoring that a lot more work needs to be done in GNU Emacs, and that's another program under RMS's stewardship, and one where he could be much more obstructive. The only outstanding threat to fork that I know of is coming from a GNU Emacs maintainer, to I believe fork GNU Emacs. Again. Oh boy, again to support C++ development! How could I have forgotten that?!?!?!!! But you're right, arguing with RMS on this is likely to be completely unproductive. But it is morally necessary before potentially disastrous forking of GNU Emacs and maybe GCC.
- nanolith 12y agoActually, I didn't ignore that in my original comment. I mentioned that the GNU Emacs work should make use of a file format which is independent of the plugin work. There is no reason why GNU would refuse to mainline such an enhancement if it had merits outside of the GCC dependency. RMS wishes to restrict possible proprietary use of the GCC front-end. That's his prerogative. However, he can't prevent the existence of such a tool. He can only prevent it from being mainlined. EDIT: Also, it may be easier to make a case for mainlining if the functionality is demonstrable. As I've learned throughout my career, it's often better to ask forgiveness than to ask permission. RMS excels in the idealistic and theoretical. If he has to consider the practical -- such as whether to mainline already existing functionality -- then he may find ways of suggesting changes to the plugin than ways of saying "no."
- politician 12y agoStallman appears to make himself out to be a Capitalist with positions like this -- he simply takes profits in the furtherance of his cause rather than in dollars, and uses procedural controls like the GPL rather than technological controls like obfuscated binaries to do so. That said, personally, I think the GPL has both helped and harmed the evolution of computing.
- nitrogen 12y agoThe entire point of Copyleft was to exploit copyright against itself.
- gre 12y agoCode terrorism at its worst.