nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

Makefile does not detect new toolchain

Open kassane opened this issue 2 years ago • 4 comments

Ref: #5732

When trying last to commit the proposal above there was an issue during the make build running the toolchain that its initialization was not listed in the makefile log. I expected at least some compilation error but it doesn't even return. Except when replacing the CC and CXX with ZCC and ZCXX there are some compilation errors on Config.mk file.

Would any further changes be required to add a new toolchain or did I forget some reference point?

output:

# [...]
CC:  signal/sig_ppoll.c
make[3]: Entrando no diretório '/home/kassane/Code/nuttxspace/apps/examples/hello_zig'

CC:  driver/fs_closeblockdriver.c
CC:  signal/sig_fillset.c
CC:  signal/sig_hold.c
CC:  signal/sig_pselect.c
CC:  driver/fs_blockpartition.c
CC:  signal/sig_ignore.c
CC:  task/task_create.c
CC:  signal/sig_ismember.c
CC:  driver/fs_findmtddriver.c
CC:  signal/sig_pause.c
CC:  task/task_init.c
CC:  driver/fs_blockproxy.c
CC:  signal/sig_psignal.c
CC:  task/task_setup.c
CC:  dirent/fs_closedir.c
CC:  signal/sig_raise.c
AR (add): libapps.a           
# Missing ZIG: examples/hello_zig/hello_zig_main.zig
make[3]: Saindo do diretório '/home/kassane/Code/nuttxspace/apps/examples/hello_zig'
# [...]
/usr/bin/ld: nuttx.rel:(.data.rel.ro.g_builtins+0x28): reference not defined for "hello_zig_main"
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:323: nuttx] Error 1
make: *** [tools/Unix.mk:509: nuttx] Error 2

kassane avatar May 08 '22 18:05 kassane

Does the new toolchain on your search path?

xiaoxiang781216 avatar May 12 '22 18:05 xiaoxiang781216

Right, the example of this is zcc and zcxx worked even though they generated a flags error. Only zig build did not return any information in the output. I will review the application.mk file again.

The strange thing is that when did an external test manually everything works. But only note in question is the condition to always link the object generated by zig to libc.

What do you mean?

zig code doesn't need libc (only ffi) and the other toolchains can't find to call it.

e.g.:

$> zig build-obj src.zig
...
$> xtoolchain-gcc src.o -o myfile
# error, need to call libc
....
$> zig build-obj src.zig -lc #link to libc
...
$> xtoolchain-gcc src.o -o myfile
# done

kassane avatar May 12 '22 20:05 kassane

Wow! Thx @lupyuen

Ref.: https://github.com/lupyuen/zig-bl602-nuttx

kassane avatar May 25 '22 11:05 kassane

Thanks! I'm totally new to Zig, but it looks super exciting :-)

lupyuen avatar May 25 '22 12:05 lupyuen