@@ -279,14 +279,10 @@ object LLVMRunner extends Runner[String] {
279
279
280
280
override def includes (path : File ): List [File ] = List (path / " .." / " llvm" )
281
281
282
- lazy val clangCmd = discoverExecutable(List (" clang-18" , " clang" ), List (" --version" ))
283
- lazy val llcCmd = discoverExecutable(List (" llc-18" , " llc" ), List (" --version" ))
284
- lazy val optCmd = discoverExecutable(List (" opt-18" , " opt" ), List (" --version" ))
282
+ lazy val clangCmd = discoverExecutable(List (" clang-20" , " clang-19" , " clang-18" , " clang" ), List (" --version" ))
285
283
286
284
def checkSetup (): Either [String , Unit ] =
287
285
clangCmd.getOrElseAborting { return Left (" Cannot find clang. This is required to use the LLVM backend." ) }
288
- llcCmd.getOrElseAborting { return Left (" Cannot find llc. This is required to use the LLVM backend." ) }
289
- optCmd.getOrElseAborting { return Left (" Cannot find opt. This is required to use the LLVM backend." ) }
290
286
Right (())
291
287
292
288
def libuvArgs (using C : Context ): Seq [String ] =
@@ -335,40 +331,33 @@ object LLVMRunner extends Runner[String] {
335
331
336
332
def missing (cmd : String ) = C .abort(s " Cannot find ${cmd}. This is required to use the LLVM backend. " )
337
333
val clang = clangCmd.getOrElse(missing(" clang" ))
338
- val llc = llcCmd.getOrElse(missing(" llc" ))
339
- val opt = optCmd.getOrElse(missing(" opt" ))
340
334
341
335
val clangMainFile = (C .config.libPath / " .." / " llvm" / " main.c" ).unixPath
342
336
val executableFile = basePath
343
337
344
- if (useLTO) {
345
- // Convert to bitcode with aggressive optimizations
346
- exec(opt, llPath, " -O3" , " -o" , bcPath)
347
-
348
- var clangArgs = Seq (clang, clangMainFile, bcPath, " -o" , executableFile) ++ linkedLibraries
349
-
350
- clangArgs ++= Seq (
351
- " -O3" ,
352
- " -flto=full" ,
353
- " -Wno-override-module"
354
- )
355
-
356
- if (C .config.native()) {
357
- clangArgs :+= " -march=native"
358
- }
338
+ var clangArgs = Seq (clang, llPath, clangMainFile, " -Wno-override-module" , " -o" , executableFile)
339
+ ++ linkedLibraries
359
340
360
- exec( clangArgs : _* )
361
- } else {
362
- exec(opt, llPath, " -O2 " , " -o " , bcPath)
341
+ if ( C .config.native()) {
342
+ clangArgs ++= Seq ( " -march=native " )
343
+ }
363
344
364
- var clangArgs = Seq (clang, clangMainFile, " -o" , executableFile, bcPath, " -Wno-override-module" ) ++ linkedLibraries
345
+ if (C .config.debug()) {
346
+ clangArgs ++= Seq (" -g" , " -Wall" , " -Wextra" , " -Werror" )
347
+ }
365
348
366
- if (C .config.debug()) clangArgs ++= Seq (" -g" , " -Wall" , " -Wextra" , " -Werror" )
367
- if (C .config.valgrind()) clangArgs ++= Seq (" -O0" , " -g" )
368
- else if (C .config.debug()) clangArgs ++= Seq (" -fsanitize=address,undefined" , " -fstack-protector-all" )
349
+ if (C .config.valgrind()) {
350
+ clangArgs ++= Seq (" -Og" , " -g" )
351
+ } else if (C .config.debug()) {
352
+ // these can only be used without valgrind
353
+ clangArgs ++= Seq (" -fsanitize=address,undefined" , " -fstack-protector-all" )
354
+ }
369
355
370
- exec(clangArgs : _* )
356
+ if (useLTO) {
357
+ clangArgs ++= Seq (" -O3" , " -flto=full" )
371
358
}
372
359
360
+ exec(clangArgs : _* )
361
+
373
362
Some (executableFile)
374
363
}
0 commit comments