Open ptrk8 opened 1 year ago
Sorry for the delay. It is not ready, but I thought it was more ready than that. I will need to go over my branches this week, maybe I missed a merge.
I am also ordering an M1 Mac Mini, so I will have an an aarch64 system to play with soon.
Sorry for the delay. It is not ready, but I thought it was more ready than that. I will need to go over my branches this week, maybe I missed a merge.
No worries! Were you able to find this branch? :)
I am also ordering an M1 Mac Mini, so I will have an an aarch64 system to play with soon.
Exciting! Let me know if you need a hand with testing. I'm pretty keen to have this working on aarch64 mainly because I'd like to use your libcpp
library which uses this libc
implementation by default. In the meantime, I might try building libcpp
with a different libc
implementation.
Is the main outstanding item to ensure all the files in arch/aarch64/src
contain valid aarch64
assembly code or is there more to getting it to work on aarch64
?
Building with clang is fairly broken too
"/usr/bin/clang-16" -cc1as -triple aarch64-none-unknown-eabi -filetype obj -main-file-name crt0.S -target-cpu cortex-a53 -target-feature +v8a -target-feature +crc -target-feature +crypto -target-feature +fp-armv8 -target-feature +neon -target-feature +sha2 -target-feature +aes -I subprojects/libc/src/libc.a.p -I subprojects/libc/src -I ../subprojects/libc/src -I ../subprojects/libc/include -I ../subprojects/libc/src/gdtoa/include -I ../subprojects/libc/arch/aarch64/include -fdebug-compilation-dir=/home/klokik/Dev/Embedded/bareboot-meson/builddir -dwarf-debug-producer "clang version 16.0.6" -I subprojects/libc/src/libc.a.p -I subprojects/libc/src -I ../subprojects/libc/src -I ../subprojects/libc/include -I ../subprojects/libc/src/gdtoa/include -I ../subprojects/libc/arch/aarch64/include -debug-info-kind=constructor -dwarf-version=5 -mrelocation-model pic -object-file-name=/home/klokik/Dev/Embedded/bareboot-meson/builddir/subprojects/libc/src/libc.a.p/.._arch_aarch64_src_crt0.S.o -o subprojects/libc/src/libc.a.p/.._arch_aarch64_src_crt0.S.o /tmp/crt0-ae5319.s
../subprojects/libc/arch/aarch64/src/crt0.S:65:2: error: unknown directive
.syntax unified
^
../subprojects/libc/arch/aarch64/src/crt0.S:74:2: error: unknown directive
.code 32
^
../subprojects/libc/arch/aarch64/src/crt0.S:95:2: error: unknown directive
.fnstart
^
../subprojects/libc/arch/aarch64/src/crt0.S:111:6: error: invalid operand for instruction
ldr r3, .Lstack
^
../subprojects/libc/arch/aarch64/src/crt0.S:112:6: error: invalid operand for instruction
cmp r3, #0
^
../subprojects/libc/arch/aarch64/src/crt0.S:114:2: error: unrecognized instruction mnemonic, did you mean: ldr?
ldreq r3, .LC0
^
../subprojects/libc/arch/aarch64/src/crt0.S:120:10: error: expected compatible register or logical immediate
mov sp, r3
^
../subprojects/libc/arch/aarch64/src/crt0.S:124:6: error: invalid operand for instruction
mrs r2, CPSR
^
../subprojects/libc/arch/aarch64/src/crt0.S:125:6: error: invalid operand for instruction
tst r2, #0x0F
^
../subprojects/libc/arch/aarch64/src/crt0.S:127:6: error: expected writable system register or pstate
msr CPSR_c, #0xD1
^
../subprojects/libc/arch/aarch64/src/crt0.S:128:10: error: expected compatible register or logical immediate
mov sp, r3
^
../subprojects/libc/arch/aarch64/src/crt0.S:129:6: error: invalid operand for instruction
sub sl, sp, #0x1000
^
../subprojects/libc/arch/aarch64/src/crt0.S:131:6: error: invalid operand for instruction
mov r3, sl
^
../subprojects/libc/arch/aarch64/src/crt0.S:132:6: error: expected writable system register or pstate
msr CPSR_c, #0xD7
^
../subprojects/libc/arch/aarch64/src/crt0.S:133:10: error: expected compatible register or logical immediate
mov sp, r3
^
../subprojects/libc/arch/aarch64/src/crt0.S:134:6: error: invalid operand for instruction
sub r3, r3, #0x1000
^
../subprojects/libc/arch/aarch64/src/crt0.S:136:6: error: expected writable system register or pstate
msr CPSR_c, #0xDB
^
../subprojects/libc/arch/aarch64/src/crt0.S:137:10: error: expected compatible register or logical immediate
mov sp, r3
^
../subprojects/libc/arch/aarch64/src/crt0.S:138:6: error: invalid operand for instruction
sub r3, r3, #0x1000
^
../subprojects/libc/arch/aarch64/src/crt0.S:140:6: error: expected writable system register or pstate
msr CPSR_c, #0xD2
^
../subprojects/libc/arch/aarch64/src/crt0.S:141:10: error: expected compatible register or logical immediate
mov sp, r3
^
../subprojects/libc/arch/aarch64/src/crt0.S:142:6: error: invalid operand for instruction
sub r3, r3, #0x2000
^
../subprojects/libc/arch/aarch64/src/crt0.S:144:6: error: expected writable system register or pstate
msr CPSR_c, #0xD3
^
../subprojects/libc/arch/aarch64/src/crt0.S:146:10: error: expected compatible register or logical immediate
mov sp, r3
^
../subprojects/libc/arch/aarch64/src/crt0.S:147:6: error: invalid operand for instruction
sub r3, r3, #0x8000
^
../subprojects/libc/arch/aarch64/src/crt0.S:148:6: error: invalid operand for instruction
bic r3, r3, #0x00FF
^
../subprojects/libc/arch/aarch64/src/crt0.S:149:6: error: invalid operand for instruction
bic r3, r3, #0xFF00
^
../subprojects/libc/arch/aarch64/src/crt0.S:151:6: error: invalid operand for instruction
str r3, [r3, #-4]
^
../subprojects/libc/arch/aarch64/src/crt0.S:152:13: error: vector register expected
ldmdb r3, {sp}^
^
../subprojects/libc/arch/aarch64/src/crt0.S:152:15: error: unknown token in expression
ldmdb r3, {sp}^
^
../subprojects/libc/arch/aarch64/src/crt0.S:152:15: error: invalid operand
ldmdb r3, {sp}^
^
../subprojects/libc/arch/aarch64/src/crt0.S:153:6: error: invalid operand for instruction
orr r2, r2, #0xC0
^
../subprojects/libc/arch/aarch64/src/crt0.S:154:6: error: expected writable system register or pstate
msr CPSR_c, r2
^
../subprojects/libc/arch/aarch64/src/crt0.S:177:6: error: invalid operand for instruction
sub sl, r3, #64 << 10
^
../subprojects/libc/arch/aarch64/src/crt0.S:180:7: error: invalid operand for instruction
movs r0, #0
^
../subprojects/libc/arch/aarch64/src/crt0.S:181:7: error: invalid operand for instruction
movs r1, #0
^
../subprojects/libc/arch/aarch64/src/crt0.S:263:2: error: unknown directive
.cantunwind
^
../subprojects/libc/arch/aarch64/src/crt0.S:264:2: error: unknown directive
.fnend
^
I don't expect Clang to be any different really.
Good news is that I received an m2 machine last week, got it set up, and revived my old branch. Have a couple of last issues to get through but expecting to get initial aarch64 support out sometime this week.
Master now has initial aarch64 support. I have built with XCode's clang, "real" clang, and GCC-13. I haven't tried cross-compilation yet, but I don't anticipate any problems given that it works with GCC on an arm64.
For now, crt0.S is not being built at all. For MacOS, it's not necessary. I'm unclear whether it's really needed on Linux or not - haven't set up a linux environment for testing yet. It would be needed for bare metal, but that would surprise me somewhat if that's what y'all were doing with the arm64 :)
I'm trying to build this libc implementation for aarch64 using the
aarch64-none-elf-gcc
cross-compiler.I modified the
arm.txt
cross-compiler file in the following (quick and dirty) way:I then ran the following command:
And then I ran:
However, I got the following compiler error:
As per the the compiler error, it seems that the assembly code in
crt0.S
is invalid foraarch64
.I then came across the following issues regarding aarch64:
https://github.com/embeddedartistry/libc/issues/133 https://github.com/embeddedartistry/libc/issues/131
Is my understanding correct that this repo isn't ready to be built for aarch64 yet? If it is possible to compile for aarch64, I would really appreciate it if you could let me know how!