File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -2751,7 +2751,7 @@ extension Driver {
27512751 } 
27522752
27532753 // Check that we're one of the known supported targets for sanitizers.
2754-  if  !( targetTriple. isWindows || targetTriple. isDarwin || targetTriple. os ==  . linux)  { 
2754+  if  !( targetTriple. isWindows || targetTriple. isDarwin || targetTriple. os ==  . linux || targetTriple . os  ==   . wasi )  { 
27552755 diagnosticEngine. emit ( 
27562756 . error_unsupported_opt_for_target( 
27572757 arg:  " -sanitize= " , 
Original file line number Diff line number Diff line change @@ -165,8 +165,12 @@ extension WebAssemblyToolchain {
165165
166166 // Delegate to Clang for sanitizers. It will figure out the correct linker
167167 // options.
168-  guard  sanitizers. isEmpty else  { 
169-  throw  Error . sanitizersUnsupportedForTarget ( targetTriple. triple) 
168+  if  linkerOutputType ==  . executable && !sanitizers. isEmpty { 
169+  let  sanitizerNames  =  sanitizers
170+  . map  {  $0. rawValue } 
171+  . sorted ( )  // Sort so we get a stable, testable order
172+  . joined ( separator:  " , " ) 
173+  commandLine. appendFlag ( " -fsanitize= \( sanitizerNames) " ) 
170174 } 
171175
172176 if  parsedOptions. hasArgument ( . profileGenerate)  { 
Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ public final class WebAssemblyToolchain: Toolchain {
146146 targetTriple:  Triple , 
147147 isShared:  Bool 
148148 )  throws  ->  String  { 
149-  throw   Error . sanitizersUnsupportedForTarget ( targetTriple. triple ) 
149+  return   " libclang_rt. \( sanitizer . libraryName ) - \( targetTriple. archName ) .a " 
150150 } 
151151
152152 public  func  platformSpecificInterpreterEnvironmentVariables( env:  [ String  :  String ] , 
                         You can’t perform that action at this time. 
           
                  
0 commit comments