diodesign / diosix

A lightweight, secure, multiprocessor bare-metal hypervisor written in Rust for RISC-V
https://diosix.org/
MIT License
191 stars 12 forks source link

Undefined reference to `abort` #3

Closed pavelonline closed 5 years ago

pavelonline commented 6 years ago

When tried to build as it is suggested in the README file. Got this error:

riscv32-elf-ld: /home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.0.rcgu.o: in function `core::result::unwrap_failed':
          kernel.eylniip0-cgu.0:(.text._ZN4core6result13unwrap_failed17h039c92a70aa18ed7E+0x56): undefined reference to `abort'

The full output:

% ./build.sh --triple riscv32imac-unknown-none-elf --platform sifive_u34
Building for riscv32 SiFive Freedom U34 series
   Compiling diosix v2.0.0 (/home/pkukushkin/own/diosix)                                                                            
warning: function is never used: `kernel_irq_handler`                                                                               
  --> src/kernel/irq.rs:21:1                                                                                                        
   |                                                                                                                                
21 | pub extern "C" fn kernel_irq_handler(context: IRQContext)                                                                      
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                      
   |                                                                                                                                
   = note: #[warn(dead_code)] on by default                                                                                         

warning: function is never used: `exception`                                                                                        
  --> src/kernel/irq.rs:33:1                                                                                                        
   |                                                                                                                                
33 | fn exception(irq: IRQ)                                                                                                         
   | ^^^^^^^^^^^^^^^^^^^^^^                                                                                                         

warning: function is never used: `interrupt`                                                                                        
  --> src/kernel/irq.rs:47:1                                                                                                        
   |                                                                                                                                
47 | fn interrupt(_irq: platform::common::IRQ)                                                                                      
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                      

warning: function is never used: `abort`                                                                                            
  --> src/kernel/abort.rs:19:1                                                                                                      
   |                                                                                                                                
19 | pub extern "C" fn abort() -> !                                                                                                 
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                 

warning: function is marked #[no_mangle], but not exported                                                                          
  --> src/kernel/irq.rs:21:1                                                                                                        
   |                                                                                                                                
21 | / pub extern "C" fn kernel_irq_handler(context: IRQContext)                                                                    
22 | | {                                                                                                                            
23 | |   let irq = platform::common::irq::dispatch(context);                                                                        
24 | |                                                                                                                              
...  |                                                                                                                              
29 | |   };                                                                                                                         
30 | | }                                                                                                                            
   | |_^                                                                                                                            
   |                                                                                                                                
   = note: #[warn(private_no_mangle_fns)] on by default                                                                             
   = help: try exporting the item with a `pub use` statement                                                                        

warning: function is marked #[no_mangle], but not exported                                                                          
  --> src/kernel/abort.rs:19:1                                                                                                      
   |                                                                                                                                
19 | / pub extern "C" fn abort() -> !                                                                                               
20 | | {                                                                                                                            
21 | |   kalert!("Abort handler reached!");                                                                                         
22 | |   loop {}                                                                                                                    
23 | | }                                                                                                                            
   | |_^                                                                                                                            
   |                                                                                                                                
   = help: try exporting the item with a `pub use` statement                                                                        

error: linking with `riscv32-elf-ld` failed: exit code: 1                                                                           
  |                                                                                                                                 
  = note: "riscv32-elf-ld" "-L" "/home/pkukushkin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.0.rcgu.o" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.1.rcgu.o" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.2.rcgu.o" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.3.rcgu.o" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.4.rcgu.o" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.5.rcgu.o" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.6.rcgu.o" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.7.rcgu.o" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.8.rcgu.o" "-o" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5" "--gc-sections" "-L" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps" "-L" "/home/pkukushkin/own/diosix/target/release/deps" "-L" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/build/diosix-a0cb742e0343cb8c/out" "-L" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/build/diosix-a0cb742e0343cb8c/out" "-L" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/build/diosix-a0cb742e0343cb8c/out" "-L" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/build/diosix-a0cb742e0343cb8c/out" "-L" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/build/diosix-a0cb742e0343cb8c/out" "-L" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/build/diosix-a0cb742e0343cb8c/out" "-L" "/home/pkukushkin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib" "-Bstatic" "--whole-archive" "-lentry" "--no-whole-archive" "--whole-archive" "-lserial" "--no-whole-archive" "--whole-archive" "-lirq" "--no-whole-archive" "--whole-archive" "-lutils" "--no-whole-archive" "--whole-archive" "-lconsts" "--no-whole-archive" "--whole-archive" "-latomics" "--no-whole-archive" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/libplatform-b259f12999087a7e.rlib" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/libcommon-ebe915d491305f12.rlib" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/libhermit_dtb-ce69622086d2f810.rlib" "/home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/libbyteorder-b26fa9469004fc14.rlib" "/home/pkukushkin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib/libcore-a83244677bb7b80c.rlib" "/home/pkukushkin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/riscv32imac-unknown-none-elf/lib/libcompiler_builtins-66da1cd884dc7f8e.rlib" "-Tsrc/platform/riscv32/sifive_u34/link.ld" "-Bdynamic"
  = note: riscv32-elf-ld: /home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.0.rcgu.o: in function `core::result::unwrap_failed':
          kernel.eylniip0-cgu.0:(.text._ZN4core6result13unwrap_failed17h039c92a70aa18ed7E+0x56): undefined reference to `abort'     
          riscv32-elf-ld: /home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.2.rcgu.o: in function `kmain':
          kernel.eylniip0-cgu.2:(.text.kmain+0x190): undefined reference to `abort'                                                 
          riscv32-elf-ld: /home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/kernel-f5bc6e927e6214b5.kernel.eylniip0-cgu.7.rcgu.o: in function `rust_begin_unwind':
          kernel.eylniip0-cgu.7:(.text.rust_begin_unwind+0x98): undefined reference to `abort'                                      
          riscv32-elf-ld: /home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/build/diosix-a0cb742e0343cb8c/out/libirq.a(irq.o): in function `irq_machine_handler':
          (.text+0x7c): undefined reference to `kernel_irq_handler'                                                                 
          riscv32-elf-ld: /home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/libcommon-ebe915d491305f12.rlib(common-ebe915d491305f12.common.7p0l84du-cgu.1.rcgu.o): in function `common::devicetree::get_ram_size':
          common.7p0l84du-cgu.1:(.text._ZN6common10devicetree12get_ram_size17h50b7f9c20faec30bE+0xce): undefined reference to `abort'
          riscv32-elf-ld: /home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/libhermit_dtb-ce69622086d2f810.rlib(hermit_dtb-ce69622086d2f810.hermit_dtb.f3h2hg1a-cgu.0.rcgu.o): in function `core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::RangeTo<usize>>::index::{{closure}}':
          hermit_dtb.f3h2hg1a-cgu.0:(.text._ZN4core3str6traits103_$LT$impl$u20$core..slice..SliceIndex$LT$str$GT$$u20$for$u20$core..ops..range..RangeTo$LT$usize$GT$$GT$5index28_$u7b$$u7b$closure$u7d$$u7d$17h5560586b1973a5b1E+0x14): undefined reference to `abort'
          riscv32-elf-ld: /home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/libhermit_dtb-ce69622086d2f810.rlib(hermit_dtb-ce69622086d2f810.hermit_dtb.f3h2hg1a-cgu.0.rcgu.o): in function `core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::RangeFrom<usize>>::index::{{closure}}':
          hermit_dtb.f3h2hg1a-cgu.0:(.text._ZN4core3str6traits105_$LT$impl$u20$core..slice..SliceIndex$LT$str$GT$$u20$for$u20$core..ops..range..RangeFrom$LT$usize$GT$$GT$5index28_$u7b$$u7b$closure$u7d$$u7d$17hfa85dc0daab64c6aE+0x1a): undefined reference to `abort'
          riscv32-elf-ld: /home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/libhermit_dtb-ce69622086d2f810.rlib(hermit_dtb-ce69622086d2f810.hermit_dtb.f3h2hg1a-cgu.0.rcgu.o): in function `hermit_dtb::Dtb::get_property':
          hermit_dtb.f3h2hg1a-cgu.0:(.text._ZN10hermit_dtb3Dtb12get_property17hb4fa852c51ed2636E+0x360): undefined reference to `abort'
          riscv32-elf-ld: hermit_dtb.f3h2hg1a-cgu.0:(.text._ZN10hermit_dtb3Dtb12get_property17hb4fa852c51ed2636E+0x374): undefined reference to `abort'
          riscv32-elf-ld: /home/pkukushkin/own/diosix/target/riscv32imac-unknown-none-elf/release/deps/libhermit_dtb-ce69622086d2f810.rlib(hermit_dtb-ce69622086d2f810.hermit_dtb.f3h2hg1a-cgu.0.rcgu.o):hermit_dtb.f3h2hg1a-cgu.0:(.text._ZN10hermit_dtb3Dtb12get_property17hb4fa852c51ed2636E+0x3ca): more undefined references to `abort' follow
diodesign commented 5 years ago

First off, and most importantly: I want to say thanks for trying out the project, and for the pull request. I really appreciate the interest and input, and you're more than welcome to contribute in future.

Which version of Rust are you using, please? I'm using rustc 1.32.0-nightly (36a50c29f 2018-11-09) and not seeing any build failures. This might me a stable-nightly issue? I have a Travis CI process setup to warn me of build failures, and fix them up fast. In any case, the issue might be fixed up by now? Cheers!