Site Overlay

undefined reference `__stack_chk_fail’ in luasocket build

In recent OpenWRT releases, the build fails because there is a couple of error messages indicating that the luasocket sources contain undefined references to `__stack_chk_fail_local'.

Second best solution

The only effective way I know to get rid of the compile error comes from bug data base of the OpenWRT developers forum. It recommends adding fno-stack-protector option to the CCFLAGS of the luasocket Makefile. To be more precise, the Makefile should be amended directly after the end of the general package definition and before the begin of the description section:

There are two reasons though, why this “bug fix” does not look attractive at all:

  1. As comment #4 in the forum says, it is not a good idea at all to disable a mechanism which prevents people from hacking a device which is intended to operate as a router.
  2. An image produced with the fno-stack-protector bricked my router so badly that I had to solder the memory chip out, reflash the default firmware and resolder it into the router. While it is not sure that the workaround caused the image to brick the router, it cannot be ruled out on the other hand.

Not working: Different linker

An alternative solution on stackoverflow.com suggests gcc using instead of Makefile :

Usually this is a result of calling ld instead of gcc during a build to perform linking. […] Use gcc instead of ld solved the problem.

To do that we change the following line in the luasockets Makefile from…

… to: