This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -319,9 +319,9 @@ than building it.
319319 && ( build. config . optimized_compiler_builtins ( * target)
320320 || build. config . rust_std_features . contains ( "compiler-builtins-c" ) )
321321 {
322- let is_gcc = is_gcc_compiler ( build. cc ( * target) , build) ;
323- if is_gcc {
324- panic ! ( "GCC does not support building c code for bare wasm" ) ;
322+ let is_clang = is_clang_compiler ( build. cc ( * target) , build) ;
323+ if !is_clang {
324+ panic ! ( "only clang supports building c code for wasm targets " ) ;
325325 }
326326 }
327327
@@ -388,7 +388,15 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
388388 }
389389}
390390
391- fn is_gcc_compiler ( path : PathBuf , build : & Build ) -> bool {
392- let cc_output = command ( & path) . arg ( "--version" ) . run_capture_stdout ( build) . stdout ( ) ;
393- cc_output. contains ( "GCC" )
391+ /// checks if the compiler at `path` is clang by looking at defined macros
392+ fn is_clang_compiler ( path : PathBuf , build : & Build ) -> bool {
393+ let cc_output = command ( & path)
394+ . arg ( "-E" ) // preprocess only
395+ . arg ( "-dM" ) // dump defines
396+ . arg ( "-x" )
397+ . arg ( "c" )
398+ . arg ( "/dev/null" )
399+ . run_capture_stdout ( build)
400+ . stdout ( ) ;
401+ cc_output. contains ( "#define __clang__ 1" )
394402}
You can’t perform that action at this time.
0 commit comments