[lld] aa05439 - [lld-macho] Fix min version check

Jez Ng via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 22 15:25:55 PDT 2021


Author: Jez Ng
Date: 2021-04-22T18:25:44-04:00
New Revision: aa05439c9cde873ba18ae847ac7c23877178a9ca

URL: https://github.com/llvm/llvm-project/commit/aa05439c9cde873ba18ae847ac7c23877178a9ca
DIFF: https://github.com/llvm/llvm-project/commit/aa05439c9cde873ba18ae847ac7c23877178a9ca.diff

LOG: [lld-macho] Fix min version check

We had got it backwards... the minimum version of the target
should be higher than the min version of the object files, presumably
since new platforms are backwards-compatible with older formats.

Fixes PR50078.

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D101114

Added: 
    

Modified: 
    lld/MachO/InputFiles.cpp
    lld/test/MachO/invalid/incompatible-arch.s

Removed: 
    


################################################################################
diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 7c1b3e1cd77d6..b6a776d5ce09a 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -153,11 +153,11 @@ template <class LP> static bool checkCompatibility(const InputFile *input) {
           getPlatformName(config->platform()));
     return false;
   }
-  if (platformInfo->minimum >= config->platformInfo.minimum)
+  if (platformInfo->minimum <= config->platformInfo.minimum)
     return true;
   error(toString(input) + " has version " +
         platformInfo->minimum.getAsString() +
-        ", which is incompatible with target version of " +
+        ", which is newer than target minimum of " +
         config->platformInfo.minimum.getAsString());
   return false;
 }

diff  --git a/lld/test/MachO/invalid/incompatible-arch.s b/lld/test/MachO/invalid/incompatible-arch.s
index 2bd96cbabf14a..9a776bf56219d 100644
--- a/lld/test/MachO/invalid/incompatible-arch.s
+++ b/lld/test/MachO/invalid/incompatible-arch.s
@@ -6,15 +6,17 @@
 # RUN: not %lld -arch x86_64 -lSystem %t/test.o -o /dev/null 2>&1 | FileCheck %s -DFILE=%t/test.o
 # CHECK: error: {{.*}}[[FILE]] has architecture arm64 which is incompatible with target architecture x86_64
 
-# RUN: %lld -dylib  -arch arm64 -platform_version macOS 9.0 11.0 -o %t/out.dylib %t/test.o
+# RUN: %lld -dylib -arch arm64 -platform_version macOS 10.14 10.15 -o %t/out.dylib %t/test.o
 
-# RUN: not %lld -dylib -arch arm64 -platform_version iOS 9.0 11.0  %t/out.dylib  \
+# RUN: not %lld -dylib -arch arm64 -platform_version iOS 9.0 11.0 %t/out.dylib \
 # RUN:  -o /dev/null 2>&1 | FileCheck %s --check-prefix=DYLIB-PLAT
 # DYLIB-PLAT: {{.*}}out.dylib has platform macOS, which is 
diff erent from target platform iOS
 
-# RUN: not %lld -dylib -arch arm64 -platform_version macOS 14.0 15.0  %t/out.dylib  \
+# RUN: %lld -lSystem -dylib -arch arm64 -platform_version macOS 10.14.0 10.15.0 %t/out.dylib -o /dev/null
+
+# RUN: not %lld -lSystem -dylib -arch arm64 -platform_version macOS 10.13.0 10.15.0 %t/out.dylib \
 # RUN:  -o /dev/null 2>&1 | FileCheck %s --check-prefix=DYLIB-VERSION
-# DYLIB-VERSION: {{.*}}out.dylib has version 9.0.0, which is incompatible with target version of 14.0
+# DYLIB-VERSION: {{.*}}out.dylib has version 10.14.0, which is newer than target minimum of 10.13.0
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos10.15.0 %s -o %t/test_x86.o
 
@@ -22,9 +24,11 @@
 # RUN:  -o /dev/null 2>&1 | FileCheck %s --check-prefix=OBJ-PLAT
 # OBJ-PLAT: {{.*}}test_x86.o has platform macOS, which is 
diff erent from target platform iOS
 
-# RUN: not %lld %t/test_x86.o -lSystem -arch x86_64 -platform_version macOS 14.0 15.0 \
+# RUN: %lld %t/test_x86.o -lSystem -arch x86_64 -platform_version macOS 10.15.0 10.15.0 -o /dev/null
+
+# RUN: not %lld %t/test_x86.o -lSystem -arch x86_64 -platform_version macOS 10.14.0 10.15.0 \
 # RUN:  -o /dev/null 2>&1 | FileCheck %s --check-prefix=OBJ-VERSION
-# OBJ-VERSION: {{.*}}test_x86.o has version 10.15.0, which is incompatible with target version of 14.0
+# OBJ-VERSION: {{.*}}test_x86.o has version 10.15.0, which is newer than target minimum of 10.14.0
 
 .globl _main
 _main:


        


More information about the llvm-commits mailing list