kentosama / m68k-elf-gcc

GCC toolchain for Motorola 68000
32 stars 12 forks source link

build-toolchain fails on linux and osx, libc not found #1

Open bferguson3 opened 3 years ago

bferguson3 commented 3 years ago

mkdir .deps /bin/sh ../../source/gcc-6.3.0/mkinstalldirs /Users/shram/Projects/m68k-elf-gcc/m68k-toolchain /Users/shram/Projects/m68k-elf-gcc/m68k-toolchain /bin/sh: line 0: cd: m68k-elf/libgcc: No such file or directory make: *** [install-target-libgcc] Error 1 ./build-toolchain.sh: line 77: Failed to build gcc stage 1, please check build.log: command not found

bferguson3 commented 3 years ago

config.status: executing default commands /bin/bash ../../source/gcc-6.3.0/mkinstalldirs /home/pi/Projects/m68k-elf-gcc/m68k-toolchain /home/pi/Projects/m68k-elf-gcc/m68k-toolchain /bin/bash: line 3: cd: m68k-elf/libgcc: No such file or directory make: *** [Makefile:12338: install-target-libgcc] Error 1 ./build-toolchain.sh: line 77: Failed to build gcc stage 1, please check build.log: command not found

bferguson3 commented 3 years ago

This seems to be an issue with the Makefile configure that comes with the version of gcc-6 you selected.

I manually downloaded 7.5.0, extracted it to /src and changed $VERSION in ./build-gcc.sh in order to successfully build.

More detail: GCC 6.x uses its own configure script to generate its Makefile. It uses an internal variable called $PWD_COMMAND to ensure it runs 'pwd' successfully. The code it generates to assign PWD_COMMAND is faulty. I don't know how to fix this for GCC 6 so I just upgraded to see if it would fix it, and it did.

bferguson3 commented 3 years ago

pi@raspberrypi:~/Projects/m68k-elf-gcc/m68k-toolchain/bin $ ./m68k-elf-gcc-7.5.0 ~/Projects/asmtest/main.c /home/pi/Projects/m68k-elf-gcc/m68k-toolchain/lib/gcc/m68k-elf/7.5.0/../../../../m68k-elf/bin/ld: cannot find -lc collect2: error: ld returned 1 exit status

for some reason libc.so is not created with gcc 7, so still stuck.

bferguson3 commented 3 years ago
CC=m68k-elf-gcc 
OBJCOPY=m68k-elf-objcopy
LIBFIX=-nostdlib

main.bin: main.elf main.s
    ${OBJCOPY} -O binary main.elf main.bin

%.elf: %.s
    ${CC} ${LIBFIX} -o main.elf main.s

%.s: %.c
    ${CC} -S ${LIBFIX} -o main.s main.c

clean:
    rm -rf *.bin *.elf *.s

despite the redundancy making the .s file, using this make (i.e. using -nostdlib) allows me to compile on Debian/pi.

Is there a way to build gcc so that -nostdlib isn't required on every compile?