sysprog21/doom_riscv

Can't build doom-riscv.elf with existing Makefile

ChinYikMing opened this issue · 2 comments

riscv-none-embed-gcc -Wall -Ofast -march=rv32im -mabi=ilp32 -ffreestanding -flto -fomit-frame-pointer -Wl,--gc-section --specs=nano.specs -I.. -DSCREENWIDTH=640 -DSCREENHEIGHT=360 -Wl,-Bstatic,--strip-debug -o doom-riscv.elf ../am_map.c ../d_items.c ../d_net.c ../doomdef.c ../doomstat.c ../dstrings.c ../f_finale.c ../f_wipe.c ../g_game.c ../hu_lib.c ../hu_stuff.c ../info.c ../m_argv.c ../m_bbox.c ../m_cheat.c ../m_menu.c ../m_misc.c ../m_random.c ../m_swap.c ../m_recip.c ../p_ceilng.c ../p_doors.c ../p_enemy.c ../p_floor.c ../p_inter.c ../p_lights.c ../p_map.c ../p_maputl.c ../p_mobj.c ../p_plats.c ../p_pspr.c ../p_saveg.c ../p_setup.c ../p_sight.c ../p_spec.c ../p_switch.c ../p_telept.c ../p_tick.c ../p_user.c ../r_bsp.c ../r_data.c ../r_draw.c ../r_main.c ../r_plane.c ../r_segs.c ../r_sky.c ../r_things.c ../sounds.c ../st_lib.c ../st_stuff.c ../tables.c ../v_video.c ../wi_stuff.c ../w_wad.c ../z_zone.c d_main.c i_main.c i_net.c i_sound.c i_system.c i_video.c s_sound.c console.c
/opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/bin/ld: /opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/lib/rv32im/ilp32/libc_nano.a(lib_a-exit.o): in function `.L0 ':
(.text.exit+0x38): undefined reference to `_exit'
/opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/bin/ld: /opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/lib/rv32im/ilp32/libc_nano.a(lib_a-openr.o): in function `.L0 ':
(.text._open_r+0x20): undefined reference to `_open'
/opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/bin/ld: /opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/lib/rv32im/ilp32/libc_nano.a(lib_a-sbrkr.o): in function `.L0 ':
(.text._sbrk_r+0x18): undefined reference to `_sbrk'
/opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/bin/ld: /opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/lib/rv32im/ilp32/libc_nano.a(lib_a-timesr.o): in function `_times_r':
(.text._times_r+0x4): undefined reference to `_times'
/opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/bin/ld: /opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/lib/rv32im/ilp32/libc_nano.a(lib_a-writer.o): in function `.L0 ':
(.text._write_r+0x20): undefined reference to `_write'
/opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/bin/ld: /opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/lib/rv32im/ilp32/libc_nano.a(lib_a-closer.o): in function `.L0 ':
(.text._close_r+0x18): undefined reference to `_close'
/opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/bin/ld: /opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/lib/rv32im/ilp32/libc_nano.a(lib_a-fstatr.o): in function `.L0 ':
(.text._fstat_r+0x1c): undefined reference to `_fstat'
/opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/bin/ld: /opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/lib/rv32im/ilp32/libc_nano.a(lib_a-isattyr.o): in function `.L0 ':
(.text._isatty_r+0x18): undefined reference to `_isatty'
/opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/bin/ld: /opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/lib/rv32im/ilp32/libc_nano.a(lib_a-lseekr.o): in function `.L0 ':
(.text._lseek_r+0x20): undefined reference to `_lseek'
/opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/bin/ld: /opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/lib/rv32im/ilp32/libc_nano.a(lib_a-readr.o): in function `.L0 ':
(.text._read_r+0x20): undefined reference to `_read'
/opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/bin/ld: /opt/riscv-none-embed-gcc/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin/../lib/gcc/riscv-none-embed/10.2.0/../../../../riscv-none-embed/lib/rv32im/ilp32/libc_nano.a(lib_a-statr.o): in function `.L0 ':
(.text._stat_r+0x1c): undefined reference to `_stat'
jserv commented

You have to build RISC-V toolchain from scratch. See https://github.com/riscv-collab/riscv-gnu-toolchain
Don't use prebuilt toolchains. Reference configurations:

--target=riscv32-unknown-elf --disable-shared --disable-threads --enable-languages=c,c++ --with-pkgversion= --with-system-zlib --enable-tls --with-newlib --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --disable-tm-clone-registry --enable-multilib --with-abi=ilp32 --with-arch=rv32im

Thanks for the solution!