NB: Problem is solved. Look here.
Hi there!
When I’m trying to build some RePhone project from source (using Makefile from LinkIt SDK, as I understand situation), I experiencing some issues:
First of all, original MTK LinkIt SDK is only for windows. So, users on another platforms going to make SDK themselves.
So, I installed arm-none-eabi toolchain (actually, built it with “crossdev” tool, since I’m using Gentoo), which by default comes with “newlib” libc (because of “none eabi”) or without any libc at all.
If I trying to run make with toolchain, built without any libc at all, I’m getting error that stdio.h is not found.
If I run make on toolchain with libc (newlib) — I’m getting following build failure:
arm-none-eabi-gcc -mcpu=arm7tdmi-s -mthumb -mlittle-endian -O2 -Wl,--gc-sections --specs=nosys.specs -fpic -pie -Wl,-Map=lua.map -Wl,--entry=gcc_entry -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-unresolved-symbols -Tlinkit/lib/LINKIT10/armgcc/scat.ld -Llinkit/lib -o lua.elf -Wl,--start-group src/main.o src/retarget.o src/shell.o src/lcd_sitronix_st7789s.o src/tp_goodix_gt9xx.o src/tp_i2c.o lua/lapi.o lua/lcode.o lua/ldebug.o lua/ldo.o lua/ldump.o lua/lfunc.o lua/lgc.o lua/llex.o lua/lmem.o lua/lobject.o lua/lopcodes.o lua/lparser.o lua/lstate.o lua/lstring.o lua/ltable.o lua/ltm.o lua/lundump.o lua/lvm.o lua/lzio.o lua/lrotable.o lua/lauxlib.o lua/lbaselib.o lua/ldblib.o lua/liolib.o lua/lmathlib.o lua/loslib.o lua/ltablib.o lua/lstrlib.o lua/loadlib.o lua/linit.o lua/print.o lua/linenoise.o bindings/audio.o bindings/gsm.o bindings/gpio.o bindings/i2c.o bindings/timer.o bindings/tcp.o bindings/screen.o bindings/https.o bindings/bluetooth.o linkit/lib/LINKIT10/src/gccmain.o linkit/lib/LINKIT10/armgcc/percommon.a -lm -Wl,--end-group
/usr/lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_lseek':
/var/tmp/portage/cross-arm-none-eabi/newlib-2.3.0.20160104/work/newlib-2.3.0.20160104/newlib/libc/sys/arm/syscalls.c:282: multiple definition of `_lseek'
linkit/lib/LINKIT10/src/gccmain.o:gccmain.c:(.text+0x16c): first defined here
/usr/lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_open':
/var/tmp/portage/cross-arm-none-eabi/newlib-2.3.0.20160104/work/newlib-2.3.0.20160104/newlib/libc/sys/arm/syscalls.c:391: multiple definition of `_open'
linkit/lib/LINKIT10/src/gccmain.o:gccmain.c:(.text+0xcc): first defined here
/usr/lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_close':
/var/tmp/portage/cross-arm-none-eabi/newlib-2.3.0.20160104/work/newlib-2.3.0.20160104/newlib/libc/sys/arm/syscalls.c:413: multiple definition of `_close'
linkit/lib/LINKIT10/src/gccmain.o:gccmain.c:(.text+0x120): first defined here
/usr/lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_kill':
/var/tmp/portage/cross-arm-none-eabi/newlib-2.3.0.20160104/work/newlib-2.3.0.20160104/newlib/libc/sys/arm/syscalls.c:419: multiple definition of `_kill'
linkit/lib/LINKIT10/src/gccmain.o:gccmain.c:(.text+0x200): first defined here
/usr/lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_exit':
/var/tmp/portage/cross-arm-none-eabi/newlib-2.3.0.20160104/work/newlib-2.3.0.20160104/newlib/libc/sys/arm/syscalls.c:438: multiple definition of `_exit'
linkit/lib/LINKIT10/src/gccmain.o:gccmain.c:(.text+0x1fc): first defined here
/usr/lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_getpid':
/var/tmp/portage/cross-arm-none-eabi/newlib-2.3.0.20160104/work/newlib-2.3.0.20160104/newlib/libc/sys/arm/syscalls.c:452: multiple definition of `_getpid'
linkit/lib/LINKIT10/src/gccmain.o:gccmain.c:(.text+0x204): first defined here
/usr/lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_fstat':
/var/tmp/portage/cross-arm-none-eabi/newlib-2.3.0.20160104/work/newlib-2.3.0.20160104/newlib/libc/sys/arm/syscalls.c:491: multiple definition of `_fstat'
linkit/lib/LINKIT10/src/gccmain.o:gccmain.c:(.text+0x130): first defined here
/usr/lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/lib/thumb/libc.a(lib_a-syscalls.o): In function `_isatty':
/var/tmp/portage/cross-arm-none-eabi/newlib-2.3.0.20160104/work/newlib-2.3.0.20160104/newlib/libc/sys/arm/syscalls.c:595: multiple definition of `_isatty'
linkit/lib/LINKIT10/src/gccmain.o:gccmain.c:(.text+0x15c): first defined here
collect2: error: ld returned 1 exit status
Makefile:66: recipe for target 'lua.elf' failed
make: *** [lua.elf] Error 1
I even tried to comment out inclusion of linkit/src/gccmain.o in Makefile, but got a warning about missed gcc_entry.
And, looking at the code in gccmain.c, it defines functions, which exists in newlib’s syscalls.c in a bit another way (maybe, more related to RePhone or MTK?)
So, I don’t know what to do now, to fix the build (except marking all mentioned definitions with a attribute ((weak)), which, I think, anyway will made compiler to prefer newlib’s implementations, and not linkit’s, which maybe bad idea…
Any ideas? Maybe, there should be used some another libc?