Re: [rust-dev] Problems cross-compiling to ARM9

2015-01-01 Thread Valerii Hiora
Hi Tomi,

> The prologue problem was fixed by adding "morestack: false," to the 
> linux ARM target specification, similar to how it is in the iOS 
> target.

  Right, my bad, that should be enough.

> My device does not really benefit from the segmented stack, since it 
> has only 64MB RAM

  Segmented stacks in Rust for a long time are used only for catching a
stack overflow.

-- 

  Valerii



signature.asc
Description: OpenPGP digital signature
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


Re: [rust-dev] Problems cross-compiling to ARM9

2015-01-01 Thread Vladimir Pouzanov
FWIW, we're just disabling segmented stack in zinc for now exactly because
of the same problem. I have a patch for llvm but I didn't really push it
upstream hard enough.

On Tue, Dec 30, 2014 at 11:23 AM, Valerii Hiora 
wrote:

> Hi Tomi,
>
> > Anyone have any idea if that's a larger problem, or simply something
> > nobody has written the small handcoded ASMs needed for ARMv5 or v4?
> > If latter, I might be able to wrap my head around this.
>
>   The problem you've got is related to segmented stack support. It need
> fix on 2 levels:
>
> - Rust - can be relatively easy fixed by providing (or patching) a
> target and marking it as a target which doesn't support segmented
> stacks, see example [1]
>
>Once it works you can play a bit to provide a correct implementation
> in record_sp.S and morestack.S
>
> - LLVM - as I remember some time ago LLVM generated a function prologue
> which uses the same instruction for any ARM device, may be that was
> patched in upstream, may be not. You can also ask Vladimir Pouzanov and
> zinc.rs [2] team, AFAIK they had the similar problem too and definitely
> have a workaround.
>
> [1]
>
> https://github.com/rust-lang/rust/blob/master/src/librustc_back/target/arm_apple_ios.rs#L33
> [2]  https://zinc.rs/
>
> --
>
>   Valerii
>
>
> ___
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>


-- 
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


Re: [rust-dev] Problems cross-compiling to ARM9

2014-12-31 Thread Tomi Pieviläinen
> - Rust - can be relatively easy fixed by providing (or patching) a
> target and marking it as a target which doesn't support segmented
> stacks, see example [1]

> - LLVM - as I remember some time ago LLVM generated a function
> prologue which uses the same instruction for any ARM device

The prologue problem was fixed by adding "morestack: false," to the
linux ARM target specification, similar to how it is in the iOS
target.

>Once it works you can play a bit to provide a correct
>implementation in record_sp.S and morestack.S

My device does not really benefit from the segmented stack, since it
has only 64MB RAM, so I simply modified libstd/sys/common/stack.rs to
define stubs for all ARMs, not just iOS. Not that I would have the
skills to do it anyway.

With these two modifications I got helloworld working! Thank you for
the segmented stack on iOS hint. I'll now start programming what I
originally wanted, and will report if I find any other problems.

-- 
Tomi Pieviläinen, +358 400 487 504
A: Because it disrupts the natural way of thinking.
Q: Why is top posting frowned upon?


signature.asc
Description: Digital signature
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


Re: [rust-dev] Problems cross-compiling to ARM9

2014-12-30 Thread Valerii Hiora
Hi Tomi,

> Anyone have any idea if that's a larger problem, or simply something 
> nobody has written the small handcoded ASMs needed for ARMv5 or v4?
> If latter, I might be able to wrap my head around this.

  The problem you've got is related to segmented stack support. It need
fix on 2 levels:

- Rust - can be relatively easy fixed by providing (or patching) a
target and marking it as a target which doesn't support segmented
stacks, see example [1]

   Once it works you can play a bit to provide a correct implementation
in record_sp.S and morestack.S

- LLVM - as I remember some time ago LLVM generated a function prologue
which uses the same instruction for any ARM device, may be that was
patched in upstream, may be not. You can also ask Vladimir Pouzanov and
zinc.rs [2] team, AFAIK they had the similar problem too and definitely
have a workaround.

[1]
https://github.com/rust-lang/rust/blob/master/src/librustc_back/target/arm_apple_ios.rs#L33
[2]  https://zinc.rs/

-- 

  Valerii



signature.asc
Description: OpenPGP digital signature
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


Re: [rust-dev] Problems cross-compiling to ARM9

2014-12-30 Thread Tomi Pieviläinen
So far my best guess is that the problem is the Assmebly line

mrc 15, 0, r4, cr13, cr0, {3}

in main, which means that it's trying to read from coprocessor 15,
register 13, part 3. According to
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0360e/CACEAIHG.html
that's a thread ID that's read only for user processes. But that's for
ARM11, and the corresponding doc for ARM9 (926EJ-S, specifically)
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0198e/I1002240.html
doesn't list thread registers at all. So I'm guessing it doesn't
exist, and trying to read from it naturally fails.

A friend noticed that
https://github.com/rust-lang/rust/blob/master/src/librustc_back/target/arm_unknown_linux_gnueabi.rs
specifies ARMv6 as the target, but either retargetting from command
line or recompiling with that file patched for v5te didn't help; the
resulting ASM is the same in that part.

I think the problem might be
https://github.com/rust-lang/rust/blob/master/src/rt/arch/arm/record_sp.S
which assumes a more modern architecture. So perhaps this means that
rust has stricter requirements than C gnueabi?

Anyone have any idea if that's a larger problem, or simply something
nobody has written the small handcoded ASMs needed for ARMv5 or v4? If
latter, I might be able to wrap my head around this.

-- 
Tomi Pieviläinen, +358 400 487 504
A: Because it disrupts the natural way of thinking.
Q: Why is top posting frowned upon?


signature.asc
Description: Digital signature
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


Re: [rust-dev] Problems cross-compiling to ARM9

2014-12-29 Thread Tomi Pieviläinen
> In the past when I've seen this error, it's because your C cross
> toolchain is built for a slightly wrong architecture. Can you verify
> that C programs cross compiled with your cross-gcc work correctly?

Christmas is over, back to work. C works fine just by calling
arm-linux-gnueabi-gcc. I hadn't tried an empty rust program, but that
also stops with the same "illegal instructions". The other hints are a
bit over my head right now, as I haven't done much anything this close
to metal. I'll continue studying this and report on whatever I find.

I'm still wondering if rustc is somehow creating "bad" IR, since LLVM
doesn't like that.

-- 
Tomi Pieviläinen, +358 400 487 504
A: Because it disrupts the natural way of thinking.
Q: Why is top posting frowned upon?
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


Re: [rust-dev] Problems cross-compiling to ARM9

2014-12-16 Thread Riad S. Wahby
Tomi Pieviläinen  wrote:
> --target=arm-unknown-linux-gnueabi hello.rs`, but trying to run the
> binary on the device just gives me "Illegal instruction".

In the past when I've seen this error, it's because your C cross
toolchain is built for a slightly wrong architecture. Can you verify
that C programs cross compiled with your cross-gcc work correctly?

-=rsw
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev