On 12/03/13 22:28, Konstantin Serebryany wrote:
I really think that we need to disable libsanitizer on old systems
until someone volunteers to set up a proper testing process upstream.
If no one volunteers -- no one really needs it.
The right way to do this is to do feature tests rather than just
declaring something to be too old based on a version number. Using
version #s is a decent, but not great fall back (though it is often
easier to writing the appropriate feature tests).
Do you use autoconf upstream? If so, testing for things like the
existence of particular header files is trivial and avoids nonsense like
this entirely:
#if !SANITIZER_ANDROID
+#include <linux/version.h>
+// <linux/perf_event.h> has been added in 2.6.32
+#if LINUX_VERSION_CODE >= 132640
#include <linux/perf_event.h>
#endif
+#endif
This kind of testing is so easy with autoconf that it's just silly.
namespace __sanitizer {
unsigned struct_statfs64_sz = sizeof(struct statfs64);
@@ -75,15 +79,18 @@ CHECK_SIZE_AND_OFFSET(io_event, res);
CHECK_SIZE_AND_OFFSET(io_event, res2);
#if !SANITIZER_ANDROID
+#if LINUX_VERSION_CODE >= 132640
COMPILER_CHECK(sizeof(struct __sanitizer_perf_event_attr) <=
sizeof(struct perf_event_attr));
CHECK_SIZE_AND_OFFSET(perf_event_attr, type);
CHECK_SIZE_AND_OFFSET(perf_event_attr, size);
#endif
+#endif
Couldn't this be done with a test as well. Given header files and the
ability to run the compiler, it should be fairly easy to test for this,
even in cross environments.
COMPILER_CHECK(iocb_cmd_pread == IOCB_CMD_PREAD);
COMPILER_CHECK(iocb_cmd_pwrite == IOCB_CMD_PWRITE);
-#if !SANITIZER_ANDROID
+#if !SANITIZER_ANDROID && LINUX_VERSION_CODE >= 132627
+// IOCB_CMD_PREADV/PWRITEV has been added in 2.6.19
COMPILER_CHECK(iocb_cmd_preadv == IOCB_CMD_PREADV);
COMPILER_CHECK(iocb_cmd_pwritev == IOCB_CMD_PWRITEV);
#endif
Also trivial to do with autoconf.
[ ... ]
But more generally, I'd look real closely at anything including linux/
headers directly and see if it can be reasonably avoided. The
ultimate result will actually be easier maintenance upstream over the
long term.
jeff