Skip to main content

mr1 CDC cross compiling uClibc question

8 replies [Last post]
lamsap
Offline
Joined: 2004-11-09
Points: 0

Anyone experienced with building an i686/uClibc version of cvm?

The makefile seems designed for use only with GCC. When I define cc,as,ld,etc... to my uClibc toolchain, cc works fine, but as and ld have problems.

as ../../build/linux-x86-generic/./obj/invokeNative_i386.o
/root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-uclibc-as: unrecognized option `-_ASM'
make: *** [../../build/linux-x86-generic/./obj/invokeNative_i386.o] Error 1

The full command that the makefile is calling is:

/root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-uclibc-as -fno-common -D_ASM -DCVM_OPTIMIZED -DCVM_DEBUG_STACKTRACES -DNDEBUG -DCVM_CLASSLOADING -DCVM_SERIALIZATION -DCVM_REFLECT -DCVM_DYNAMIC_LINKING -DCVM_TIMESTAMPING -DJ2ME_CLASSLIB=cdc -DTARGET_CPU_FAMILY=x86 -D_GNU_SOURCE -I../../src/share -I../../build/linux-x86-generic/. -I../../src/share/javavm/export -I../../src/share/native/common -I../../src/share/native/java/lang -I../../src/share/native/java/lang/fdlibm/include -I../../src/share/native/java/net -I../../src/share/native/java/io -I../../src/share/native/java/util/zip -I../../src/share/native/java/util/zip/zlib-1.1.3 -I../../build/linux-x86-generic/./generated/jni -I../../src/x86 -I../../src -I../../src/linux -I../../src/linux/native/java/net -I../../src/linux/native/common -I../../src/linux-x86 -o ../../build/linux-x86-generic/./obj/invokeNative_i386.o ../../src/x86/javavm/runtime/invokeNative_i386.S

If I remove the -D_ASM flag, it them complains about all the -DCVM_* flags. If I remove all these flags, then the assembler just outright fails:

../../src/x86/javavm/runtime/invokeNative_i386.S: Assembler messages:
../../src/x86/javavm/runtime/invokeNative_i386.S:2: Error: junk at end of line, first unrecognized character is `*'
../../src/x86/javavm/runtime/invokeNative_i386.S:3: Error: junk at end of line, first unrecognized character is `*'
../../src/x86/javavm/runtime/invokeNative_i386.S:4: Error: junk at end of line, first unrecognized character is `*'
../../src/x86/javavm/runtime/invokeNative_i386.S:5: Error: junk at end of line, first unrecognized character is `*'
../../src/x86/javavm/runtime/invokeNative_i386.S:6: Error: junk at end of line, first unrecognized character is `*'
../../src/x86/javavm/runtime/invokeNative_i386.S:6: Error: no such instruction: `you can redistribute it and/or modify'
../../src/x86/javavm/runtime/invokeNative_i386.S:7: Error: junk at end of line, first unrecognized character is `*'
../../src/x86/javavm/runtime/invokeNative_i386.S:8: Error: junk at end of line, first unrecognized character is `*'
../../src/x86/javavm/runtime/invokeNative_i386.S:9: Error: junk at end of line, first unrecognized character is `*'
../../src/x86/javavm/runtime/invokeNative_i386.S:10: Error: junk at end of line, first unrecognized character is `*'
../../src/x86/javavm/runtime/invokeNative_i386.S:11: Error: junk at end of line, first unrecognized character is `*'
../../src/x86/javavm/runtime/invokeNative_i386.S:11: Error: no such instruction: `without even the implied warranty of MERCHANTABILITY'
etc...
../../src/x86/javavm/runtime/invokeNative_i386.S:26: Error: no such instruction: `include "javavm/include/asmmacros_cpu.h"
etc...

The gcc compiler handles this fine. I'm afraid I'm not a gcc/cc expert, so any help would be much appreciated.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jiangli_zhou
Offline
Joined: 2006-10-16
Points: 0

Try running 'cpp' to preprocess invokeNative_i396.S first. Then run 'as' tool against the cpp output. That might help.

Jiangli Zhou

lamsap
Offline
Joined: 2004-11-09
Points: 0

I realised I had made some changes to defs.mk to remove a compile flag error that I shouldn't have.

I've extracted a fresh copy of the source, with the only changes to the linux-i686-generic/GNUmakefile being:

TARGET_CC = /root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-cc
TARGET_AS = /root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-cc
TARGET_LD = /root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-cc
TARGET_AR = /root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-cc
TARGET_RANLIB = /root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-cc
JDK_HOME = /usr/java/j2sdk1.4.2_13
JAVA_HOME = /usr/java/j2sdk1.4.2_13

Results as follows:

make
...
cc ../../build/linux-x86-generic/./obj/PlainDatagramSocketImpl_md.o
cc ../../build/linux-x86-generic/./obj/net_util_md.o
cc ../../build/linux-x86-generic/./obj/executejava_standard.o
as ../../build/linux-x86-generic/./obj/invokeNative_i386.o
as ../../build/linux-x86-generic/./obj/x86_double_divmul.o
cc romjavaAux.o
make[1]: Entering directory `/root/phoneme/t3/phoneme-advanced-mr1/build/linux-x86-generic'
touch ../../build/linux-x86-generic/./generated/empty.mk
make[1]: Leaving directory `/root/phoneme/t3/phoneme-advanced-mr1/build/linux-x86-generic'
make[1]: Entering directory `/root/phoneme/t3/phoneme-advanced-mr1/build/linux-x86-generic'
cc ../../build/linux-x86-generic/./obj/romjavaAux.o
make[1]: Leaving directory `/root/phoneme/t3/phoneme-advanced-mr1/build/linux-x86-generic'
cc romjava0.o
make[1]: Entering directory `/root/phoneme/t3/phoneme-advanced-mr1/build/linux-x86-generic'
cc ../../build/linux-x86-generic/./obj/romjava0.o
make[1]: Leaving directory `/root/phoneme/t3/phoneme-advanced-mr1/build/linux-x86-generic'
cc romjava1.o
make[1]: Entering directory `/root/phoneme/t3/phoneme-advanced-mr1/build/linux-x86-generic'
cc ../../build/linux-x86-generic/./obj/romjava1.o
make[1]: Leaving directory `/root/phoneme/t3/phoneme-advanced-mr1/build/linux-x86-generic'
Linking ../../build/linux-x86-generic/./obj/libromjava.a
/root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-cc rc ../../build/linux-x86-generic/./obj/libromjava.a ../../build/linux-x86-generic/./obj/romjavaAux.o ../../build/linux-x86-generic/./obj/romjava0.o ../../build/linux-x86-generic/./obj/romjava1.o
i686-linux-cc: rc: No such file or directory
i686-linux-cc: ../../build/linux-x86-generic/./obj/libromjava.a: No such file or directory
make: *** [../../build/linux-x86-generic/./obj/libromjava.a] Error 1

cjplummer
Offline
Joined: 2006-10-16
Points: 0

Why are you setting TARGET_AR and TARGET_RANLIB to i686-linux-cc? They should be set to ar and ranlib tools.

lamsap
Offline
Joined: 2004-11-09
Points: 0

Initially I set them to the -ar and -ranlib equivs, but these gave me errors about invalid flags (-c, -D_ASM, -DCVM_OPTIMIZED, etc...). I found that the normal /usr/bin/as also complained about these flags, and that the original Makefile was actually invoking gcc for as. So using that as a guide, I tried specifying i686-linux-cc as my as and ranlib... it seems to work as it gets me further than before.

But now I'm stuck with a problem with a missing 'rc'.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

> Initially I set them to the -ar and -ranlib equivs,
> but these gave me errors about invalid flags (-c,
> -D_ASM, -DCVM_OPTIMIZED, etc...). I found that the
> normal /usr/bin/as also complained about these flags,
I think you are mistaken. These flags are not passed to the ar and ranlib tools.

> and that the original Makefile was actually invoking
> gcc for as.
This I believe. By default we use gcc as the front end for the assembler because it needs to go through the C preprocesser. For this reason, setting TARGET_AS to "as" won't work. It's best to just leave TARGET_AS and TARGET_LD unset, and by default they will be set to whatever TARGET_CC is set to.

> So using that as a guide, I tried
> specifying i686-linux-cc as my as and ranlib... it
> seems to work as it gets me further than before.
>
What got you further is setting TARGET_AS and TARGET_LD properly, but in the process you broke TARGET_AR and TARGET_RANLIB. You just need to point these to the ar and ranlib tools and you should be fine.

> But now I'm stuck with a problem with a missing 'rc'.

Chris

lamsap
Offline
Joined: 2004-11-09
Points: 0

Ah, this is starting to make sense. Thanks!

I now have a different (unrelated) error:

TARGET_CC = /root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-cc
#TARGET_AS = /root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-cc
#TARGET_LD = /root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-cc
TARGET_AR = /root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-ar
TARGET_RANLIB = /root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-ranlib

make gives....

cc ../../build/linux-x86-generic/./obj/w_sqrt.o
lib ../../build/linux-x86-generic/./obj/fdlibm.a
Linking ../../build/linux-x86-generic/./bin/cvm
../../build/linux-x86-generic/./obj/UNIXProcess_md.o: In function `Java_java_lang_UNIXProcess_forkAndExec':
UNIXProcess_md.c:(.text+0x68a): undefined reference to `_environ'
UNIXProcess_md.c:(.text+0x68f): undefined reference to `_environ'
collect2: ld returned 1 exit status
make: *** [../../build/linux-x86-generic/./bin/cvm] Error 1

I fix the offending lines in UNIXProcess_md.c and it compiles.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

> Ah, this is starting to make sense. Thanks!
>
> I now have a different (unrelated) error:
>
> TARGET_CC =
> /root/builtool/buildroot/build_i686/staging_dir/bin/i6
> 86-linux-cc
> #TARGET_AS =
> /root/builtool/buildroot/build_i686/staging_dir/bin/i6
> 86-linux-cc
> #TARGET_LD =
> /root/builtool/buildroot/build_i686/staging_dir/bin/i6
> 86-linux-cc
> TARGET_AR =
> /root/builtool/buildroot/build_i686/staging_dir/bin/i6
> 86-linux-ar
> TARGET_RANLIB =
> /root/builtool/buildroot/build_i686/staging_dir/bin/i6
> 86-linux-ranlib
>
> make gives....
>
> cc ../../build/linux-x86-generic/./obj/w_sqrt.o
> lib ../../build/linux-x86-generic/./obj/fdlibm.a
> Linking ../../build/linux-x86-generic/./bin/cvm
> ../../build/linux-x86-generic/./obj/UNIXProcess_md.o:
> In function
> `Java_java_lang_UNIXProcess_forkAndExec':
> UNIXProcess_md.c:(.text+0x68a): undefined reference
> to `_environ'
> UNIXProcess_md.c:(.text+0x68f): undefined reference
> to `_environ'
> collect2: ld returned 1 exit status
> make: *** [../../build/linux-x86-generic/./bin/cvm]
> Error 1
>
> I fix the offending lines in UNIXProcess_md.c and it
> compiles.

This is a known problem that is fixed in MR2. In cdc/src/linux/native/java/lang/UNIXProcess_md.c, remove the '_' from the references to _environ

extern char **environ;
environ = envv;

Chris

lamsap
Offline
Joined: 2004-11-09
Points: 0

Update:

When I change the TARGET_AS to point to the CC, not the AS, I get a different error

TARGET_AS = /root/builtool/buildroot/build_i686/staging_dir/bin/i686-linux-cc
make
... normal stuff ...
cc ../../build/linux-x86-generic/./obj/PlainDatagramSocketImpl_md.o
cc ../../build/linux-x86-generic/./obj/net_util_md.o
cc ../../build/linux-x86-generic/./obj/executejava_standard.o
as ../../build/linux-x86-generic/./obj/invokeNative_i386.o
/root/builtool/buildroot/build_i686/staging_dir/lib/gcc/i686-linux-uclibc/3.4.6/../../../../i686-linux-uclibc/lib/crt1.o: In function `_start':
libc/sysdeps/linux/i386/crt1.S:(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [../../build/linux-x86-generic/./obj/invokeNative_i386.o] Error 1