public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Building gdb for Android using Android-ndk
@ 2013-01-23  9:29 Robert
  2013-01-23 13:40 ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Robert @ 2013-01-23  9:29 UTC (permalink / raw)
  To: gdb

Hi,

I am trying to build gdb for Android using the "standalone-toolchain"
created by the Android-NDK (make-standalone-toolchain.sh).

My configure call is as follows:

./configure  --target=arm-linux-androideabi  --host=arm-linux-androideabi

I tried different gdb versions - unfortunately earlier or later I ran
into an error I could not solve.

For example gdb 7.5 has only some minor problems where libraries like
libsim.a, libbfd.a and other required additional processing using
ranlib. I fixed this by manually executing ranlib on the specified
libraries and then restarted the make process.

But in the end the build process stops with the following error:

make[5]: Leaving directory `/tmp/gdb-7.5/gdb/gdbserver'
gcc -c -g -O2    -I. -I. -I./../common -I./../regformats
-I./../../include -I./../gnulib/import -Ibuild-gnulib-gdbserver/import
-Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral
-Wno-char-subscripts -Werror linux-arm-low.c
linux-arm-low.c: In function ‘arm_prepare_to_resume’:
linux-arm-low.c:714:9: error: cast to pointer from integer of different
size [-Werror=int-to-pointer-cast]
linux-arm-low.c:720:9: error: cast to pointer from integer of different
size [-Werror=int-to-pointer-cast]
linux-arm-low.c:734:9: error: cast to pointer from integer of different
size [-Werror=int-to-pointer-cast]
linux-arm-low.c:740:9: error: cast to pointer from integer of different
size [-Werror=int-to-pointer-cast]

BTW: Build environment is Ubuntu 12.04 (x86_64).

Robert

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Building gdb for Android using Android-ndk
  2013-01-23  9:29 Building gdb for Android using Android-ndk Robert
@ 2013-01-23 13:40 ` Pedro Alves
  2013-01-23 14:54   ` Robert
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2013-01-23 13:40 UTC (permalink / raw)
  To: Robert; +Cc: gdb

On 01/23/2013 09:29 AM, Robert wrote:
> I am trying to build gdb for Android using the "standalone-toolchain"
> created by the Android-NDK (make-standalone-toolchain.sh).
> 
> My configure call is as follows:
> 
> ./configure  --target=arm-linux-androideabi  --host=arm-linux-androideabi
> 
> I tried different gdb versions - unfortunately earlier or later I ran
> into an error I could not solve.

You're building a gdb that runs on Android?  Or you want a GDBserver
that runs on Android, but debug from your x86_64 Ubuntu host?
If the latter, drop the --host part when building GDB, as you
want GDB that runs on x86_64.  You'll then need to build GDBserver
as a separate step, for an Android host, so you'll use the --host
setting then.  See:
http://www.sourceware.org/autobook/autobook/autobook_259.html

> 
> For example gdb 7.5 has only some minor problems where libraries like
> libsim.a, libbfd.a and other required additional processing using
> ranlib. I fixed this by manually executing ranlib on the specified
> libraries and then restarted the make process.
> 
> But in the end the build process stops with the following error:
> 
> make[5]: Leaving directory `/tmp/gdb-7.5/gdb/gdbserver'
> gcc -c -g -O2    -I. -I. -I./../common -I./../regformats

So is "gcc" itself a native compiler running on Android?  If not,
then you should be seeing arm-linux-androideabi-gcc or some such here.

> -I./../../include -I./../gnulib/import -Ibuild-gnulib-gdbserver/import
> -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral
> -Wno-char-subscripts -Werror linux-arm-low.c
-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Building gdb for Android using Android-ndk
  2013-01-23 13:40 ` Pedro Alves
@ 2013-01-23 14:54   ` Robert
  2013-01-23 14:58     ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Robert @ 2013-01-23 14:54 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb

Hi Pedro,

thanks for your reply.

> You're building a gdb that runs on Android?  Or you want a GDBserver 
> that runs on Android, but debug from your x86_64 Ubuntu host?

I am trying to build a standalone version of gdb that runs directly on
the device. It is coincidence that the error just occurs in the
gdbserver subproject. I am not aware of the internal dependencies of gdb
- may be one can simply disable the gdbserver subproject?

> So is "gcc" itself a native compiler running on Android?  If not, 
> then you should be seeing arm-linux-androideabi-gcc or some such
> here.

You are right, this little strange detail did not catch my attention.
Looks like the configuration was not done correctly.

Therefore I deleted everything and started from scratch. Now the build
process looks correct, but stops much earlier with an error I have seen
several times before:

arm-linux-androideabi-gcc -c -DHAVE_CONFIG_H -g -O2  -I. -I./../include
 -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic
./getpagesize.c -o getpagesize.o
./getpagesize.c:64:1: error: redefinition of 'getpagesize'
/opt/android-standalone-toolchain/bin/../sysroot/usr/include/unistd.h:162:23:
note: previous definition of 'getpagesize' was here

I checked the log and noticed that the system checks that executed the
first time when I execute "make" contains several lines with
"checking for getpagesize... no".

I uploaded the complete make log here: http://pastebin.com/v3etd3Sa

Robert

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Building gdb for Android using Android-ndk
  2013-01-23 14:54   ` Robert
@ 2013-01-23 14:58     ` Pedro Alves
       [not found]       ` <35190382.post@talk.nabble.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2013-01-23 14:58 UTC (permalink / raw)
  To: Robert; +Cc: gdb

On 01/23/2013 02:28 PM, Robert wrote:
>> You're building a gdb that runs on Android?  Or you want a GDBserver
>> that runs on Android, but debug from your x86_64 Ubuntu host?
>
> I am trying to build a standalone version of gdb that runs directly on
> the device.

Ack.  I don't ever recall seeing patches to port the various
subprojects in gdb (bfd, libiberty, gdb itself, etc.), except
gdbserver, which always runs on the target, to
Android/bionic though.
You're likely to hit problems that would need porting work.

 It is coincidence that the error just occurs in the
> gdbserver subproject. I am not aware of the internal dependencies of gdb
> - may be one can simply disable the gdbserver subproject?

gdbserver should build for Android.  So the cross scenario we know works.

>
> arm-linux-androideabi-gcc -c -DHAVE_CONFIG_H -g -O2  -I. -I./../include
>  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic
> ./getpagesize.c -o getpagesize.o
> ./getpagesize.c:64:1: error: redefinition of 'getpagesize'
> /opt/android-standalone-toolchain/bin/../sysroot/usr/include/unistd.h:162:23:
> note: previous definition of 'getpagesize' was here
>
> I checked the log and noticed that the system checks that executed the
> first time when I execute "make" contains several lines with
> "checking for getpagesize... no".
>
> I uploaded the complete make log here: http://pastebin.com/v3etd3Sa

Right, so the build is failing while building libiberty (primarily a
host abstraction library).  I'm afraid it looks like someone needs to
step up and do some porting work.  Looks like you found an itch to
scratch.  ;-)

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Building gdb for Android using Android-ndk
       [not found]       ` <35190382.post@talk.nabble.com>
@ 2013-04-04  9:43         ` Pedro Alves
  0 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2013-04-04  9:43 UTC (permalink / raw)
  To: Bernd Späth; +Cc: gdb

On 03/18/2013 11:40 PM, Bernd Späth wrote:

> Stumbeling across a similar error that the one you reported in trying to
> compile a package depending on libiberty:
> 
> 'sysroot/usr/include/unistd.h:171:23: note: previous definition of
> 'getpagesize' was here'
> 
> I managed to track down the problem to the following issue:
> 
> sysroot/usr/include/unistd.h
> ---
> static __inline__ int getpagesize(void) {
>   extern unsigned int __page_size;
>   return __page_size;
> }
> 
> Unfortunately besides claiming AC_REPLACE_FUNC will (by by some kind of
> black magic, voodoo or whatever) just do the right thing. The autoconf
> manual doesn't give any clue on how this check will be done so hunting down
> the problem took me just a while.
> 
> As it turns out in determinig if a function is available the autoconf macro
> doesn't really give a damn thing about headers. Instead relying on
> prototypeless ANSI C fallback mode it just compiles a binary using a call to
> the tested func: <function-name>().
> Running the generated executable would sure crash if <function-name> was
> anything else but int <function-name> (void).
> This never happens as autoconf will never run the generated binary at all.
> The whole trick involved is to see if the linker is able to resolve the
> symbol <function-name> in generating the executable.
> 
> For the tricky getpagesize() implementation cited above this tricky method
> fails as it is just the symbol __page_size that gets exported by libc.
> As the coresponding header (unistd.h) in this case never gets included in
> the autoconf test the static function definition of getpagesize will be
> missing fooling the linker into thinking getpagesize would have to be
> resolved.
> 
> Finding the right spot to fix to elegantly fix the issue doesn't seem too
> easy. At least I wasn't clever enough to spot it.

FYI, libiberty is maintained by the gcc folks.  You may want to report this
there.  Any patch needs to go there first, and is then brought into gdb
via a merge.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-04  9:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-23  9:29 Building gdb for Android using Android-ndk Robert
2013-01-23 13:40 ` Pedro Alves
2013-01-23 14:54   ` Robert
2013-01-23 14:58     ` Pedro Alves
     [not found]       ` <35190382.post@talk.nabble.com>
2013-04-04  9:43         ` Pedro Alves

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 read-only IMAP folder(s) and NNTP newsgroup(s).