zephyrproject-rtos / sdk-ng

Zephyr SDK (Toolchains, Development Tools)
Apache License 2.0
184 stars 133 forks source link

Cannot link "Hello world!" #776

Open RobertoBagnara opened 2 months ago

RobertoBagnara commented 2 months ago

I am sure I am missing something trivial, but here it goes:

$ cat hello.c 
#include <stdio.h>

int main() {
  printf("Hello world!\n");
}
$ ~/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/x86_64-zephyr-elf-gcc -v hello.c 
Using built-in specs.
COLLECT_GCC=/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/x86_64-zephyr-elf-gcc
COLLECT_LTO_WRAPPER=/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../libexec/gcc/x86_64-zephyr-elf/12.2.0/lto-wrapper
Target: x86_64-zephyr-elf
Configured with: /__w/_temp/workspace/build/.build/x86_64-zephyr-elf/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=x86_64-zephyr-elf --prefix=/__w/_temp/workspace/output/x86_64-zephyr-elf --exec_prefix=/__w/_temp/workspace/output/x86_64-zephyr-elf --with-local-prefix=/__w/_temp/workspace/output/x86_64-zephyr-elf/x86_64-zephyr-elf --with-headers=/__w/_temp/workspace/output/x86_64-zephyr-elf/x86_64-zephyr-elf/include --with-newlib --enable-threads=no --disable-shared --with-pkgversion='Zephyr SDK 0.16.8' --with-bugurl=https://github.com/zephyrproject-rtos/sdk-ng/issues --enable-__cxa_atexit --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libstdcxx-verbose --with-gmp=/__w/_temp/workspace/build/.build/x86_64-zephyr-elf/buildtools --with-mpfr=/__w/_temp/workspace/build/.build/x86_64-zephyr-elf/buildtools --with-mpc=/__w/_temp/workspace/build/.build/x86_64-zephyr-elf/buildtools --with-isl=/__w/_temp/workspace/build/.build/x86_64-zephyr-elf/buildtools --enable-lto --enable-target-optspace --disable-nls --enable-multiarch --enable-languages=c,c++ --with-gnu-ld --with-gnu-as --enable-initfini-array --with-cpu-32=i586 --with-arch-32=i586 --with-cpu-64=generic --with-arch-64=x86-64
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 12.2.0 (Zephyr SDK 0.16.8) 
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../libexec/gcc/x86_64-zephyr-elf/12.2.0/cc1 -quiet -v -iprefix /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/ hello.c -quiet -dumpdir a- -dumpbase hello.c -dumpbase-ext .c -mtune=generic -march=x86-64 -version -o /tmp/ccHdDHd0.s
GNU C17 (Zephyr SDK 0.16.8) version 12.2.0 (x86_64-zephyr-elf)
    compiled by GNU C version 7.5.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/../../lib/gcc/x86_64-zephyr-elf/12.2.0/include"
ignoring duplicate directory "/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/../../lib/gcc/x86_64-zephyr-elf/12.2.0/include-fixed"
ignoring duplicate directory "/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/../../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/sys-include"
ignoring duplicate directory "/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/../../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/include
 /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/include-fixed
 /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/sys-include
 /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/include
End of search list.
GNU C17 (Zephyr SDK 0.16.8) version 12.2.0 (x86_64-zephyr-elf)
    compiled by GNU C version 7.5.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 52ff28bc1f0e4fb3c32d27070b9aae1a
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/as -v -o /tmp/ccfwtURD.o /tmp/ccHdDHd0.s
GNU assembler version 2.38 (x86_64-zephyr-elf) using BFD version (Zephyr SDK 0.16.8) 2.38
COMPILER_PATH=/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../libexec/gcc/x86_64-zephyr-elf/12.2.0/:/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../libexec/gcc/:/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/
LIBRARY_PATH=/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/:/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/:/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/lib/
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a.'
 /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../libexec/gcc/x86_64-zephyr-elf/12.2.0/collect2 -plugin /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../libexec/gcc/x86_64-zephyr-elf/12.2.0/liblto_plugin.so -plugin-opt=/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../libexec/gcc/x86_64-zephyr-elf/12.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/cc0qQTds.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/crtbegin.o -L/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0 -L/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc -L/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/lib /tmp/ccfwtURD.o -lgcc -lc -lgcc /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/crtend.o
/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/ld: warning: cannot find entry symbol _start; defaulting to 00000000004000b0
/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/ld: /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/lib/libc.a(lib_a-sbrkr.o): in function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0x1a): undefined reference to `_sbrk'
/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/ld: /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/lib/libc.a(lib_a-writer.o): in function `_write_r':
writer.c:(.text._write_r+0x21): undefined reference to `_write'
/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/ld: /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/lib/libc.a(lib_a-closer.o): in function `_close_r':
closer.c:(.text._close_r+0x1b): undefined reference to `_close'
/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/ld: /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/lib/libc.a(lib_a-lseekr.o): in function `_lseek_r':
lseekr.c:(.text._lseek_r+0x20): undefined reference to `_lseek'
/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/ld: /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/lib/libc.a(lib_a-readr.o): in function `_read_r':
readr.c:(.text._read_r+0x21): undefined reference to `_read'
/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/ld: /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/lib/libc.a(lib_a-fstatr.o): in function `_fstat_r':
fstatr.c:(.text._fstat_r+0x1e): undefined reference to `_fstat'
/home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/bin/ld: /home/roberto/zephyr-sdk-0.16.8/x86_64-zephyr-elf/bin/../lib/gcc/x86_64-zephyr-elf/12.2.0/../../../../x86_64-zephyr-elf/lib/libc.a(lib_a-isattyr.o): in function `_isatty_r':
isattyr.c:(.text._isatty_r+0x1b): undefined reference to `_isatty'
collect2: error: ld returned 1 exit status
$