resea icon indicating copy to clipboard operation
resea copied to clipboard

Asking an advice.

Open AlessandroSangiuliano opened this issue 3 years ago • 1 comments

Hello, I know this is not probably the best place to ask, but I started to learn some system programming and I have a kernel that actually just start and set the IDT.

I'm using gcc as cross compiler but I want to switch to clang/llvm I know that ofr its nature clang is a cross compiler so i dont need to recompile it.

The question is: what are the options to make clang to cross compile to x86(_64) bare metal?

Something like -target=i386-none ?

This is needed because obviously when you start to buld a kernel from scratch you are going to run a binary on the bare metal and you don't have any environment yet.

Thank you for the help.

AlessandroSangiuliano avatar Dec 13 '21 12:12 AlessandroSangiuliano

Hi, try clang --target=x86_64 to let it cross-compile. Also, you would be interested in the following options:

clang --target=x86_64 -mcmodel=large -fno-omit-frame-pointer -ffreestanding -fno-builtin -nostdlib -nostdinc \
	-mno-red-zone -mno-mmx -mno-sse -mno-sse2 -mno-avx -mno-avx2 

nuta avatar Dec 13 '21 12:12 nuta