r268127 - Add a new warning to notify users of mismatched SDK and deployment target
Chris Bieneman via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 29 22:10:35 PDT 2016
Unless I'm reading the log wrong there doesn't seem to be any error text getting logged.
Any idea what that is about?
-Chris
> On Apr 29, 2016, at 9:49 PM, Sean Silva <chisophugis at gmail.com> wrote:
>
> This breaks the PS4 bots at least. They've been red for hours now.
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast?numbuilds=100
>
>> On Fri, Apr 29, 2016 at 3:28 PM, Chris Bieneman via cfe-commits <cfe-commits at lists.llvm.org> wrote:
>> Author: cbieneman
>> Date: Fri Apr 29 17:28:34 2016
>> New Revision: 268127
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=268127&view=rev
>> Log:
>> Add a new warning to notify users of mismatched SDK and deployment target
>>
>> Summary:
>> This patch adds a new driver warning -Wincompatible-sdk which notifies the user when they are mismatching the version min options and the sysroot.
>>
>> The patch works by checking the sysroot (if present) for an SDK name, then matching that against the target platform. In the case of a mismatch it logs a warning.
>>
>> Reviewers: bob.wilson, rsmith
>>
>> Subscribers: rsmith, edward-san, cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D18088
>>
>> Added:
>> cfe/trunk/test/Driver/incompatible_sysroot.c
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> cfe/trunk/lib/Driver/ToolChains.cpp
>> cfe/trunk/lib/Driver/ToolChains.h
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=268127&r1=268126&r2=268127&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Apr 29 17:28:34 2016
>> @@ -198,6 +198,8 @@ def warn_drv_pch_not_first_include : War
>> "precompiled header '%0' was ignored because '%1' is not first '-include'">;
>> def warn_missing_sysroot : Warning<"no such sysroot directory: '%0'">,
>> InGroup<DiagGroup<"missing-sysroot">>;
>> +def warn_incompatible_sysroot : Warning<"using sysroot for '%0' but targeting '%1'">,
>> + InGroup<DiagGroup<"incompatible-sysroot">>;
>> def warn_debug_compression_unavailable : Warning<"cannot compress debug sections (zlib not installed)">,
>> InGroup<DiagGroup<"debug-compression-unavailable">>;
>> def warn_drv_enabling_rtti_with_exceptions : Warning<
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=268127&r1=268126&r2=268127&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Apr 29 17:28:34 2016
>> @@ -329,6 +329,36 @@ void MachO::AddLinkRuntimeLib(const ArgL
>> }
>> }
>>
>> +StringRef Darwin::getPlatformFamily() const {
>> + switch (TargetPlatform) {
>> + case DarwinPlatformKind::MacOS:
>> + return "MacOSX";
>> + case DarwinPlatformKind::IPhoneOS:
>> + case DarwinPlatformKind::IPhoneOSSimulator:
>> + return "iPhone";
>> + case DarwinPlatformKind::TvOS:
>> + case DarwinPlatformKind::TvOSSimulator:
>> + return "AppleTV";
>> + case DarwinPlatformKind::WatchOS:
>> + case DarwinPlatformKind::WatchOSSimulator:
>> + return "Watch";
>> + }
>> + llvm_unreachable("Unsupported platform");
>> +}
>> +
>> +StringRef Darwin::getSDKName(StringRef isysroot) {
>> + // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk
>> + llvm::sys::path::const_iterator SDKDir;
>> + auto BeginSDK = llvm::sys::path::begin(isysroot);
>> + auto EndSDK = llvm::sys::path::end(isysroot);
>> + for (auto IT = BeginSDK; IT != EndSDK; ++IT) {
>> + StringRef SDK = *IT;
>> + if (SDK.endswith(".sdk"))
>> + return SDK.slice(0, SDK.size() - 4);
>> + }
>> + return "";
>> +}
>> +
>> StringRef Darwin::getOSLibraryNameSuffix() const {
>> switch(TargetPlatform) {
>> case DarwinPlatformKind::MacOS:
>> @@ -540,11 +570,8 @@ void Darwin::AddDeploymentTarget(Derived
>> TvOSTarget.empty() && Args.hasArg(options::OPT_isysroot)) {
>> if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
>> StringRef isysroot = A->getValue();
>> - // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk
>> - size_t BeginSDK = isysroot.rfind("SDKs/");
>> - size_t EndSDK = isysroot.rfind(".sdk");
>> - if (BeginSDK != StringRef::npos && EndSDK != StringRef::npos) {
>> - StringRef SDK = isysroot.slice(BeginSDK + 5, EndSDK);
>> + StringRef SDK = getSDKName(isysroot);
>> + if (SDK.size() > 0) {
>> // Slice the version number out.
>> // Version number is between the first and the last number.
>> size_t StartVer = SDK.find_first_of("0123456789");
>> @@ -697,6 +724,17 @@ void Darwin::AddDeploymentTarget(Derived
>> Platform = WatchOSSimulator;
>>
>> setTarget(Platform, Major, Minor, Micro);
>> +
>> + if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
>> + StringRef SDK = getSDKName(A->getValue());
>> + if (SDK.size() > 0) {
>> + size_t StartVer = SDK.find_first_of("0123456789");
>> + StringRef SDKName = SDK.slice(0, StartVer);
>> + if (!SDKName.startswith(getPlatformFamily()))
>> + getDriver().Diag(diag::warn_incompatible_sysroot)
>> + << SDKName << getPlatformFamily();
>> + }
>> + }
>> }
>>
>> void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args,
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=268127&r1=268126&r2=268127&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains.h Fri Apr 29 17:28:34 2016
>> @@ -496,6 +496,8 @@ protected:
>> return TargetVersion < VersionTuple(V0, V1, V2);
>> }
>>
>> + StringRef getPlatformFamily() const;
>> + static StringRef getSDKName(StringRef isysroot);
>> StringRef getOSLibraryNameSuffix() const;
>>
>> public:
>>
>> Added: cfe/trunk/test/Driver/incompatible_sysroot.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/incompatible_sysroot.c?rev=268127&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/Driver/incompatible_sysroot.c (added)
>> +++ cfe/trunk/test/Driver/incompatible_sysroot.c Fri Apr 29 17:28:34 2016
>> @@ -0,0 +1,12 @@
>> +// RUN: %clang -Wincompatible-sysroot -isysroot SDKs/MacOSX10.9.sdk -mios-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-OSX-IOS %s
>> +// RUN: %clang -Wincompatible-sysroot -isysroot SDKs/iPhoneOS9.2.sdk -mwatchos-version-min=2.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-WATCHOS %s
>> +// RUN: %clang -Wincompatible-sysroot -isysroot SDKs/iPhoneOS9.2.sdk -mtvos-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-TVOS %s
>> +// RUN: %clang -Wincompatible-sysroot -isysroot SDKs/iPhoneSimulator9.2.sdk -mios-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-IOSSIM %s
>> +// RUN: %clang -Wno-incompatible-sysroot -isysroot SDKs/MacOSX10.9.sdk -mios-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-OSX-IOS-DISABLED %s
>> +
>> +int main() { return 0; }
>> +// CHECK-OSX-IOS: warning: using sysroot for 'MacOSX' but targeting 'iPhone'
>> +// CHECK-IOS-WATCHOS: warning: using sysroot for 'iPhoneOS' but targeting 'Watch'
>> +// CHECK-IOS-TVOS: warning: using sysroot for 'iPhoneOS' but targeting 'AppleTV'
>> +// CHECK-IOS-IOSSIM-NOT: warning: using sysroot for '{{.*}}' but targeting '{{.*}}'
>> +// CHECK-OSX-IOS-DISABLED-NOT: warning: using sysroot for '{{.*}}' but targeting '{{.*}}'
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160429/6a479c43/attachment.html>
More information about the cfe-commits
mailing list