Page MenuHomePhabricator

Unbreak the build of compiler-rt on Linux/mips64el
Needs ReviewPublic

Authored by sylvestre.ledru on Fri, Mar 22, 9:53 AM.



Fails with:

/<<BUILDDIR>>/llvm-toolchain-8-8~+rc5/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:72: error: size of array 'assertion_failed__73' is negative

typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]

/<<BUILDDIR>>/llvm-toolchain-8-8~+rc5/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:337:30: note: in expansion of macro 'IMPL_COMPILER_ASSERT'


/<<BUILDDIR>>/llvm-toolchain-8-8~+rc5/projects/compiler-rt/lib/sanitizer_common/ note: in expansion of macro 'COMPILER_CHECK'

COMPILER_CHECK(struct_kernel_stat_sz == sizeof(struct stat));

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFri, Mar 22, 9:53 AM
Herald added subscribers: llvm-commits, Restricted Project, jdoerfert and 5 others. · View Herald Transcript

Not sure what I am doing but it fixes the issue

atanasyan added inline comments.Mon, Mar 25, 7:38 AM

Why do you need this change?


These numbers are sizes of the struct stat for 32 / 64-bit cases. Due the rL301171 32-bit size depends on definitions of the _LARGEFILE_SOURCE and FILE_OFFSET_BITS=64 macros.

I run the following test case on Debian 9 mipsel 64-bit:

$ cat test.c
#include <stdio.h>
#include <sys/stat.h>

int main() {
  printf("%u\n", sizeof(struct stat));

$ gcc -mabi=64 test.c && ./a.out

$ gcc -mabi=32 test.c -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 && ./a.out

Both numbers are the same as in the original version of the sanitizer_platform_limits_posix.h.

I guess that the 144 is sizeof(struct stat) in 32-bit case without proper _LARGEFILE_SOURCE and _FILE_OFFSET_BITS=64 definitions. It looks like the code introduced by the rL301171 does not work in your case.

The 104 looks strange. It means that the size of struct stat in 32-bit case is larger than in the 64-bit one.

I agree that 104 looks strange... but it worked.
As I said, I am no expert in mips64el. :/

How do you build compiler-rt? What OS do yo use?