Brian Sweeney
Brian Sweeney

Reputation: 6793

cross compiling for android using NDK fails with compiler error

I'm compiling a nexus one android kernel from source as found on HTCs developer website. I've obtained an ARM tool chain by DLing the android NDK from the android dev site. I am able to run make clean and make defconfig without incident, but when I run make, it only gets so fare before running into compiler errors.

Currently i see the following:

$MY_DIR/nexus_one/arch/arm/include/asm/glue.h:156:29: error: '#' is not followed by a macro parameter

The offending line is:

1  /*
2  * Instruction Fault Status Register.  (New register as of ARMv6)
3  * If processor has IFSR then set value, else set translation fault
4  */
5 #if defined(CONFIG_CPU_ABRT_EV7) || defined(CONFIG_CPU_ABRT_EV6)
6 # define CPU_PABORT_IFSR(reg)    mrc p15, 0, reg, cr5, cr0, 1         @asm macro;
7 #else
8 # define CPU_PABORT_IFSR(reg)    mov reg, #5                          @asm macro;
9 #endif

Specifically, line 8 above is what hoses the compiler. Apparently you can't have that second # sign, but i'm not really sure whats going on in this code, and it looks pretty important so i don't want to touch it.

I'm guessing i'm compiling with the wrong tool chain maybe? Or perhaps i have configured things wrong somehow? Does any one have any idea what this is all about?

thanks, brian

Upvotes: 0

Views: 536

Answers (2)

Brian Sweeney
Brian Sweeney

Reputation: 6793

Turns out it was nothing to do with the specific toolchain. The # sign needed 'escaping' of some sort. The solution was as follows:

/* this is needed to get the mov reg, 5 macro to compile and function correctly */
#define hash_hackery #
#define f(x) x

#if defined(CONFIG_CPU_ABRT_EV7) || defined(CONFIG_CPU_ABRT_EV6)
# define CPU_PABORT_IFSR(reg)   mrc p15, 0, reg, cr5, cr0, 1         @asm macro;
#else
# define CPU_PABORT_IFSR(reg)   mov reg, f(hash_hackery)5            @asm macro;
#endif

This post was very informative in finding the answer.

Upvotes: 1

Kazuki Sakamoto
Kazuki Sakamoto

Reputation: 13999

I strongly recommend you to use CodeSourcery toolchain for Linux for compiling Linux kernel.

Upvotes: 1

Related Questions