I'm having an issue implementing Dijkstra's algorithm in MIPS (more specifically what I presume to be MIPS R10000 given that I've been told to use the RSIM built into our servers).
Because this is such an intensive project, I was working both on writing it from scratch in MIPS and writing it in C (much easier). Given that I am essentially having issues putting the finishing touches on the code, I wanted to try and cross-compile my C code into compatible MIPS code to see what it is I'm missing with my calls and algorithm.
When I try and run GCC with the -S flag, it certainly spits back Assembly code (now I know it is x86 per Jester), but not the kind that is readable (not that I expected it to be) or compatible with RSIM and my generic makefile.
I've tried using Compiler Explorer, tweaking all of the possible outputs, so I don't think that will solve my issue (unless I'm missing something obvious), and my GCC does not appear to be compatible with any of the march=mips<X> derivatives.
I have tried poking around Buildroot. However, I can't seem to make heads or tails of how to get it to compile and execute, regardless of whether it is actually compatible with RSIM.
How can I cross-compile such that I can cherry-pick the parts that I want to slot into my current implementation?
C code not working with RSIM:
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
Output of gcc -S dijkstra.c
:
.text
.section .rodata
.LC0:
.string "Hello, World!"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
leaq .LC0(%rip), %rdi
movl $0, %eax
call printf@PLT
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0"
.section .note.GNU-stack,"",@progbits
.section .note.gnu.property,"a"
.align 8
.long 1f - 0f
.long 4f - 1f
.long 5
0:
.string "GNU"
1:
.align 8
.long 0xc0000002
.long 3f - 2f
2:
.long 0x3
3:
.align 8
4:
When I run Make
cd ~/Courses/CSCI250/Dijkstras
make
Output:
/home/fac/wrc/bin/rasm -l dijkstra.asm > dijkstra.lst
2 0000 .section .rodata
Info: Unimplemented directive
4 0000 .string "Hello, World!"
Error: Syntax error near label field
7 0000 .type main, @function
Error: Syntax error near label field
10 0000 .cfi_startproc
Error: Syntax error near label field
11 0000 endbr64
Error: Syntax error near label field
12 0000 pushq %rbp
Error: Syntax error near label field
13 0000 .cfi_def_cfa_offset 16
Error: Syntax error near label field
14 0000 .cfi_offset 6, -16
Error: Syntax error near label field
15 0000 movq %rsp, %rbp
Error: Syntax error near label field
16 0000 .cfi_def_cfa_register 6
Error: Syntax error near label field
17 0000 leaq .LC0(%rip), %rdi
Error: Syntax error near label field
18 0000 movl $0, %eax
Error: Syntax error near label field
19 0000 call printf@PLT
Error: Syntax error near label field
20 0000 movl $0, %eax
Error: Syntax error near label field
21 0000 popq %rbp
Error: Syntax error near label field
22 0000 .cfi_def_cfa 7, 8
Error: Syntax error near label field
23 0000 ret
Error: Syntax error near label field
24 0000 .cfi_endproc
Error: Syntax error near label field
26 0000 .size main, .-main
Error: Syntax error near label field
27 0000 .ident "GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0"
Error: Syntax error near label field
28 0000 .section .note.GNU-stack,"",@progbits
Info: Unimplemented directive
Error: Syntax error near comment field
29 0000 .section .note.gnu.property,"a"
Info: Unimplemented directive
Error: Syntax error near comment field
31 0000 .long 1f - 0f
Error: Syntax error near label field
32 0000 .long 4f - 1f
Error: Syntax error near label field
33 0000 .long 5
Error: Syntax error near label field
34 0000 0:
Error: Syntax error near label field
35 0000 .string "GNU"
Error: Syntax error near label field
36 0000 1:
Error: Syntax error near label field
38 0000 .long 0xc0000002
Error: Syntax error near label field
39 0000 .long 3f - 2f
Error: Syntax error near label field
40 0000 2:
Error: Syntax error near label field
41 0000 .long 0x3
Error: Syntax error near label field
42 0000 3:
Error: Syntax error near label field
44 0000 4:
Error: Syntax error near label field
There were 3 informational messages
There were 33 fatal errors
make: *** [Makefile:20: dijkstra.obj] Error 33
When I try to run a specific march on the gcc, I get the following errors:
cd ~/Courses/CSCI250/Dijkstras
gcc -S -march=mips1 dijkstra.c
Output:
cc1: error: bad value (‘mips1’) for ‘-march=’ switch
cc1: note: valid arguments to ‘-march=’ switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client icelake-server cascadelake tigerlake bonnell atom silvermont slm goldmont goldmont-plus tremont knl knm x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 btver1 btver2 native