Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua port is built with the wrong architecture (x86) #59

Open
vaskas opened this issue Mar 31, 2021 · 5 comments
Open

Lua port is built with the wrong architecture (x86) #59

vaskas opened this issue Mar 31, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@vaskas
Copy link
Member

vaskas commented Mar 31, 2021

Apparently Lua is not cross-compiled:

photo_2021-04-01_09-52-23

@vaskas vaskas added the bug Something isn't working label Mar 31, 2021
@vaskas
Copy link
Member Author

vaskas commented Apr 1, 2021

This would be awesome to fix for the 0.5 release

@karawitan
Copy link
Collaborator

Hi Vaskas,

nice to see you back !
I've updated lua version and added the CC, AR, RANLIB variables to enable cross compile;

https://github.com/BerryFarm/berrymuch/tree/update-fix-crosscompile-lua

The compilation went running fine;
lapi.o: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped

But "ar" step fails like below ..


make[3]: Entering directory '/berrymuch/work/lua-5.4.3/src'
arm-unknown-nto-qnx8.0.0eabi-ar liblua.a lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o 
arm-unknown-nto-qnx8.0.0eabi-ar: invalid option -- '.'
Usage: arm-unknown-nto-qnx8.0.0eabi-ar [emulation options] [-]{dmpqrstx}[abcDfilMNoPsSTuvV] [member-name] [count] archive-file file...
       arm-unknown-nto-qnx8.0.0eabi-ar -M [<mri-script]
 commands:
  d            - delete file(s) from the archive
  m[ab]        - move file(s) in the archive
  p            - print file(s) found in the archive
  q[f]         - quick append file(s) to the archive
  r[ab][f][u]  - replace existing or insert new file(s) into the archive
  s            - act as ranlib
  t            - display contents of archive
  x[o]         - extract file(s) from the archive
 command specific modifiers:
  [a]          - put file(s) after [member-name]
  [b]          - put file(s) before [member-name] (same as [i])
  [D]          - use zero for timestamps and uids/gids
  [U]          - use actual timestamps and uids/gids (default)
  [N]          - use instance [count] of name
  [f]          - truncate inserted file names
  [P]          - use full path names when matching
  [o]          - preserve original dates
  [u]          - only replace files that are newer than current archive contents
 generic modifiers:
  [c]          - do not warn if the library had to be created
  [s]          - create an archive index (cf. ranlib)
  [S]          - do not build a symbol table
  [T]          - make a thin archive
  [v]          - be verbose
  [V]          - display the version number
  @<file>      - read options from <file>
  --target=BFDNAME - specify the target object format as BFDNAME
 emulation options: 
  No emulation specific options
arm-unknown-nto-qnx8.0.0eabi-ar: supported targets: elf32-littlearm elf32-bigarm elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex

Not sure how to fix this

@karawitan
Copy link
Collaborator

Ok gcc is calling "ar" with the following arguments:

676 execve("/root/bbndk/host_10_3_1_12/linux/x86/usr/bin/arm-unknown-nto-qnx8.0.0eabi-ar.orig", ["/root/bbndk/host_10_3_1_12/linux/x86/usr/bin/arm-unknown-nto-qnx8.0.0eabi-ar.orig", "liblua.a", "lapi.o", "lcode.o", "lctype.o", "ldebug.o", "ldo.o", "ldump.o", "lfunc.o", "lgc.o", "llex.o", "lmem.o", "lobject.o", "lopcodes.o", "lparser.o", "lstate.o", "lstring.o", "ltable.o", "ltm.o", "lundump.o", "lvm.o", "lzio.o", "lauxlib.o", "lbaselib.o", "lbitlib.o", "lcorolib.o", "ldblib.o", "liolib.o", "lmathlib.o", "loslib.o", "lstrlib.o", "ltablib.o", "loadlib.o", "linit.o"], [/* 21 vars */]) = 0

So we need to find a way to fix the gcc call to "ar"

Tried to update AR inside Makefile, without any success

@karawitan
Copy link
Collaborator

Ok we're very close to something ( see branch update-fix-lua )


karawitan@36e0b51f1ab9:~/work/lua-5.4.3$ find .  -name "*.o" | xargs file | tail  -2
./qnx/arm/a.le.v7/lfunc.o:    ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped
./qnx/arm/a.le.v7/lcode.o:    ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped

karawitan@36e0b51f1ab9:/berrymuch/work/lua-5.4.3/qnx/arm/a.le.v7# arm-unknown-nto-qnx8.0.0eabi-gcc -o lua *o *a -lm
+ arm-unknown-nto-qnx8.0.0eabi-gcc -o lua lapi.o lauxlib.o lbaselib.o lcode.o lcorolib.o lctype.o ldblib.o ldebug.o ldo.o ldump.o lfunc.o lgc.o linit.o liolib.o llex.o lmathlib.o lmem.o loadlib.o lobject.o lopcodes.o loslib.o lparser.o lstate.o lstring.o lstrlib.o ltable.o ltablib.o ltm.o lundump.o lvm.o lzio.o liblua.a -lm
loslib.o: In function `os_tmpname':
loslib.c:(.text+0x67c): warning: The 'tmpnam' function is dangerous. Use 'mkstemp' instead.
/root/bbndk/target_10_3_1_995/qnx6/armle-v7/lib/crt1S.o: In function `LPIC0':
(.text+0x9c): undefined reference to `main'
linit.o:(.data.rel.ro+0x44): undefined reference to `luaopen_utf8'
collect2: ld returned 1 exit status
root@36e0b51f1ab9:/berrymuch/work/lua-5.4.3/qnx/arm/a.le.v7# 

@vaskas
Copy link
Member Author

vaskas commented Apr 7, 2021

@karawitan luaopen_utf8.o is not getting compiled hence the symbol is missing, I think you need to tweak qnx/common.mk to have all source files under SRCS. Maybe you can do a wildcard (*) include. Getting close!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants