<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>cocos2d for iPhone &#187; Topic: LLVM vs. GCC</title>
		<link>http://www.cocos2d-iphone.org/forum/topic/7923</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 01:32:14 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.cocos2d-iphone.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.cocos2d-iphone.org/forum/rss/topic/7923" rel="self" type="application/rss+xml" />

		<item>
			<title>slembcke on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-123139</link>
			<pubDate>Wed, 26 Oct 2011 16:08:52 +0000</pubDate>
			<dc:creator>slembcke</dc:creator>
			<guid isPermaLink="false">123139@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Compiler bugs where the compiler generates bad code are definitely real (I've found two), but are very rare (I've found two <em>ever</em>). </p>
<p>95% of the time when I've had a bug that only shows up with specific build settings, it's because I used an uninitialized variable. Something like this:<br />
<pre><code>int myVariable;

if(a &#60; b){
  myVariable = 6;
} else if(a &#60; c){
  myVariable = 12;
}</code></pre>
<p>If a is greater than both b and c, myVariable will just have whatever old leftover value happened to be sitting in the register or stack location given to myVariable. It might be 0, it might be -12000, and it's almost guaranteed to change based on compiler settings as that causes registers to get used for different things. It's harder to notice this happening when myVariable is a float as half of the random sets of bits when used as a floating point number will be between 1 and -1. When this happens to pointers it can cause other confusing bugs.</p>
<p>As CJ said, turn on more warnings and also run the static analyzer. They might be able to find your bug for you.</p>
<p>Also, after years of inflicting bugs on myself caused by this. I decided never ever declare a variable without defining it!  There isn't a good reason to do it unless you are supporting 20 year old compilers.
</p></description>
		</item>
		<item>
			<title>CJ on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-123133</link>
			<pubDate>Wed, 26 Oct 2011 15:20:44 +0000</pubDate>
			<dc:creator>CJ</dc:creator>
			<guid isPermaLink="false">123133@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I would start by turning on more compiler warning options and then build with llvm. See what sort of warnings it gives you.
</p></description>
		</item>
		<item>
			<title>luridmorn on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-123127</link>
			<pubDate>Wed, 26 Oct 2011 15:00:53 +0000</pubDate>
			<dc:creator>luridmorn</dc:creator>
			<guid isPermaLink="false">123127@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>old thread but... </p>
<p><strong>is it possible that xcode 4.2 default compiler llvm 3.0 behaves differently compiling cocos2d than gcc 4.2?</strong></p>
<p>i am having a strange issue (missing batchnodes and cclabelbmfont) with my app on an old ipod touch 2g (ios 4.2.1) compiled with llvm. but using gcc... all is well. to make it worse... the issue is not appearing on my ipod touch g4 and ipad (both ios5) even when compiling with llvm. the issue also only appears in release not debug build!</p>
<p>@riq: any tips for tracking a bug like that? i hoped its withing my code not cocos2d but since it does work on ipod4/ipad i am not so sure anymore.
</p></description>
		</item>
		<item>
			<title>sigsegv on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-47426</link>
			<pubDate>Fri, 23 Jul 2010 10:02:31 +0000</pubDate>
			<dc:creator>sigsegv</dc:creator>
			<guid isPermaLink="false">47426@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>FWIW, I'm getting a nasty EXC_BAC_ACCESS on line 518 of CCSprite where glBlendFunc is called when LLVM 2.0 is selected. Device is an iPhone 3G with iOS4. It works fine on simulator and on 3GS, or using LLVM GCC 4.2.
</p></description>
		</item>
		<item>
			<title>edge17 on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-47173</link>
			<pubDate>Wed, 21 Jul 2010 20:11:59 +0000</pubDate>
			<dc:creator>edge17</dc:creator>
			<guid isPermaLink="false">47173@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I've heard much the same. There was a issue involving iOS4 frame rate dropping related to multitasking (issue #910?).. I was suggest to try compiling with LLVM rather than GCC by a friend. I haven't had the chance to try yet, but I'm going to look into it over the weekend.
</p></description>
		</item>
		<item>
			<title>Robert Payne on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46894</link>
			<pubDate>Tue, 20 Jul 2010 05:23:38 +0000</pubDate>
			<dc:creator>Robert Payne</dc:creator>
			<guid isPermaLink="false">46894@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Apple is moving in the direction of LLVM. I've used it consistently on the Zwoptex Desktop project as well as some iPad applications without any issues at all granted I was not using cocos2d and coded from the beginning with LLVM.</p>
<p>I find that it's faster, more verbose in warnings &#38; errors and generally just better all around.</p>
<p>With XCode 4 and LLDB I doubt I'll ever even touch GCC or GDB again.
</p></description>
		</item>
		<item>
			<title>marcotronic on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46893</link>
			<pubDate>Tue, 20 Jul 2010 05:15:31 +0000</pubDate>
			<dc:creator>marcotronic</dc:creator>
			<guid isPermaLink="false">46893@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thanks a lot for your investigation. What does that mean now for the particle issue?</p>
<p>Thanks,<br />
Marco
</p></description>
		</item>
		<item>
			<title>riq on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46865</link>
			<pubDate>Mon, 19 Jul 2010 22:56:43 +0000</pubDate>
			<dc:creator>riq</dc:creator>
			<guid isPermaLink="false">46865@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/34'>crmagicxxx</a>: Yes, your code seems to work OK both with LLVM and GCC.
</p></description>
		</item>
		<item>
			<title>crmagicxxx on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46864</link>
			<pubDate>Mon, 19 Jul 2010 22:45:21 +0000</pubDate>
			<dc:creator>crmagicxxx</dc:creator>
			<guid isPermaLink="false">46864@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@riq</p>
<p>Good you found it. I am getting things from dictionary like this:<br />
<pre><code>float x = [dictionary valueForKey:@&#34;some_key&#34;] ? [[dictionary valueForKey:@&#34;some_key&#34;] floatValue] : 0;</code></pre>
<p>So there is never a doubt about the value of 'x'
</p></description>
		</item>
		<item>
			<title>riq on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46863</link>
			<pubDate>Mon, 19 Jul 2010 22:38:42 +0000</pubDate>
			<dc:creator>riq</dc:creator>
			<guid isPermaLink="false">46863@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>It seems to be an LLVM bug:<br />
<a href="https://devforums.apple.com/message/260616" rel="nofollow">https://devforums.apple.com/message/260616</a>
</p></description>
		</item>
		<item>
			<title>riq on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46856</link>
			<pubDate>Mon, 19 Jul 2010 21:02:53 +0000</pubDate>
			<dc:creator>riq</dc:creator>
			<guid isPermaLink="false">46856@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I found it:</p>
<p>In LLVM 1.5 compiler<br />
<pre><code>// x ==  -nan if the key &#34;doesn&#39;t exist&#34; doesn&#39;t exist.
float x = [[dictionary valueForKey:@&#34;doesnt_exist&#34;] floatValue];</code></pre>
<p>In GCC 4.2 compiler<br />
<pre><code>// x ==  0 if the key &#34;doesn&#39;t exist&#34; doesn&#39;t exist.
float x = [[dictionary valueForKey:@&#34;doesnt_exist&#34;] floatValue];</code></pre></description>
		</item>
		<item>
			<title>CJ on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46685</link>
			<pubDate>Sun, 18 Jul 2010 10:05:04 +0000</pubDate>
			<dc:creator>CJ</dc:creator>
			<guid isPermaLink="false">46685@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/3137'>JonKean</a> does running the build with analyze produce information that would help you track this down?
</p></description>
		</item>
		<item>
			<title>JonKean on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46622</link>
			<pubDate>Sat, 17 Jul 2010 19:05:47 +0000</pubDate>
			<dc:creator>JonKean</dc:creator>
			<guid isPermaLink="false">46622@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>A developer at Apple (guy working on LLVM) highly suggested moving away from GCC immediately.  He says Apple is no longer fixing bugs in GCC, and in XCode 4 GCC-LLVM will be the default option.</p>
<p>I've noticed sometimes LLVM will not compile against really old libraries compiled with GCC (gives errors about built in runtime functions not found).  I can fix that by using GCC-LLVM (gcc parser, LLVM code generator).</p>
<p>A few days ago I noticed a bug in my code that only showed up when using LLVM (but not GCC).  I tracked it down to a non initialized local variable that was being read from, and GCC would always initialize to zero (even with O3 optimizations).  Since the variable value should be undefined, LLVM was giving the correct behavior of using whatever was in that memory already (even though it's clearly not the desired result).  I'd speculate something similar is going on with ParticleTests.</p>
<p>I did a quick test, and compiling Cocos2D with GCC-LLVM works correctly with issue 872.
</p></description>
		</item>
		<item>
			<title>crmagicxxx on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46612</link>
			<pubDate>Sat, 17 Jul 2010 16:51:55 +0000</pubDate>
			<dc:creator>crmagicxxx</dc:creator>
			<guid isPermaLink="false">46612@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@riq</p>
<p>Today I tried to update to latest develop version (2010-07-16 d73e47927a035927de59) and discovered 12 warnings/errors. I also have default compiler GCC 4.2. If I change to LLVM 1.5 those warning disappear. But I have a doubt if I should change compiler because I am afraid of possible incompatibility issues (like you stated for particles). So, can you please tell me what are the benefits/drawbacks of using LLVM 1.5 and should I really change GCC like you did in latest version?</p>
<p>Best
</p></description>
		</item>
		<item>
			<title>marcotronic on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46608</link>
			<pubDate>Sat, 17 Jul 2010 16:15:53 +0000</pubDate>
			<dc:creator>marcotronic</dc:creator>
			<guid isPermaLink="false">46608@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Sorry to ask, but I have never changed the default compiler settings. Do I <strong>have to</strong> use a special compiler for special projects or a special OS version or is it okay to just use that GCC compiler and be fine :-)</p>
<p>Thanks,<br />
Marco
</p></description>
		</item>
		<item>
			<title>jordo on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46283</link>
			<pubDate>Thu, 15 Jul 2010 02:55:52 +0000</pubDate>
			<dc:creator>jordo</dc:creator>
			<guid isPermaLink="false">46283@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>weird...
</p></description>
		</item>
		<item>
			<title>riq on "LLVM vs. GCC"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/7923#post-46282</link>
			<pubDate>Thu, 15 Jul 2010 02:50:20 +0000</pubDate>
			<dc:creator>riq</dc:creator>
			<guid isPermaLink="false">46282@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey,</p>
<p>Have you experienced any incompatibility between LLVM compiler and GCC compiler ?</p>
<p>I found one strange issue:<br />
If you compile ParticleTests with GCC and if you try sub-test "issue 872", it works as expected: a particle system will emit particles.<br />
But if you compile it with LLVM 1.5, you won't see any particle at all. I'm not sure what's the problem, but I'll investigate it a bit further.</p>
<p>I can only reproduce this bug on the simulator. It seems that this bug can't be reproduced on the devices.</p>
<p>I tested it both in Release &#38; Debug mode using Xcode 3.2.3.
</p></description>
		</item>

	</channel>
</rss>

