Topic: compiling on OpenWRT router natively?

Did anyone try to build software on a OpenWRT router natively, that is, on the device itself, with no cross-compiling?

The ones that would like to answer "that doesn't make any sense" should know:

some software compiles and runs the binaries that were just built during the compilation, so cross-compiling will either not work at all, or the build will be incomplete / instable.

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

Re: compiling on OpenWRT router natively?

I'm one of the guys that say "it doesn't make any sense" - and here's a hint on how to solve your problem with cross-compiling:
run make twice. once with the host compiler settings only for those targets that need to be executed on the host at compile time, then run another make process for all the other binaries with the cross compiling settings.
There are several other packages that need this, so it's been done before...

Re: compiling on OpenWRT router natively?

I don't fully agree.

Some ./configure script create include files while they run - and they create it by running the binaries created "dynamically".

As they try to run mipsel binaries, they can't set or guess some options properly.
An example of such software is Samba, but not only.
You have to figure out a lot that you have to add something like:

CFG=include/config.h
echo "define HAVE_GETTIMEOFDAY_TZ 1"    >> $CFG
echo "#define USE_SETEUID 1"             >> $CFG
echo "#define HAVE_IFACE_IFCONF 1"       >> $CFG

*after* the ./configure was run.

I guess it's not all, as "smbclient" after such a compilation is still not functional (and yes, samba 3.0.10 package that can be found here is totally broken).

Running make twice here wouldn't help at all, as it's the "./configure" that matters here.

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

Re: compiling on OpenWRT router natively?

While I agree that the running the configure script against the host system will produce incorrect results, I hardly think that compiling entirely on openwrt is really an answer; the resources of the routers tend to be far to limited to be of any practical use. I'd suggest simply fixing the config.h and patching the build process to avoid configure entirely.

configure scripts are rarely written for cross compiling

Re: compiling on OpenWRT router natively?

mbm wrote:

configure scripts are rarely written for cross compiling

Exactly.
A couple of years ago I used to compile stuff on P100 + 16 MB RAM, so I guess a mipsel@200 Mhz with 32 MB RAM would be even faster.

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

Re: compiling on OpenWRT router natively?

mbm wrote:

While I agree that the running the configure script against the host system will produce incorrect results, I hardly think that compiling entirely on openwrt is really an answer; the resources of the routers tend to be far to limited to be of any practical use. I'd suggest simply fixing the config.h and patching the build process to avoid configure entirely.

But it's all about time.

# cat config.h|grep defin|wc -l
354
# cat config.h|grep undef|wc -l
424

It has over 700 values, and in 3 day I needed to compile Samba many times to change many values blindly.
And it still malfunctions, and I don't know what's wrong.

On a router it would probably compile in 3-4 hours or so (against 20 minutes on a PC).

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

Re: compiling on OpenWRT router natively?

Why not use a pre-compiled samba ?

Re: compiling on OpenWRT router natively?

Because there is none.

Well, there is Samba 2.0.10, but it's just ancient, and there in 3.0.10, which is also ancient, but most of all, so buggy and incomplete, that hardly usable (no LDAP support, curious bugs like "PANIC: failed to set gid", it even can't find any network interface!).

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

Re: compiling on OpenWRT router natively?

Assuming your trying to compile an open source firmware on your WRT54G/S router that comes with a 32MB RAM. What will happen during the compilation when RAM resources get exhausted?

Re: compiling on OpenWRT router natively?

It will use swap on a HDD (the router is ASUS WL-500g).

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

Re: compiling on OpenWRT router natively?

Native compilation will most of the time, not solve configure/building problems. If you need a specific update for samba, or a given package, you can also ask us for trying.

Re: compiling on OpenWRT router natively?

Of course it will solve most of the configure problems - because ./configure will run it it's true environment, and therefore, it will be able to guess the values correctly.

I already have samba 3.0.21b compiled with options allowing it to be a true domain controller (LDAP support, ACL support, etc.), and workarounds for problems like lack of NSS in uClibc (Samba needs to resolve system users, and uClibc can't fetch system users from LDAP, only from /etc/passwd + /etc/group).

I also have a kernel compiled with acl + xattr support (actually, ext2/ext3 filesystems), and OpenLDAP (2.3.19) server, too.

For those interested in Unattended installations (http://unattended.sf.net) - it also supports PXE booting via a tftp server, for unattended installations.

So, on ASUS wl-500g (or any other compatibile router to which you can connect a usb stick or a HDD), you can have a compact, but fully functional domain controller for a small office.

With two Windows clients connected, it has even about 15 megs of RAM free.

The only thing that is broken in Samba is smbclient - it's needed for cupsaddsmb for easy printer management:

[2006/02/10 11:36:06, 0] smbd/reply.c:reply_write_and_X(3048)
  reply_write_and_X - large offset (40bd << 32) used and we don't support 64 bit offsets.

Every uploaded file (via smbclient, locally) is cut to 16573 bytes, which is "the first network chunk transmitted from smbclient to the server".

If anyone's interested - let me know - I don't really know if running a Samba domain controller on a OpenWRT-compatibile router is the main interest of OpenWRT developers.

And of course - if anyone can resolve the smbclient problem - is welcome.

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

13

Re: compiling on OpenWRT router natively?

The main reason why I'm opposed to native compilation of packages is that it cannot be reproduced by others without setting up lots of stuff.
Compiling a package natively may give us a working binary, but it produces nothing that can be maintained properly.
Sure, it's more work to cross-compile an application with a broken configure script... but that doesn't mean it's not worth doing it...

Re: compiling on OpenWRT router natively?

Mangoo can you share your Samba 3 compiled version ? i am really interested in it wink

SeDkY

Re: compiling on OpenWRT router natively?

Sure.

You can find it on http://www2.wpkg.org/openwrt/

It's my home PC, so you can only download it from ~9.00 to ~23.00, European time smile

If you have any problems, let me know.

All Samba bugs I mentioned before are fixed.

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

Re: compiling on OpenWRT router natively?

Thanks a lot smile Can you compile LDAP with ldbm support please ?

SeDkY

Re: compiling on OpenWRT router natively?

Hmm, no? smile

Is there a reason why you need to use ldbm?

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

Re: compiling on OpenWRT router natively?

Why not ? wink i need bdb or ldbm for my PDC wink

SeDkY

Re: compiling on OpenWRT router natively?

No, you don't.

You can use any backend just fine.

ldif backend is the most compact perhaps, and thus, the most appropriate for a tiny router.

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

Re: compiling on OpenWRT router natively?

mangoo wrote:

So, on ASUS wl-500g (or any other compatibile router to which you can connect a usb stick or a HDD), you can have a compact, but fully functional domain controller for a small office.

I am seriously interested in that kind of functionality, running a WL-500g myself.

I "only" need an inexpensive, silent central authentication and authorization authority for use by Windows clients and other appliances which support authentication on a Windows domain (NAS system) which does not consume too much energy.

The appliance is supposed to be the PDC, not the BDC, writing vital information to the USB device (memory stick).

Currently I run Oleg's firmware for the WL-500g, but central authentication delivered by OpenWrt + addons would convince me to take the risk of upgrading my router to OpenWRT.

Re: compiling on OpenWRT router natively?

Hi,

It's done already, see previous posts.

You can get Samba, OpenLDAP, and other tools from
http://www2.wpkg.org/openwrt/

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

Re: compiling on OpenWRT router natively?

BTW, if anyone's interested in compiling on OpenWRT router natively - http://www2.wpkg.org/openwrt/devel-tools contains packages like binutils, diffutils, file, gcc, make, and uClibc-devel - everything (hopefully) needed to compile on a router smile

WPKG - http://wpkg.org
Software deployment / silent installation with Samba

Re: compiling on OpenWRT router natively?

I used to do native compilation using the following setup :

1. change the openwrt kernel to support nfs client
2. nfs mount a debian root on another machine
3. chroot into it.

Now I have a fully loaded mipsel debian environment to work with. To compile package for openwrt environment, I just installed the uclibc package in debian and make a few symlink change on openwrt. It is a bit slow and suffers OOM situation(the nfs swap helps) for complex package but otherwise is ok for a number of packages when there was no packaged ipkg.

The hardest part was actually having a mipsel debian environment on a x86. I use debootstrap, running from openwrt to init the chroot environment on the host. Now that qemu support mipsel, may be that is a better choice.

24

Re: compiling on OpenWRT router natively?

a very similar to chimpanzee solution is to setup scratchbox with openwrt
using what they called cputransparency mechanism to automatically dialog between the
router and the host-pc (sbrsh for sbox remote shell) with nfs mount.So one can almost fake native compilation more efficiently (configure works then with true native router,and compile with crosscompilation in jailed nfs_root !).
for info :
http://scratchbox.org/wiki/CrossToolToolchain

25 (edited by Ionic 2006-03-15 15:31:41)

Re: compiling on OpenWRT router natively?

Yeah, I managed it to compile natively on OpenWrt, too. smile
Any informations can be found at http://openedwrt.root24.be

Though, olli, nbd and mbm can me call as stupid as they want to smile