Compile hello_world against musl

Post new topic   Reply to topic    DD-WRT Forum Index -> Generic Questions
Author Message
tosiara
DD-WRT User


Joined: 20 Dec 2011
Posts: 100

PostPosted: Fri Aug 01, 2014 10:01    Post subject: Compile hello_world against musl Reply with quote
Hi,

is there any wiki about simple program compilation against new musl libc library?

My test platform is:

Code:
# cat /proc/cpuinfo
system type             : Atheros AR9132 rev 2 (0xb9)
processor               : 0
cpu model               : MIPS 24Kc V7.4
BogoMIPS                : 265.42
CPUClock                : 400
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 16
extra interrupt vector  : yes
hardware watchpoint     : yes, count: 4, address/irw mask: [0x0000, 0x0ff8, 0x0ff8, 0x0ff8]
isa                     : mips1 mips2 mips32r1 mips32r2
ASEs implemented        : mips16
shadow register sets    : 1
kscratch registers      : 0
core                    : 0
VCED exceptions         : not available
VCEI exceptions         : not available


Router Model: TP-Link TL-WR1043ND
Firmware Version: DD-WRT v24-sp2 (06/23/14) std - build 24461
Kernel Version: Linux 3.10.44 #11005 Mon Jun 23 08:30:54 CEST 2014 mips


I have downloaded toolchains from ftp://ftp.dd-wrt.com/toolchains/toolchains.tar.xz, and found gcc there:

Code:
./toolchain-mips_34kc_gcc-4.8-linaro_musl-1.1.2/bin/mips-openwrt-linux-musl-gcc



Sample source code to compile:

Code:
#include <stdio.h>
int main(int argc, char **argv)
{ printf("hello %d\n", argc); }


I compile using this command:

Code:
./mips-openwrt-linux-musl-gcc hello.c -o hello


Produced binary is:

Code:
# file hello
hello: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70403, not stripped


Then I transfer the binary to my router and try to execute - no error, but also no output:

Code:
# ./hello
#


Can anyone point me - what is wrong?
I tried to compile division by zero - no segfault. Looks like program is not being executed

Any help appreciated

Thaks


Last edited by tosiara on Sat Aug 02, 2014 16:17; edited 1 time in total
Sponsor
BrainSlayer
Site Admin


Joined: 06 Jun 2006
Posts: 7492
Location: Dresden, Germany

PostPosted: Sat Aug 02, 2014 9:50    Post subject: Reply with quote
compile with -DNEED_PRINTF
all toolchains in dd-wrt do disable any printf output without that definition. thats one way to safe alot of space within the firmware

_________________
"So you tried to use the computer and it started smoking? Sounds like a Mac to me.." - Louis Rossmann https://www.youtube.com/watch?v=eL_5YDRWqGE&t=60s
tosiara
DD-WRT User


Joined: 20 Dec 2011
Posts: 100

PostPosted: Sat Aug 02, 2014 16:55    Post subject: Reply with quote
BrainSlayer wrote:
compile with -DNEED_PRINTF
all toolchains in dd-wrt do disable any printf output without that definition. thats one way to safe alot of space within the firmware

That worked, thanks!
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Generic Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum