[rust-dev] Newbie question about Rust stack management
Good morning Rustaceans, I'm just moving my first steps into the Rust world, so please apologies in advance for my silly questions. As an exercise to learn the language I'm trying to create a streaming CLI app to decrypt data read from stdin directly into stdout. This gist is a very simple program to simply read raw bytes from stdin and pushing them out to stdout: https://gist.github.com/adinapoli/da8cc9cbaec3576a1bd4 It works, but as soon as I try to modify the BUFSIZE to be, for example, 5MB, the program crashes with: task 'main' has overflowed its stack I have tried to Google for rust increase stack size, but I wasn't able to find anything meaningful. I would like to ask you then if this is just because I failed to search the relevant bits of documentation, or it's by design because it's a bad idea to increase the stack size? This bit of documentation seems relevant, although it refers to task (but main seems to be indeed one), and returns a TaskBuilder: http://doc.rust-lang.org/std/task/struct.TaskBuilder.html#method.stack_size Thanks in advance, Alfredo ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev
Re: [rust-dev] Newbie question about Rust stack management
Ah, thanks a lot Richo, I did miss the fact a Box was allocating on the heap. Bad me! Yes, I do agree that allocating huge things on the stack is bad, hence my head scratching. Thanks! Alfredo On Thursday, 18 December 2014, Richo Healey ri...@psych0tik.net wrote: On 18/12/14 10:40 +0100, Alfredo Di Napoli wrote: Good morning Rustaceans, I'm just moving my first steps into the Rust world, so please apologies in advance for my silly questions. As an exercise to learn the language I'm trying to create a streaming CLI app to decrypt data read from stdin directly into stdout. This gist is a very simple program to simply read raw bytes from stdin and pushing them out to stdout: https://gist.github.com/adinapoli/da8cc9cbaec3576a1bd4 It works, but as soon as I try to modify the BUFSIZE to be, for example, 5MB, the program crashes with: task 'main' has overflowed its stack I have tried to Google for rust increase stack size, but I wasn't able to find anything meaningful. I would like to ask you then if this is just because I failed to search the relevant bits of documentation, or it's by design because it's a bad idea to increase the stack size? This bit of documentation seems relevant, although it refers to task (but main seems to be indeed one), and returns a TaskBuilder: http://doc.rust-lang.org/std/task/struct.TaskBuilder.html#method.stack_size Thanks in advance, Alfredo The easiest thing to do here is simply to lob it onto the heap, by putting it into a box: https://gist.github.com/0a324ac17620bf0ac286 In general, you probably don't want huge objects on the stack. richo ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev
[rust-dev] (FFI) Compile a dylib to x86 from a x86_64 machine and rust toolchain
Hello Rustacean, I’ll go straight to the point: I’m building a small FFI library which needs to be called from a C++ x86 project. I cannot change the arch of the latter (it’s Doom3, and relies on x86 arch entirely). Thus linker reject my Rust library as “file was built for x86_64 which is not the architecture being linked (i386)”. Thus my question: It’s possible (without rebuilding the toolchain) to instruct cargo to generate a x86 dylib? Something like (fantasy syntax): cargo build —arch-type=x86 Thanks in advance! Alfredo ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev
Re: [rust-dev] (FFI) Compile a dylib to x86 from a x86_64 machine and rust toolchain
Thanks Corey, I will have a look into this ;) Alfredo On Sunday, 28 December 2014, Corey Richardson co...@octayn.net wrote: You need at least a 32-bit stdlib, but you can build with `cargo build --target i686-unknown-linux-gnu` and it will Just Work assuming you have the proper libs in $PREFIX/lib/rustlib/i686-unknown-linux-gnu. http://doc.rust-lang.org/src/rustc_back/target/mod.rs.html#330 has a list of the built-in targets, and http://doc.rust-lang.org/rustc_back/target/index.html has docs on how to create your own. On Sun, Dec 28, 2014 at 2:11 PM, Alfredo Di Napoli alfredo.dinap...@gmail.com wrote: Hello Rustacean, I’ll go straight to the point: I’m building a small FFI library which needs to be called from a C++ x86 project. I cannot change the arch of the latter (it’s Doom3, and relies on x86 arch entirely). Thus linker reject my Rust library as “file was built for x86_64 which is not the architecture being linked (i386)”. Thus my question: It’s possible (without rebuilding the toolchain) to instruct cargo to generate a x86 dylib? Something like (fantasy syntax): cargo build —arch-type=x86 Thanks in advance! Alfredo ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev -- http://octayn.net/ ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev