[PATCH] D101114: [lld-macho] Fix min version check

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 22 14:58:52 PDT 2021


int3 created this revision.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101114

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


Index: lld/test/MachO/invalid/incompatible-arch.s
===================================================================
--- lld/test/MachO/invalid/incompatible-arch.s
+++ 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 different 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 different 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:
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -153,11 +153,11 @@
           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;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101114.339792.patch
Type: text/x-patch
Size: 3060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210422/6af0b2ee/attachment.bin>


More information about the llvm-commits mailing list