Sigar is very cool and everything runs out of the box, so I wanted to rebuild from scratch and maybe provide a Gentoo package. But not so fast cowboy:
[cc] /tmp/hyperic-sigar-1.6.0-src/src/os/linux/linux_sigar.c: In function 'sigar_proc_env_get': [cc] /tmp/hyperic-sigar-1.6.0-src/src/os/linux/linux_sigar.c:889: error: 'ARG_MAX' undeclared (first use in this function)
This looks interesting, because limits.h pulls in sys/params.h which includes linux/limits.h and then successfully UNdefines ARG_MAX again because it thinks it knows better:
#ifndef ARG_MAX # define __undef_ARG_MAX #endif #include limits.h #include linux/limits.h #include linux/param.h /* The kernel headers defines ARG_MAX. The value is wrong, though. */ #ifndef __undef_ARG_MAX # undef ARG_MAX # undef __undef_ARG_MAX #endif
..and so I end up with no ARG_MAX. I know that directly defining values from linux/* is bad, but in this case it looks like a valid workaround. Sure enough, adding the following after all includes:
#ifndef ARG_MAX #define ARG_MAX 131072 #endif
..fixes things to build & run fine, as expected.
This is with glibc 2.8_p20080602 - arguably a "testing" version, but since this is Gentoo practically everything is built from source, and this is the very first time I ran into this particular error.
Any other suggestions? Should I file this into JIRA?
thanks for looking into this. AFAIK newer Fedora systems should have glibc 2.8; we had similar problems when compiling the Erlang VM. ;) Btw - just to make sure - I think the original allocation was on the stack. This might end in unhappy ways when the returned value is too large.