diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -2486,6 +2486,11 @@ options::OPT_fvisibility_inlines_hidden_static_local_var, options::OPT_fno_visibility_inlines_hidden_static_local_var)) CC1Args.push_back("-fvisibility-inlines-hidden-static-local-var"); + + // If no vector library is specified by the user, default to + // Darwin_libsystem_m for iOS based targets. + if (isTargetIOSBased() && !DriverArgs.hasArgNoClaim(options::OPT_fveclib)) + CC1Args.push_back("-fveclib=Darwin_libsystem_m"); } DerivedArgList * diff --git a/clang/test/Driver/darwin-veclib-default.c b/clang/test/Driver/darwin-veclib-default.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/darwin-veclib-default.c @@ -0,0 +1,24 @@ +// Check default vector library options on Darwin platforms. + +// RUN: %clang -target x86_64-apple-darwin -S -### %s -arch x86_64 2>&1 | \ +// RUN: FileCheck --check-prefix CHECK-MACOS %s + +// CHECK-MACOS: "-cc1" +// CHECK-MACOS-NOT: -fveclib + +// RUN: %clang -target arm64-apple-darwinos -S -### %s -arch arm64 2>&1 | \ +// RUN: FileCheck --check-prefix CHECK-IOS-DEFAULT %s + +// RUN: %clang -target arm64-apple-ios -S -### %s -arch arm64 2>&1 | \ +// RUN: FileCheck --check-prefix CHECK-IOS-DEFAULT %s + +// CHECK-IOS-DEFAULT: "-cc1" +// CHECK-IOS-DEFAULT: "-fveclib=Darwin_libsystem_m" + +// RUN: %clang -target arm64-apple-ios -S -### %s -arch arm64 -fveclib=Accelerate 2>&1 | \ +// RUN: FileCheck --check-prefix CHECK-IOS-ACCELERATE %s + +// CHECK-IOS-ACCELERATE: "-cc1" +// CHECK-IOS-ACCELERATE-NOT: "-fveclib=Darwin_libsystem_m" +// CHECK-IOS-ACCELERATE: "-fveclib=Accelerate" +// CHECK-IOS-ACCELERATE-NOT: "-fveclib=Darwin_libsystem_m"