diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index e2b4bf999a4d1..42af23d377f39 100755 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -88,6 +88,15 @@ if(APPLE) HAVE_CRASHREPORTER_INFO) endif() +if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + check_include_file(linux/magic.h HAVE_LINUX_MAGIC_H) + if(NOT HAVE_LINUX_MAGIC_H) + # older kernels use split files + check_include_file(linux/nfs_fs.h HAVE_LINUX_NFS_FS_H) + check_include_file(linux/smb.h HAVE_LINUX_SMB_H) + endif() +endif() + # library checks if( NOT PURE_WINDOWS ) check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD) diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index 4b35c7b468739..56fa01ab51208 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -76,7 +76,16 @@ #include #include #elif defined(__linux__) +#if defined(HAVE_LINUX_MAGIC_H) #include +#else +#if defined(HAVE_LINUX_NFS_FS_H) +#include +#endif +#if defined(HAVE_LINUX_SMB_H) +#include +#endif +#endif #include #else #include @@ -346,6 +355,12 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) { static bool is_local_impl(struct STATVFS &Vfs) { #if defined(__linux__) +#ifndef NFS_SUPER_MAGIC +#define NFS_SUPER_MAGIC 0x6969 +#endif +#ifndef SMB_SUPER_MAGIC +#define SMB_SUPER_MAGIC 0x517B +#endif #ifndef CIFS_MAGIC_NUMBER #define CIFS_MAGIC_NUMBER 0xFF534D42 #endif