ramosian-glider / sanitizers

0 stars 0 forks source link

Doesn't build on Snow Leopard 10.6 #155

Closed ramosian-glider closed 9 years ago

ramosian-glider commented 9 years ago

Originally reported on Google Code with ID 154

What steps will reproduce the problem?
1. Checkout latest sources (r174596)
2. Build using cmake and clang binaries from (http://www.llvm.org/releases/download.html#3.2)

export DEST_CLANG=/tmp/clang; mkdir cbuild && (cd cbuild && CC=~/clang3.2/bin/clang
CXX=~/clang3.2/bin/clang++ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=OFF
-DCMAKE_INSTALL_PREFIX=$DEST_CLANG ../ && make -j2)

 you get the 2 errors for undefined type :

/Users/devel/llvm/projects/compiler-rt/lib/interception/interception_type_test.cc:23:44:
error: use of undeclared identifier
      'ptrdiff_t'
COMPILER_CHECK(sizeof(PTRDIFF_T) == sizeof(ptrdiff_t));
                                           ^
/Users/devel/llvm/projects/compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:217:51:
note: expanded
      from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__)
                                                  ^
/Users/devel/llvm/projects/compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:223:65:
note: expanded
      from macro 'IMPL_COMPILER_ASSERT'
    typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
                                                                ^
/Users/devel/llvm/projects/compiler-rt/lib/interception/interception_type_test.cc:25:42:
error: unknown type name 'off64_t';
      did you mean 'off_t'?
COMPILER_CHECK(sizeof(OFF64_T) == sizeof(off64_t));
                                         ^
/Users/devel/llvm/projects/compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:217:51:
note: expanded
      from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__)
                                                  ^
/Users/devel/llvm/projects/compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:223:65:
note: expanded
      from macro 'IMPL_COMPILER_ASSERT'
    typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
                                                                ^
/usr/include/sys/types.h:172:25: note: 'off_t' declared here
typedef __darwin_off_t          off_t;

What is the expected output? What do you see instead?

It should compile.

What version of the product are you using? On what operating system?

$ uname -a
Darwin Host.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011;
root:xnu-1504.15.3~1/RELEASE_I386 i386
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.6.8
BuildVersion:   10K549

===========================

Same issue with 'stock' GCC (4.2)

/Users/devel/llvm/projects/compiler-rt/lib/interception/interception_type_test.cc:24:
error: 'ptrdiff_t' was not declared in th
is scope
/Users/devel/llvm/projects/compiler-rt/lib/interception/interception_type_test.cc:26:
error: 'off64_t' was not declared in this
 scope
/Users/devel/llvm/projects/compiler-rt/lib/interception/interception_type_test.cc:24:
error: 'ptrdiff_t' was not declared in th
is scope
/Users/devel/llvm/projects/compiler-rt/lib/interception/interception_type_test.cc:26:
error: 'off64_t' was not declared in this
 scope
/Users/devel/llvm/projects/compiler-rt/lib/interception/interception_type_test.cc:33:
error: size of array 'assertion_failed__3
3' is negative

========= CURRENT SOLUTION =======

change the cmake commandline into :

CC=~/clang3.2/bin/clang CXX=~/clang3.2/bin/clang++ CFLAGS="-D_FILE_OFFSET_BITS=64"
CXXFLAGS="-D_FILE_OFFSET_BITS=64" cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=OFF
-DCMAKE_INSTALL_PREFIX=$DEST_CLANG ../ 

and patch the interception_type_test.cc like this :

Index: lib/interception/interception_type_test.cc
===================================================================
--- lib/interception/interception_type_test.cc  (revision 174596)
+++ lib/interception/interception_type_test.cc  (working copy)
@@ -17,7 +17,12 @@
 #include "interception.h"
 #include <sys/types.h>
 #include <stdint.h>
+#include <stddef.h>

+#if defined(__APPLE__)
+#define off64_t off_t
+#endif
+
 COMPILER_CHECK(sizeof(SIZE_T) == sizeof(size_t));
 COMPILER_CHECK(sizeof(SSIZE_T) == sizeof(ssize_t));
 COMPILER_CHECK(sizeof(PTRDIFF_T) == sizeof(ptrdiff_t));

Reported by mkvtoolnix.build.jonthn on 2013-02-07 09:29:44

ramosian-glider commented 9 years ago

Reported by ramosian.glider on 2013-02-07 09:31:42

ramosian-glider commented 9 years ago
If there is no off64_t on Mac, we should just skip the test.
I hope my latest change fixed this.

Reported by eugenis@google.com on 2013-02-07 09:35:33

ramosian-glider commented 9 years ago
Thanks. With latest ToT (r174701), it works for me

Reported by mkvtoolnix.build.jonthn on 2013-02-08 09:24:09

ramosian-glider commented 9 years ago

Reported by konstantin.s.serebryany on 2013-02-08 09:28:06

ramosian-glider commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:13:40