In Xcode 11, ld added a new flag called -platform_version that can be used instead of the old -<platform>_version_min flags. The new flag allows Clang to pass the SDK version from the driver to the linker.
This patch adopts the new -platform_version flag in Clang, and starts using it by default, unless a linker version < 520 is passed to the driver.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Driver/ToolChains/Darwin.cpp | ||
---|---|---|
2530 | Doesn't this mean you hit llvm_unreachable when you link catalyst? And this is the default behavior? |
clang/lib/Driver/ToolChains/Darwin.cpp | ||
---|---|---|
2530 | You can't link for macCatalyst with the current master Clang. I will modify the downstream Clang to pass in the right flag though. |
I'm not sure if the detection is working correctly, this is failing on our macOS toolchain bots:
FAIL: Clang :: Driver/darwin-ld-platform-version-ios.c (5284 of 16450) ******************** TEST 'Clang :: Driver/darwin-ld-platform-version-ios.c' FAILED ******************** Script: -- : 'RUN: at line 1'; touch /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-ios.c.tmp.o : 'RUN: at line 3'; /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/clang -target arm64-apple-ios12.3 -isysroot /b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/iPhoneOS13.0.sdk -### /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-ios.c.tmp.o 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/FileCheck /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-ios.c : 'RUN: at line 5'; /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/clang -target x86_64-apple-ios13-simulator -isysroot /b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/iPhoneOS13.0.sdk -### /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-ios.c.tmp.o 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/FileCheck --check-prefix=SIMUL /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-ios.c -- Exit Code: 1 Command Output (stderr): -- /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-ios.c:8:11: error: CHECK: expected string not found in input // CHECK: "-platform_version" "ios" "12.3.0" "13.0" ^ <stdin>:1:1: note: scanning from here Fuchsia clang version 10.0.0 (https://fuchsia.googlesource.com/a/third_party/llvm-project 1a8ff89653d2a80a013701fe927d2d32491bff59) ^ <stdin>:5:141: note: possible intended match here "/usr/bin/ld" "-demangle" "-lto_library" "/b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/lib/libLTO.dylib" "-dynamic" "-arch" "arm64" "-iphoneos_version_min" "12.3.0" "-syslibroot" "/b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/iPhoneOS13.0.sdk" "-o" "a.out" "/b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-ios.c.tmp.o" "-lSystem" "/b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/lib/clang/10.0.0/lib/darwin/libclang_rt.ios.a" ^ -- ******************** Testing: 0.. 10.. 20.. 30 FAIL: Clang :: Driver/darwin-ld-platform-version-macos.c (5286 of 16450) ******************** TEST 'Clang :: Driver/darwin-ld-platform-version-macos.c' FAILED ******************** Script: -- : 'RUN: at line 1'; touch /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-macos.c.tmp.o : 'RUN: at line 3'; /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/clang -target x86_64-apple-macos10.13 -isysroot /b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/MacOSX10.14.sdk -### /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-macos.c.tmp.o 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/FileCheck /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-macos.c : 'RUN: at line 5'; env SDKROOT=/b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/MacOSX10.14.sdk /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/clang -target x86_64-apple-macos10.13.0.1 -mlinker-version=520 -### /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-macos.c.tmp.o 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/FileCheck /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-macos.c : 'RUN: at line 10'; /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/clang -target x86_64-apple-macos10.13 -### /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-macos.c.tmp.o 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/FileCheck --check-prefix=NOSDK /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-macos.c -- Exit Code: 1 Command Output (stderr): -- /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-macos.c:8:11: error: CHECK: expected string not found in input // CHECK: "-platform_version" "macos" "10.13.0" "10.14" ^ <stdin>:1:1: note: scanning from here Fuchsia clang version 10.0.0 (https://fuchsia.googlesource.com/a/third_party/llvm-project 1a8ff89653d2a80a013701fe927d2d32491bff59) ^ <stdin>:5:364: note: possible intended match here "/usr/bin/ld" "-demangle" "-lto_library" "/b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/lib/libLTO.dylib" "-dynamic" "-arch" "x86_64" "-macosx_version_min" "10.13.0" "-syslibroot" "/b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/MacOSX10.14.sdk" "-o" "a.out" "/b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-macos.c.tmp.o" "-lSystem" "/b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/lib/clang/10.0.0/lib/darwin/libclang_rt.osx.a" ^ -- ******************** Testing: 0.. 10.. 20.. 30 FAIL: Clang :: Driver/darwin-ld-platform-version-tvos.c (5287 of 16450) ******************** TEST 'Clang :: Driver/darwin-ld-platform-version-tvos.c' FAILED ******************** Script: -- : 'RUN: at line 1'; touch /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-tvos.c.tmp.o : 'RUN: at line 3'; /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/clang -target arm64-apple-tvos12.3 -isysroot /b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/iPhoneOS13.0.sdk -### /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-tvos.c.tmp.o 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/FileCheck /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-tvos.c : 'RUN: at line 5'; /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/clang -target x86_64-apple-tvos13-simulator -isysroot /b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/iPhoneOS13.0.sdk -### /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-tvos.c.tmp.o 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/FileCheck --check-prefix=SIMUL /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-tvos.c -- Exit Code: 1 Command Output (stderr): -- /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-tvos.c:8:11: error: CHECK: expected string not found in input // CHECK: "-platform_version" "tvos" "12.3.0" "13.0" ^ <stdin>:1:1: note: scanning from here Fuchsia clang version 10.0.0 (https://fuchsia.googlesource.com/a/third_party/llvm-project 1a8ff89653d2a80a013701fe927d2d32491bff59) ^ <stdin>:6:359: note: possible intended match here "/usr/bin/ld" "-demangle" "-lto_library" "/b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/lib/libLTO.dylib" "-dynamic" "-arch" "arm64" "-tvos_version_min" "12.3.0" "-syslibroot" "/b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/iPhoneOS13.0.sdk" "-o" "a.out" "/b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-tvos.c.tmp.o" "-lSystem" ^ -- ******************** Testing: 0.. 10.. 20.. 30 FAIL: Clang :: Driver/darwin-ld-platform-version-watchos.c (5288 of 16450) ******************** TEST 'Clang :: Driver/darwin-ld-platform-version-watchos.c' FAILED ******************** Script: -- : 'RUN: at line 1'; touch /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-watchos.c.tmp.o : 'RUN: at line 3'; /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/clang -target arm64_32-apple-watchos5.2 -isysroot /b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/WatchOS6.0.sdk -### /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-watchos.c.tmp.o 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/FileCheck /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-watchos.c : 'RUN: at line 5'; /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/clang -target x86_64-apple-watchos6-simulator -isysroot /b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/WatchOS6.0.sdk -### /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-watchos.c.tmp.o 2>&1 | /b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/bin/FileCheck --check-prefix=SIMUL /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-watchos.c -- Exit Code: 1 Command Output (stderr): -- /b/s/w/ir/k/llvm-project/clang/test/Driver/darwin-ld-platform-version-watchos.c:8:11: error: CHECK: expected string not found in input // CHECK: "-platform_version" "watchos" "5.2.0" "6.0.0" ^ <stdin>:1:1: note: scanning from here Fuchsia clang version 10.0.0 (https://fuchsia.googlesource.com/a/third_party/llvm-project 1a8ff89653d2a80a013701fe927d2d32491bff59) ^ <stdin>:5:363: note: possible intended match here "/usr/bin/ld" "-demangle" "-lto_library" "/b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/lib/libLTO.dylib" "-dynamic" "-arch" "arm64_32" "-watchos_version_min" "5.2.0" "-syslibroot" "/b/s/w/ir/k/llvm-project/clang/test/Driver/Inputs/WatchOS6.0.sdk" "-o" "a.out" "/b/s/w/ir/k/recipe_cleanup/clangybBdXS/llvm_build_dir/tools/clang/test/Driver/Output/darwin-ld-platform-version-watchos.c.tmp.o" "-lSystem" ^
@phosek Thanks, I think it reproduces on our macOS bots. I'll start fixing it right now.
Looks like HOST_LINK_VERSION is influencing the decision. I should specify the version manually in the tests then.
clang/lib/Driver/ToolChains/Darwin.cpp | ||
---|---|---|
339 | Hi. Just for anyone who isn't on the bugzilla thread: in https://bugs.llvm.org/show_bug.cgi?id=44813 I'd like to reconsider this decision about using the flag by default. It is a breaking change and is inconsistent with the other treatments of Version in this function. What do you all think? Thanks. |
Why version '0' should go through the new path?