GCC交叉编译器可以';t通过void main()测试

GCC交叉编译器可以';t通过void main()测试,gcc,cross-compiling,Gcc,Cross Compiling,我正在构建一个交叉编译器,将c代码转换为我正在使用的处理器的汇编代码。经过几个小时的工作,我设法让xgcc.exe进行编译,这样我就可以开始让它吐出实际的操作码。但是,我在尝试编译简单的void主代码时遇到了一个障碍: void main(){} 当我运行此命令时,我得到以下内部编译器错误 (call_ins 3 2 5 2 (call (mem SI ("__main") [flags 0x41]) [0 S4 A8]) (const_int 0 [0])) test.c:1 -1 (e

我正在构建一个交叉编译器,将c代码转换为我正在使用的处理器的汇编代码。经过几个小时的工作,我设法让xgcc.exe进行编译,这样我就可以开始让它吐出实际的操作码。但是,我在尝试编译简单的void主代码时遇到了一个障碍:

void main(){}
当我运行此命令时,我得到以下内部编译器错误

(call_ins 3 2 5 2 (call (mem SI ("__main") [flags 0x41]) [0 S4 A8])

(const_int 0 [0])) test.c:1 -1

(expr_list REG_EH_REGION (const_int 0 [0]) (nil)) (nil))

Internal compiler error: in extract_insn, at recog.c: 2109
我已经从一个与我(moxie)类似的工作处理器上复制了一个机器描述符文件,但它仍然会产生相同的错误。应与此错误协作的行是:

(define_expand "call_value"
  [(set (match_operand:SI 0 "memory_operand" "")
        (call (match_operand:SI 1 "memory_operand" "")
         (match_operand:SI 2 "memory_operand" "")))]
  ""
{
  gcc_assert (MEM_P (operands[1]));
})"

但我已经改变了很多方面,我还没有成功。你知道是什么导致了这个错误吗?

经过一系列的黑客攻击,我解决了这个问题:

(define_expand "call"
  [(call (match_operand:SI 0 "memory_operand" "")
        (match_operand 1 "general_operand" ""))]
  ""
{
  gcc_assert (MEM_P (operands[0]));
})


(define_insn "*call"
  [(call (mem:SI (match_operand:SI
          0 "nonmemory_operand" "i,r"))
     (match_operand 1 "" ""))]
  ""
  "@
   call   %0
   call   %0"
)

简而言之,它找不到call指令,因为它不匹配。

不知道这是否能解决您的问题,但是
main
应该具有
int
的返回类型,而不是
void
。坚持使用符合标准的代码可能是一个好的开始,至少tint main只是在编译器中返回一个非特定的segfault。理想情况下,一旦我开始使用void,我就可以知道如何使用int,但如果void都不起作用,那么我就不知道了。