compile error

Hi all,

i have been compiling clang for months without problems, until about last week. Since then I can't compile.

usually delete CMakeCache.txt then run
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_C_COMPILER=/usr/local/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/bin/clang++ -DCMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++" -DCMAKE_SHARED_LINKER_FLAGS="-std=c++11 -stdlib=libc++" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_WERROR=OFF -DLLVM_BUILD_TOOLS=ON -DLLVM_BUILD_EXAMPLES=OFF -DCLANG_BUILD_EXAMPLES=OFF -DLLVM_APPEND_VC_REV=ON /Users/Mani/Development/Projects/llvm/source
ln -s $PWD/compile_commands.json /Users/Mani/Development/Projects/llvm/source

and then run
make -j10 ENABLE_OPTIMIZED=1 DISABLE_ASSERTIONS=1

Here is what i get.

[ 15%] [ 16%] Built target clang_rt.x86_64
Built target clang_rt.i386
[ 16%] /Users/Mani/Development/Projects/llvm/source/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc:799:1: error: 'assertion_failed__799'
      declared as an array with a negative size
CHECK_SIZE_AND_OFFSET(dirent, d_ino);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Mani/Development/Projects/llvm/source/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc:726:3: note: expanded from macro
      'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *) NULL)->MEMBER) == \
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Mani/Development/Projects/llvm/source/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:239:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__)
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Mani/Development/Projects/llvm/source/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:245:57: note: expanded from macro
      'IMPL_COMPILER_ASSERT'
    typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
                                                        ^~~~~~~~~~~~~~~
/Users/Mani/Development/Projects/llvm/source/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc:803:1: error: 'assertion_failed__803'
      declared as an array with a negative size
CHECK_SIZE_AND_OFFSET(dirent, d_reclen);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Mani/Development/Projects/llvm/source/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc:728:3: note: expanded from macro
      'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Mani/Development/Projects/llvm/source/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:239:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__)
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Mani/Development/Projects/llvm/source/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:245:57: note: expanded from macro
      'IMPL_COMPILER_ASSERT'
    typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
                                                        ^~~~~~~~~~~~~~~
2 errors generated.
Built target RTLSanCommon.osx
make[2]: *** [projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_posix.cc.o] Error 1
make[1]: *** [projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs….

Anybody know what going on?

Thanks
Emmanuel

Hi!

Hi,

Thanks a lot for your help.

My version of osX is 10.8.4
And the define __DARWIN_64_BIT_INO_T is define to 1.

I hope this help.

The reason I am compiling Address sanitizer is that I might need it is i run into problems while developing.

Thanks again

Emmanuel

Hi Emmanuel!

I found out what the problem was: we defined dirent structure for Mac OS X 10.5, and in your case the runtime was compiled with -mmacosx-version-min=10.7.
This problem should be fixed by r186404.

Hi,

I also encounter this issue and I think your fix will not work.

While it fixes compilation, it introduce a latent bug as now the structure definition in asan no longer match the one readdir expects.

When compiling for 10.6 and later, OS X implicitly replace call to readdir (and other functions) by readdir$INODE64 call which properly handle the 64bit structure, but call to readdir will always use the old structure.

So if using 64 bit version of the dirent struct, ASAN should interpose readdir$INODE64 and not readdir symbol.

Argh, forget my previous comment.

As the OS X interceptor is based on dyld interposition, it uses symbols directly (and not symbol name string), so the compiler should also alias the readdir interceptor and replace it by readdir$INODE64 as expected.

We do not include the OSX library headers directly, so we actually
need to add the suffixes manually.
Until now this was only done for $UNIX2003, but it looks like we'll
have to handle at least $INODE64 as well.