msl: Explicity validate against MSL 1.2

Fixed: tint:1327
Change-Id: I7d2e182f60c42894410500f393a1235d37efe5e1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/71680
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
diff --git a/src/val/msl.cc b/src/val/msl.cc
index de34bdc..61ec4a1 100644
--- a/src/val/msl.cc
+++ b/src/val/msl.cc
@@ -38,10 +38,15 @@
 #ifdef _WIN32
   // On Windows, we should actually be running metal.exe from the Metal
   // Developer Tools for Windows
-  auto res = xcrun("-x", "metal", "-c", "-o", "NUL", file.Path());
+  auto res = xcrun("-x", "metal",        //
+                   "-o", "NUL",          //
+                   "-std=osx-metal1.2",  //
+                   "-c", file.Path());
 #else
-  auto res =
-      xcrun("-sdk", "macosx", "metal", "-o", "/dev/null", "-c", file.Path());
+  auto res = xcrun("-sdk", "macosx", "metal",  //
+                   "-o", "/dev/null",          //
+                   "-std=osx-metal1.2",        //
+                   "-c", file.Path());
 #endif
   if (!res.out.empty()) {
     if (!result.output.empty()) {
diff --git a/src/val/msl_metal.mm b/src/val/msl_metal.mm
index 63b4961..8869bdb 100644
--- a/src/val/msl_metal.mm
+++ b/src/val/msl_metal.mm
@@ -40,8 +40,11 @@
   NSString* source = [NSString stringWithCString:src.c_str()
                                         encoding:NSUTF8StringEncoding];
 
+  MTLCompileOptions* compileOptions = [MTLCompileOptions new];
+  compileOptions.languageVersion = MTLLanguageVersion1_2;
+
   id<MTLLibrary> library = [device newLibraryWithSource:source
-                                                options:nil
+                                                options:compileOptions
                                                   error:&error];
   if (!library) {
     NSString* output = [error localizedDescription];
diff --git a/tools/src/cmd/remote-compile/msl_metal.mm b/tools/src/cmd/remote-compile/msl_metal.mm
index a0b0b5a..2fef251 100644
--- a/tools/src/cmd/remote-compile/msl_metal.mm
+++ b/tools/src/cmd/remote-compile/msl_metal.mm
@@ -38,8 +38,11 @@
   NSString* source = [NSString stringWithCString:src.c_str()
                                         encoding:NSUTF8StringEncoding];
 
+  MTLCompileOptions* compileOptions = [MTLCompileOptions new];
+  compileOptions.languageVersion = MTLLanguageVersion1_2;
+
   id<MTLLibrary> library = [device newLibraryWithSource:source
-                                                options:nil
+                                                options:compileOptions
                                                   error:&error];
   if (!library) {
     NSString* output = [error localizedDescription];