Hello. This patch fixes gcc build problems on the latest OS X 10.10 SDK beta (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61407)
fixincludes/ChangeLog * inclhack.def (darwin14_has_feature): New fix * fixincl.x: Regenerate * tests/base/Availability.h: Added gcc/ChangeLog * config/darwin-c.c (version_as_macro): Added compatibility with OS X 10.10 macro version macro and triplet * config/darwin-driver.c (darwin_find_version_from_kernel): Bumped max kernel version libsanitizer/ChangeLog * sanitizer_common/sanitizer_platform_limits_posix.cc: Fixed 32-bit compatible dirent struct for OS X * sanitizer_common/sanitizer_platform_limits_posix.h: Likewise With regards, Ilya Mikhaltsou diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def index 6a1136c..b536080 100644 --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -4751,4 +4751,33 @@ fix = { test_text = "extern char *\tsprintf();"; }; + +/* + * Fix stdio.h using C++ __has_feature built-in on OS X 10.10 + */ +fix = { + hackname = darwin14_has_feature; + files = Availability.h; + mach = "*-*-darwin14.0*"; + + c_fix = wrap; + c_fix_arg = <<- _HasFeature_ + +/* + * GCC doesn't support __has_feature built-in in C mode and + * using defined(__has_feature) && __has_feature in the same + * macro expression is not valid. So, easiest way is to define + * for this header __has_feature as a macro, returning 0, in case + * it is not defined internally + */ +#ifndef __has_feature +#define __has_feature(x) 0 +#endif + + +_HasFeature_; + + test_text = ''; +}; + /*EOF*/ diff --git a/fixincludes/tests/base/Availability.h b/fixincludes/tests/base/Availability.h new file mode 100644 index 0000000..807c40d --- /dev/null +++ b/fixincludes/tests/base/Availability.h @@ -0,0 +1,29 @@ +/* DO NOT EDIT THIS FILE. + + It has been auto-edited by fixincludes from: + + "fixinc/tests/inc/Availability.h" + + This had to be done to correct non-standard usages in the + original, manufacturer supplied header file. */ + +#ifndef FIXINC_WRAP_AVAILABILITY_H_DARWIN14_HAS_FEATURE +#define FIXINC_WRAP_AVAILABILITY_H_DARWIN14_HAS_FEATURE 1 + + +/* GCC doesn't support __has_feature built-in in C mode and + * using defined(__has_feature) && __has_feature in the same + * macro expression is not valid. So, easiest way is to define + * for this header __has_feature as a macro, returning 0, in case + * it is not defined internally + */ +#ifndef __has_feature +#define __has_feature(x) 0 +#endif + + +#if defined( DARWIN14_HAS_FEATURE_CHECK ) + +#endif /* DARWIN14_HAS_FEATURE_CHECK */ + +#endif /* FIXINC_WRAP_AVAILABILITY_H_DARWIN14_HAS_FEATURE */ diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c index 892ba35..39f795f 100644 --- a/gcc/config/darwin-c.c +++ b/gcc/config/darwin-c.c @@ -572,20 +572,31 @@ find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp) /* Return the value of darwin_macosx_version_min suitable for the __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro, - so '10.4.2' becomes 1040. The lowest digit is always zero. - Print a warning if the version number can't be understood. */ + so '10.4.2' becomes 1040 and '10.10.0' becomes 101000. The lowest + digit is always zero. Print a warning if the version number + can't be understood. */ static const char * version_as_macro (void) { - static char result[] = "1000"; + static char result[7] = "1000"; + int minorDigitIdx; if (strncmp (darwin_macosx_version_min, "10.", 3) != 0) goto fail; if (! ISDIGIT (darwin_macosx_version_min[3])) goto fail; - result[2] = darwin_macosx_version_min[3]; - if (darwin_macosx_version_min[4] != '\0' - && darwin_macosx_version_min[4] != '.') + + minorDigitIdx = 3; + result[2] = darwin_macosx_version_min[minorDigitIdx++]; + if (ISDIGIT(darwin_macosx_version_min[minorDigitIdx])) { + /* Starting with 10.10 numeration for mactro changed */ + result[3] = darwin_macosx_version_min[minorDigitIdx++]; + result[4] = '0'; + result[5] = '0'; + result[6] = '\0'; + } + if (darwin_macosx_version_min[minorDigitIdx] != '\0' + && darwin_macosx_version_min[minorDigitIdx] != '.') goto fail; return result; diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c index 8b6ae93..a115616 100644 --- a/gcc/config/darwin-driver.c +++ b/gcc/config/darwin-driver.c @@ -57,7 +57,7 @@ darwin_find_version_from_kernel (char *new_flag) version_p = osversion + 1; if (ISDIGIT (*version_p)) major_vers = major_vers * 10 + (*version_p++ - '0'); - if (major_vers > 4 + 9) + if (major_vers > 4 + 10) goto parse_failed; if (*version_p++ != '.') goto parse_failed; diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc index a93d38d..6783108 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc @@ -940,8 +940,10 @@ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent)); CHECK_SIZE_AND_OFFSET(dirent, d_ino); -#if SANITIZER_MAC +#if SANITIZER_MAC && ( !defined(__DARWIN_64_BIT_INO_T) || __DARWIN_64_BIT_INO_T) CHECK_SIZE_AND_OFFSET(dirent, d_seekoff); +#elif SANITIZER_MAC +// There is no d_seekoff with non 64-bit ino_t #elif SANITIZER_FREEBSD // There is no 'd_off' field on FreeBSD. #else diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h index dece2d3..c830486 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h @@ -392,12 +392,20 @@ namespace __sanitizer { #endif #if SANITIZER_MAC +# if ! defined(__DARWIN_64_BIT_INO_T) || __DARWIN_64_BIT_INO_T struct __sanitizer_dirent { unsigned long long d_ino; unsigned long long d_seekoff; unsigned short d_reclen; // more fields that we don't care about }; +# else + struct __sanitizer_dirent { + unsigned int d_ino; + unsigned short d_reclen; + // more fields that we don't care about + }; +# endif #elif SANITIZER_FREEBSD struct __sanitizer_dirent { unsigned int d_fileno;