mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Difference between -O2 and -g
Date: Thu, 25 Oct 2012 21:40:22 -0400	[thread overview]
Message-ID: <20121026014022.GT254@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAPW=hRT3tDr8BTqhJG=rgcc3KR5gLj+N1_xsAhryWsNrH6GpYg@mail.gmail.com>

On Fri, Oct 26, 2012 at 09:31:56AM +0800, Brian Wang wrote:
> Hello all,
> 
> I am experiencing a rather strange problem...
> 
> I have an oldish kdrive/Xfbdev that works on my ARM device with
> CodeSourcery toolchains.
> Now, I tried it with musl (0.9.6 and the recent git master branch as well).
> First it failed to find the screen and refused to start.  After some naive
> attempts with printf without success, I recompiled it with -g and no
> -Ox with the hope that gdbserver
> would help pin point the problem.  However, with only -g, it runs!

-g should have absolutely no effect on code behavior, but it sounds
like your two setups are "-O2" and "-O0 -g" (where the -O0 is the
default). If that's the case, when code behaves differently with
different optimization levels, the cause is almost surely undefined
behavior. Another possibility is a bug in musl (possibly an
ARM-specific bug), but if you didn't recompile musl with different
options, I doubt that's the cause.

One very simple way to get a picture of what's going on in a program
is to run it under strace. Try saving strace logs for both the working
version and the broken version and comparing them either manually or
with the diff utility (although the latter may be difficult unless you
filter out the addresses and other contnets that will naturally
differ, so it might be easier to visually inspect). If you don't
already have an strace built for your target, I think Aboriginal Linux
has static binaries you can use.

If you're having trouble analyzing the results I'd be happy to help
you.

Rich


  reply	other threads:[~2012-10-26  1:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26  1:31 Brian Wang
2012-10-26  1:40 ` Rich Felker [this message]
2012-10-26  2:04   ` Brian Wang
2012-10-26  2:21     ` Brian Wang
2012-10-26  2:32     ` Rich Felker
2012-10-26  2:47       ` Brian Wang
2012-10-26  2:55         ` Rich Felker
2012-10-26  3:01           ` Brian Wang
2012-10-26  3:19             ` Rich Felker
2012-10-26  6:44               ` Brian Wang
2012-10-26 17:58                 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121026014022.GT254@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).