Closed derekchiang closed 10 years ago
So I replaced main
with rustboot
in the Makefile
and the compilation was able to proceed a little bit. Now I'm getting even weirder errors:
make all -C arch/x86/
make[1]: Entering directory `/media/Work_Study/CS/workspace/rust/rustboot/arch/x86'
/usr/bin/clang -O2 -ffreestanding -target i686-intel-linux -c boot/rustboot.bc -o boot/rustboot.o
/usr/bin/ld -melf_i386 -o boot/floppy.elf -T ./boot/linker.ld ./boot/loader.o ./boot/rustboot.o "-(" ./boot/libcore-2e829c2f-0.0.rlib "-)" -Map=././boot/linker.map
./boot/libcore-2e829c2f-0.0.rlib(core.o): In function `core::u64::mul_with_overflow':
/media/Work_Study/CS/workspace/rust/rustboot/arch/x86/../../rust-core/core/u64.rs:29: undefined reference to `__udivdi3'
./boot/libcore-2e829c2f-0.0.rlib(core.o): In function `core::i64::mul_with_overflow':
/media/Work_Study/CS/workspace/rust/rustboot/arch/x86/../../rust-core/core/i64.rs:35: undefined reference to `__mulodi4'
make[1]: *** [boot/floppy.elf] Error 1
make[1]: Leaving directory `/media/Work_Study/CS/workspace/rust/rustboot/arch/x86'
make: *** [all] Error 2
Any clue what's going on?
This problem is caused by u64.rs and i64.rs, both can be removed in rust-core/core/lib.rs as a workaround. thestinger commented on f47d13b
You need clang with compiler-rt for udivdi3 and mulodi4. If you don't want to build position independent code you can pass -fno_pie.
I'm surprised your changes work, I got this:
$ make
make all -C arch/x86/
make[1]: Entering directory '/home/piotr/Desktop/rustboot/arch/x86'
make[1]: *** No rule to make target 'boot/rustboot.o', needed by 'boot/floppy.elf'. Stop.
make[1]: Leaving directory '/home/piotr/Desktop/rustboot/arch/x86'
Makefile:4: recipe for target 'all' failed
make: *** [all] Error 2
Just an idea, main.rs
(perhaps you changed it to rustboot.rs
) can be moved to kernel/lib.rs
or arch/.../lib.rs
.
Indeed, I made some mistakes. Now the Makefile
should work.
When I pass -fno_pie
to ld
, I get this error:
/usr/bin/ld -melf_i386 -fno_pie -o boot/floppy.elf -T ./boot/linker.ld ./boot/loader.o ./boot/main.o "-(" ./boot/libcore-2e829c2f-0.0.rlib "-)" -Map=././boot/linker.map
/usr/bin/ld: -f may not be used without -shared
make[1]: *** [boot/floppy.elf] Error 1
Do you know why?
Oh I misread the message. Thought it said with
rather than without
.
So I added -shared
(without knowing what the consequences are) and it compiled. When I do make run
though, all I see is a black screen flashing with the message:
Booting from Hard Disk...
Boot failed: could not read the boot disk
Booting from Floppy...
First, link compiler-rt runtime library that manipulates integers larger than 32 bits.
I'm using x86_64 Arch Linux and clang package contains /usr/lib/clang/3.4/lib/linux/libclang_rt.full-x86_64.a
. Unfortunately, it's incompatible with i386.
Two options remain.
Then append path to libclang_rt.full-i386.a
to LINK
in Makefile.
I don't think it matters. Maybe add -fno-pie
to CFLAGS
. The code is first generated by clang
, not ld
!
Sorry I pressed the comment button too quickly. Details follow:
I was trying to compile this repo according to the instructions given, but got lots of errors.
arch/x86/cpu/gdt.rs
, did not importkernel::memory::Allocator
. As a result thealloc
method couldn't be called.lib
attribute does not work anymore. It was replaced bycrate_id
.At the first glance, there is indeed no such file. The file intended to be used seems to be
rustboot.bc
. So it indicates that there are some errors in theMakefile
.