So I don't know if this is a bug with rust codegen or if this is a bug in my code. I recently upgraded to rustc 1.59.0-nightly (b60e32c82 2021-12-30) and switched my kernel to use the x86_64-uknown-none target. I also upgraded some dependencies (I don't think I upgraded log though...). But when it boots now, when it tries to set the logger via log::set_logger or log::set_logger_racy, it immediately triple-faults. Setting the logger is the very first thing the kernel does (its first function call) after taking control of the system and entering kmain, so I'm extremely confused on why this is happening. The disassembly of the code is equally as strange:
0000000000019b10 <kmain>:
19b10: 55 push %rbp
19b11: 41 57 push %r15
19b13: 41 56 push %r14
19b15: 41 55 push %r13
19b17: 41 54 push %r12
19b19: 53 push %rbx
19b1a: 48 81 ec 88 00 00 00 sub $0x88,%rsp
19b21: 48 89 7c 24 40 mov %rdi,0x40(%rsp)
19b26: fa cli
19b27: 4c 8d 35 12 50 ff ff lea -0xafee(%rip),%r14 # eb40 <anon.c31ad24ece4221bbd8799acf4a463560.11.llvm.16454607279314885932+0x77>
19b2e: 48 8d 35 b3 9f 05 00 lea 0x59fb3(%rip),%rsi # 73ae8 <anon.c31ad24ece4221bbd8799acf4a463560.12.llvm.16454607279314885932+0x78>
19b35: 4c 89 f7 mov %r14,%rdi
19b38: ff 15 7a 3f 06 00 call *0x63f7a(%rip) # 7dab8 <_DYNAMIC+0x170> // triple fault occurs here
Is this a bug in Rustc or something else?