Page 1 of 1

compiler-rt without red zone

Posted: Tue Oct 12, 2021 4:20 pm
by nexos
Hello,
I am working on making my OS support Clang. I see no tutorial on how to build compiler-rt with -mno-red-zone, however.

I tried taking matters into my own hands by looking through compiler-rt's build system to figure out how to do this. I theory, this should be easy (just find a place where x86_64 specific C flags can be put and add -mno-red-zone), but compiler-rt's x86 appears to bundle x86_64 and i386, which probably would mess up the build

Any tips on this?

Thanks,
nexos

Re: compiler-rt without red zone

Posted: Wed Oct 13, 2021 2:47 am
by davmac314
For cmake projects I typically run "ccmake ." to show available options (press 't' to toggle advanced options).

For compiler-rt it looks like there are "CMAKE_C_FLAGS" and "CMAKE_CXX_FLAGS" which are standard for C/C++ projects. Your build process with cmake is probably something like:

Code: Select all

mkdir build
cd build
cmake .. -DCMAKE_C_FLAGS=-mno-red-zone -DCMAKE_CXX_FLAGS=-mno-red-zone
make
(edit: I haven't actually tried to build).

Re: compiler-rt without red zone

Posted: Wed Oct 13, 2021 3:01 am
by davmac314
Also, use:

Code: Select all

make VERBOSE=1
... to actually see the compilation commands.

Re: compiler-rt without red zone

Posted: Wed Oct 13, 2021 2:36 pm
by nexos
Thanks, I didn't think of that!