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

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

Open
bferguson3 opened this issue Apr 6, 2021 · 4 comments
Open

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

bferguson3 opened this issue Apr 6, 2021 · 4 comments

Comments

@bferguson3
Copy link

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 bferguson3 changed the title build-toolchain fails on osx build-toolchain fails on linux and osx Apr 6, 2021
@bferguson3
Copy link
Author

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
Copy link
Author

bferguson3 commented Apr 6, 2021

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 bferguson3 reopened this Apr 6, 2021
@bferguson3 bferguson3 changed the title build-toolchain fails on linux and osx build-toolchain fails on linux and osx, libc not found Apr 6, 2021
@bferguson3
Copy link
Author

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
Copy link
Author

bferguson3 commented Apr 7, 2021

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?

5inf added a commit to 5inf/m68k-elf-gcc that referenced this issue Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant