Live data from Hacker News

Android NDK: GCC is now deprecated, everyone should be switching to Clang

android.googlesource.com

121–130 of 259 posts

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#121
post #55
post #12

Earlier quoted context omitted.

As someone messing with LLVM a lot.. basically LLVM is where a ton of development effort is going. GCC is a dead end it seems like. LLVM is designed to be extended where as GCC.. well, usually doesn't really seem to have been designed.

GCC has been designed specifically NOT to be extended. Richard Stallman reasoned that by exposing an interface to other applications, or allowing other applications to access or modify intermediate code/trees, closed source proprietary applications could be built around GCC. He was probably right ... but we all ended up with a worse compiler.

"GCC has been designed specifically NOT to be extended."

Several extension mechanisms have been built out in the last few years, including plugins for intermediate passes of compilation, and a library to operate as a JIT.

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#122

I'm not sure if this will stoke a flamewar, because I've never seen a discussion here on this (might just be hanging around different articles). Is there any technical reason to prefer clang over gcc other than ideological reasons? I get the modular nature of llvm is useful, but is the android NDK using this feature? Quick google search shows clang lagging gcc in all but one test[0] at least on Intel Broadwell. Again…

Better security features for one. Clang supports SafeStack and Control Flow Integrity. SafeStack is much more performant than gcc's stack protectors, and gcc offers no equivalent of CFI.

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#123
post #91

Earlier quoted context omitted.

> C already has rock-solid string formatting options Don't troll.

Do you have an actual response? How is iostream any better than *printf? At least you can read the format of the former without needing to google un-googleable operators.

> How is iostream any better than *printf?

Type checking.

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#124
post #91

Earlier quoted context omitted.

> C already has rock-solid string formatting options Don't troll.

Do you have an actual response? How is iostream any better than *printf? At least you can read the format of the former without needing to google un-googleable operators.

> How is iostream any better than []printf?

What consistent mechanism do you use to printf an instance of an arbitrary user-defined type?

With ostream, you implement

  ostream& operator
and you're done.

with printf, you have to have a convention and remember to stick to it. (Do I call .toString(), .stringize(), .getString()... ??)

For one-off things, printf is great. You take it from me when you pry it from my goddamn cold, dead, hands. However, for real work io*stream are rather nice.

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#125
post #48
post #10

Earlier quoted context omitted.

I'm curious, what's wrong with iostream?

How do you internationalize strings built up from multiple string fragments?

Am I being downvoted for asking an honest question?

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#126

I'm not sure if this will stoke a flamewar, because I've never seen a discussion here on this (might just be hanging around different articles). Is there any technical reason to prefer clang over gcc other than ideological reasons? I get the modular nature of llvm is useful, but is the android NDK using this feature? Quick google search shows clang lagging gcc in all but one test[0] at least on Intel Broadwell. Again…

I don't know much about Android NDK, but in general, people use clang because: - Clear and readable diagnostics -- especially useful when debugging nasty C++ template stuff where the type signature is a page long. (GCC is catching up in this area) - Modular design -- if an IDE wants to have syntax highlighting or an Xcode/Eclipse/IntelliJ like "fix it" feature, they can use the clang frontend to parse the code. Also,…

FWIW, GCC has ASan too. [0] I'm not sure how it compares to the LLVM implementation, I've only tried LLVM's (with good results).

Having said that, I hack on LLVM daily and would not relish having to use GCC to the same effect. LLVM really does shine when used as a library!

[0]: https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#127

Earlier quoted context omitted.

Compiler bugs are usually limited to a single compilation unit and are usually submitted by doing a binary search on a pre processed source file. This is certainly true for closed source as well - just redact the (few) symbol names and create something that will compile to an a.out that demonstrates the problem. God saves a puppy anytime someone filed a compiler bug with a trivial test case that demonstrates the prob…

> God saves a puppy anytime someone filed a compiler bug with a trivial test case that demonstrates the problem. The current (r10e) shipping version of clang cannot return 128bit floats from a function. #include int main(int c, char **v) { std::stringstream("1.5"); double x; s >> x; return x == 1.5 ? 0 : 1; } EDIT: You don't need "long double" in the above. double (or float) will show the problem. The standard librar…

What is 'long double' on non-X86 (non-PPC?)? On X86, I know it is an 80-bit X87 float.

I wonder if the bug you are seeing is a result of the C++ STL and not the compiler itself. Can you try reproing with libc++?

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#128

Earlier quoted context omitted.

It's a somewhat artificial distinction, since the user of a piece of software becomes a developer to modify it. And to preclude modifications which prevent him from effectively monetizing his labour is to infringe on his freedom. Prehaps it would not be if money (etc.) didnt exist. It's always the way, however, with idealists to prescribe policies that make people free in their utopia but cause chaos in our reality.

> And to preclude modifications which prevent him from effectively monetizing his labour is to infringe on his freedom. This sounds a lot like the people saying that adblocker software is infringing the freedom of people trying to monetize their websites (or maybe even "stealing" from them). And I think the same response applies: the fact that your business model isn't compatible with adblocker software, or with my c…

It's just an observation about which licence maximises the freedom of the user.

Since we're in a capitalist system, monetization of one's labour is hugely important from real-term freedom. To deny people that is to make them less free.

So the most permissive licence is the one providing the most freedom.

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#129

Earlier quoted context omitted.

RMS is an idealist. If people actually made what he proposed (envisioned), world would be much better place. It is hard to see the entire impact of Free software and even harder to predict how the world would like if people actually stood up to it but I can say that I am sure we would have: - more secure Internet - more decentralized/distributed Internet - no ISP blocks - much harder if not even impossible NSA spying…

You listed a bunch of things without substantiating. For example, how would free software prevent the NSA from spying? Internet backbone taps don't care if your HTTP implementation is running under Windows or Linux...

Not all answer need to be pure technical ones - they don't go and search person by person via manpower but they use meta data and algorithms. Simple overflowing their meta data would force them to use other means. Also you forget social impact - if majority of people actually listened to RMS that means majority of people would be very privacy and security minded and would press the government to change the laws (NSA spying is illegal anyway but with majority of folks actually actively pursuing this would made their existence hard or at least not possible to just go and spy and ruing privacy of entire planet).

Re: Android NDK: GCC is now deprecated, everyone should be switching to Clang

#130
post #91

Earlier quoted context omitted.

Do you have an actual response? How is iostream any better than *printf? At least you can read the format of the former without needing to google un-googleable operators.

> How is iostream any better than *printf? Type checking.

You already have to do odd casting to get around compiler warnings when passing invalid types to a format—I don't buy this anymore.
Post reply on HN