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

Can you replicate the examples on macOS? #7

Closed
japaric opened this Issue Aug 2, 2018 · 10 comments

Comments

Projects
None yet
5 participants
@japaric
Copy link
Member

japaric commented Aug 2, 2018

Let us know if you had to significantly deviate from the instructions!

@japaric japaric added this to the RC1 milestone Aug 2, 2018

@tekjar

This comment has been minimized.

Copy link

tekjar commented Aug 4, 2018

I can do this

@japaric japaric self-assigned this Aug 7, 2018

@japaric

This comment has been minimized.

Copy link
Member Author

japaric commented Aug 7, 2018

@tekjar Thanks! To clarify: do you mean you can run the examples on macOS? Or that you would test this (but haven't yet)?

@tekjar

This comment has been minimized.

Copy link

tekjar commented Aug 7, 2018

Oops. Sorry for the confusion. Yet to test.

@odunboye

This comment has been minimized.

Copy link

odunboye commented Aug 9, 2018

@japaric I have tested the example in Memory layout page and got the follow error :

error: language item required, but not found: `eh_personality`
error: aborting due to previous error
error: Could not compile `app`.
To learn more, run the command again with --verbose.

What could be the issue?
Thanks .

@japaric

This comment has been minimized.

Copy link
Member Author

japaric commented Aug 9, 2018

@odunboye sounds like you are compiling the program for the host instead of cross compiling. Did you set up a default build target in .cargo/config as covered in the last part of the first section (smallest std program)? If you missed it, it may be good to mention it again in the second section.

@odunboye

This comment has been minimized.

Copy link

odunboye commented Aug 9, 2018

@japaric I was able to compile it by setting the .cargo/config content
Currently testing the rest of the examples on MacOS
Thanks

@odunboye

This comment has been minimized.

Copy link

odunboye commented Aug 10, 2018

@japaric I was able to test the example up until the very last one where I can't generate the "release" version of the output like target/thumbv7m-none-eabi/release/app but was able to compile to the debug output.
What compilation flag compiles for the release version?

@andre-richter

This comment has been minimized.

Copy link
Member

andre-richter commented Aug 11, 2018

Try using the --release argument when building.

Note to self: add this missing info to the book.

@twilco

This comment has been minimized.

Copy link

twilco commented Sep 11, 2018

I ran through the whole thing (almost) without issue on MacOS 10.12.6.

I did run into issues with the lldb related stuff, but it seems to be Python problems. From the end of the "Memory layout" section:

$ lldb target/thumbv7m-none-eabi/debug/embedonomicon
(lldb) target create "target/thumbv7m-none-eabi/debug/embedonomicon"
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
    import weakref
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Current executable set to 'target/thumbv7m-none-eabi/debug/embedonomicon' (arm).
(lldb) gdb-remote 3333
Process 1 stopped
* thread #1, stop reason = signal SIGTRAP
    frame #0: 0x00000008 embedonomicon`Reset at main.rs:9
   6    
   7    #[panic_handler]
   8    fn panic(_panic: &PanicInfo) -> ! {
-> 9        loop {}
   10   }
   11   
   12   // The reset handler
Target 0: (embedonomicon) stopped.
(lldb) disassemble -frame
embedonomicon`Reset:
->  0x8 <+0>:  sub    sp, #0x4
    0xa <+2>:  movs   r0, #0x2a
    0xc <+4>:  str    r0, [sp]
    0xe <+6>:  b      0x10                      ; <+8> at main.rs:18
    0x10 <+8>: b      0x10                      ; <+8> at main.rs:18
(lldb) print/x $sp
error: need to add support for DW_TAG_base_type '!' encoded with DW_ATE = 0x7, bit_size = 0
(unsigned int) $0 = 0x20010000
(lldb) step
Process 1 stopped
* thread #1, stop reason = step in
    frame #0: 0x0000000c embedonomicon`Reset at main.rs:15
   12   // The reset handler
   13   #[no_mangle]
   14   pub unsafe extern "C" fn Reset() -> ! {
-> 15       let _x = 42;
   16   
   17       // can't return so we go into an infinite loop here
   18       loop {}
Target 0: (embedonomicon) stopped.
(lldb) step
Process 1 stopped
* thread #1, stop reason = step in
    frame #0: 0x0000000e embedonomicon`Reset at main.rs:18
   15       let _x = 42;
   16   
   17       // can't return so we go into an infinite loop here
-> 18       loop {}
   19   }
   20   
   21   // The reset vector, a pointer into the reset handler
Target 0: (embedonomicon) stopped.

However, things mostly worked :). Looking at flutter/flutter#17803, there is probably some brew/Python finagling that could be done to make it work.

Might be worth noting in the embedonomicon that installing QEMU and qemu-system-arm on MacOS is as simple as brew install qemu. Googling "install qemu macos" and/or "install qemu-system-arm macos" doesn't yield a lot of clear information to get what is needed only for this guide (and not QEMU for emulating a Raspberry Pi or something else, which I saw a lot of).

@japaric

This comment has been minimized.

Copy link
Member Author

japaric commented Sep 14, 2018

@twilco thanks for the report. Some windows users are also having trouble with lldb so I think we'll recommend gdb instead of lldb.

Might be worth noting in the embedonomicon that installing QEMU and qemu-system-arm on MacOS is as simple as brew install qemu

Thanks for the info! I'll add a small section to the preface covering how to install the tools on macOS.

japaric added a commit that referenced this issue Sep 14, 2018

LLDB -> GDB; +setup instructions for Windows and mac; -cargo-edit
this commit:

- changes the debugger to GDB since Windows and macOS users reported errors with
LLDB

- adds setup instructions for Windows and macOS

- drops the cargo-edit dependency since it's used only once and lets us simplify
  the setup instructions

- adds a note regarding .cargo/config being required in section 3 since some
  people missed it while reading section 2

- removes a note about llvm-objdump not working correctly since the problem was
  fixed in cargo-binutils v0.1.4

closes #8
closes #7

@japaric japaric closed this in #20 Sep 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.