@@ -667,26 +667,37 @@ private function doCompile($compiler_config, &$files, $dir, $CC, $CFLAGS, $CPP,
667
667
$ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Gcc reported files: " . implode (" | " , array_keys ($ gccElements )));
668
668
669
669
if (array_diff (array_keys ($ clangElements ), array_keys ($ gccElements ))) {
670
- $ resp ["old_message " ] = $ output ;
671
670
671
+ $ resp ["old_message " ] = $ output ;
672
672
$ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Mismatch between clang and gcc output found. " );
673
- $ new_clang_output = $ this ->cleanUpClangOutput ($ output , $ compiler_config );
674
-
675
- $ clangElements = $ this ->getClangErrorFileList ($ new_clang_output );
676
- if (array_diff (array_keys ($ clangElements ), array_keys ($ gccElements )))
677
- $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang still reports errors in different files than gcc. " );
678
- else
679
- $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang reports errors in the same files as gcc. " );
680
673
681
- $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Gcc output: " . json_encode ($ avr_output ));
682
- $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang initial output: " . json_encode ($ output ));
683
- $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang reformated output: " . json_encode ($ new_clang_output ));
684
-
685
- $ resp ["message " ] = $ new_clang_output ;
674
+ $ next_clang_output = $ this ->cleanUpClangOutput ($ output , $ compiler_config , "asm " );
675
+
676
+ $ clangElements = $ this ->getClangErrorFileList ($ next_clang_output );
677
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang reported files after removing asm: " . implode (" | " , array_keys ($ clangElements )));
678
+
679
+ if (array_diff (array_keys ($ clangElements ), array_keys ($ gccElements ))) {
680
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Mismatch between clang and gcc output found after removing assembly messages. " );
681
+ $ final_clang_output = $ this ->cleanUpClangOutput ($ next_clang_output , $ compiler_config , "non_asm " );
682
+
683
+ $ clangElements = $ this ->getClangErrorFileList ($ final_clang_output );
684
+ if (array_diff (array_keys ($ clangElements ), array_keys ($ gccElements ))) {
685
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Mismatch between clang and gcc output found after removing assembly/library/core messages. " );
686
+ }else {
687
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang and gcc issue solved. Both report same files with errors. " );
688
+ }
689
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Gcc output: " . json_encode ($ avr_output ));
690
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang initial output: " . json_encode ($ output ));
691
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang reformated output: " . json_encode ($ final_clang_output ));
692
+ $ resp ["message " ] = $ final_clang_output ;
693
+ }else {
694
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Gcc output: " . json_encode ($ avr_output ));
695
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang initial output: " . json_encode ($ output ));
696
+ $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang reformated output: " . json_encode ($ next_clang_output ));
697
+ $ resp ["message " ] = $ next_clang_output ;
698
+ }
686
699
}
687
-
688
700
return $ resp ;
689
-
690
701
}
691
702
unset($ output );
692
703
if ($ caching && $ lock_check ){
@@ -1108,7 +1119,7 @@ private function getGccErrorFileList ($avr_output) {
1108
1119
return $ gcc_elements ;
1109
1120
}
1110
1121
1111
- private function cleanUpClangOutput ($ clang_output , $ compiler_config ) {
1122
+ private function cleanUpClangOutput ($ clang_output , $ compiler_config, $ option ) {
1112
1123
1113
1124
$ content_line_array = explode ("\n" , $ clang_output );
1114
1125
@@ -1130,22 +1141,23 @@ private function cleanUpClangOutput ($clang_output, $compiler_config) {
1130
1141
&& strpos ($ line , "note: " ) !== false )) {
1131
1142
1132
1143
if ($ header_found === false ) {
1133
- if (preg_match ('/(\/compiler\.\w+\/libraries\/)/ ' , $ header )
1134
- || strpos ($ header , $ compiler_config ["arduino_cores_dir " ]) !== false
1135
- || (array_key_exists ("external_core_files " , $ compiler_config )
1136
- && strpos ($ header , $ compiler_config ["external_core_files " ]) !== false )
1137
- || strpos ($ header , "note: " ) !== false
1138
- || strpos ($ header , "in asm " ) !== false
1139
- || strpos ($ body , "in asm " ) !== false ) {
1140
-
1141
- if (preg_match ('/(\/compiler\.\w+\/libraries\/)/ ' , $ header ) && $ libFound === false ) {
1144
+ if (($ option == "non_asm " && preg_match ('/(\/compiler\.\w+\/libraries\/)/ ' , $ header )
1145
+ || strpos ($ header , $ compiler_config ["arduino_cores_dir " ]) !== false
1146
+ || (array_key_exists ("external_core_files " , $ compiler_config )
1147
+ && strpos ($ header , $ compiler_config ["external_core_files " ]) !== false )
1148
+ || strpos ($ header , "note: " ) !== false )
1149
+ || ($ option == "asm "
1150
+ && (strpos ($ header , "in asm " ) !== false
1151
+ || strpos ($ body , "in asm " ) !== false ))) {
1152
+
1153
+ if (preg_match ('/(\/compiler\.\w+\/libraries\/)/ ' , $ header ) && $ libFound === false && $ option != "asm " ) {
1142
1154
$ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang reports library issue. " );
1143
1155
$ libFound = true ;
1144
1156
}
1145
1157
if ((strpos ($ header , $ compiler_config ["arduino_cores_dir " ]) !== false
1146
- || (array_key_exists ("external_core_files " , $ compiler_config )
1147
- && strpos ($ header , $ compiler_config ["external_core_files " ]) !== false ))
1148
- && $ coreFound === false ) {
1158
+ || (array_key_exists ("external_core_files " , $ compiler_config )
1159
+ && strpos ($ header , $ compiler_config ["external_core_files " ]) !== false ))
1160
+ && $ coreFound === false && $ option != " asm " ) {
1149
1161
$ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - Clang reports core issue. " );
1150
1162
$ coreFound = true ;
1151
1163
}
@@ -1176,13 +1188,15 @@ private function cleanUpClangOutput ($clang_output, $compiler_config) {
1176
1188
}
1177
1189
1178
1190
if (!array_key_exists ($ key + 1 , $ content_line_array )) {
1179
- if (!preg_match ('/(\/compiler\.\w+\/libraries\/)/ ' , $ header )
1180
- && strpos ($ header , $ compiler_config ["arduino_cores_dir " ]) === false
1181
- && (array_key_exists ("external_core_files " , $ compiler_config )
1182
- && strpos ($ header , $ compiler_config ["external_core_files " ]) === false )
1183
- && strpos ($ header , "note: " ) === false
1184
- && strpos ($ header , "in asm " ) === false
1185
- && strpos ($ body , "in asm " ) === false ) {
1191
+ if ((!preg_match ('/(\/compiler\.\w+\/libraries\/)/ ' , $ header )
1192
+ && strpos ($ header , $ compiler_config ["arduino_cores_dir " ]) === false
1193
+ && (array_key_exists ("external_core_files " , $ compiler_config )
1194
+ && strpos ($ header , $ compiler_config ["external_core_files " ]) === false )
1195
+ && strpos ($ header , "note: " ) === false
1196
+ && $ option == "non_asm " )
1197
+ || ($ option == "asm "
1198
+ && strpos ($ header , "in asm " ) === false
1199
+ && strpos ($ body , "in asm " ) === false )) {
1186
1200
if ($ header != "" && $ body != "" ) {
1187
1201
if (strpos ($ header , "</font></b> " ) == 0 )
1188
1202
$ header = substr_replace ($ header , '' , 0 , 11 );
0 commit comments