www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Writing a small linux binary

reply "NVolcz" <niklas.volcz gmail.com> writes:
Can this be done in D? How easy is it? What about the runtime?

https://www.reddit.com/r/programming/comments/2s1sgg/151byte_static_linux_binary_in_rust/

Best regards,
NVolcz
Jan 11 2015
next sibling parent ketmar via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Mon, 12 Jan 2015 05:59:35 +0000
NVolcz via Digitalmars-d <digitalmars-d puremagic.com> wrote:

 Can this be done in D?
yes.
 How easy is it?
it depends of your experience and readyness to live without phobos and GC.
 What about the runtime?
you may need to write one which will include only functions your program requires. p.s. i've not visited the link.
Jan 12 2015
prev sibling parent reply "Mike" <none none.com> writes:
On Monday, 12 January 2015 at 05:59:36 UTC, NVolcz wrote:
 Can this be done in D? How easy is it? What about the runtime?

 https://www.reddit.com/r/programming/comments/2s1sgg/151byte_static_linux_binary_in_rust/
Here's a link to my 56 byte "Hello, World!" program for the ARM Cortex-M platform in D. And, if I only used the string "Hello!" like the rust example, I believe it would be 47 bytes. http://goo.gl/qWhpVX Mike
Jan 12 2015
next sibling parent "Paulo Pinto" <pjmlp progtools.org> writes:
On Monday, 12 January 2015 at 08:46:57 UTC, Mike wrote:
 On Monday, 12 January 2015 at 05:59:36 UTC, NVolcz wrote:
 Can this be done in D? How easy is it? What about the runtime?

 https://www.reddit.com/r/programming/comments/2s1sgg/151byte_static_linux_binary_in_rust/
Here's a link to my 56 byte "Hello, World!" program for the ARM Cortex-M platform in D. And, if I only used the string "Hello!" like the rust example, I believe it would be 47 bytes. http://goo.gl/qWhpVX Mike
Just posted the link to HN. -- Paulo
Jan 12 2015
prev sibling parent reply Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 12 January 2015 at 08:46, Mike via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Monday, 12 January 2015 at 05:59:36 UTC, NVolcz wrote:
 Can this be done in D? How easy is it? What about the runtime?


 https://www.reddit.com/r/programming/comments/2s1sgg/151byte_static_linux_binary_in_rust/
Here's a link to my 56 byte "Hello, World!" program for the ARM Cortex-M platform in D. And, if I only used the string "Hello!" like the rust example, I believe it would be 47 bytes. http://goo.gl/qWhpVX Mike
Without performing any linker magic. root f6e559d2d853:~# cat > small.d << EOF import core.stdc.stdio; import core.stdc.stdlib; extern(C) void main() { printf("Hello!\n"); exit(0); } EOF root f6e559d2d853:~# gdc -frelease -Os -nophoboslib -fno-emit-moduleinfo -nostdlib --entry=main small.d -lc -o small root f6e559d2d853:~# wc -c small 2488 small root f6e559d2d853:~# ./small Hello!
Jan 12 2015
parent "Paulo Pinto" <pjmlp progtools.org> writes:
On Monday, 12 January 2015 at 09:00:58 UTC, Iain Buclaw via 
Digitalmars-d wrote:
 On 12 January 2015 at 08:46, Mike via Digitalmars-d
 <digitalmars-d puremagic.com> wrote:
 On Monday, 12 January 2015 at 05:59:36 UTC, NVolcz wrote:
 Can this be done in D? How easy is it? What about the runtime?


 https://www.reddit.com/r/programming/comments/2s1sgg/151byte_static_linux_binary_in_rust/
Here's a link to my 56 byte "Hello, World!" program for the ARM Cortex-M platform in D. And, if I only used the string "Hello!" like the rust example, I believe it would be 47 bytes. http://goo.gl/qWhpVX Mike
Without performing any linker magic. root f6e559d2d853:~# cat > small.d << EOF import core.stdc.stdio; import core.stdc.stdlib; extern(C) void main() { printf("Hello!\n"); exit(0); } EOF root f6e559d2d853:~# gdc -frelease -Os -nophoboslib -fno-emit-moduleinfo -nostdlib --entry=main small.d -lc -o small root f6e559d2d853:~# wc -c small 2488 small root f6e559d2d853:~# ./small Hello!
Would be considered linker magic to use _start(), write() and _exit() instead? :) -- Paulo
Jan 12 2015