compiler-rt without red zone

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

compiler-rt without red zone

Post 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
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
davmac314
Member
Member
Posts: 121
Joined: Mon Jul 05, 2021 6:57 pm

Re: compiler-rt without red zone

Post 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).
davmac314
Member
Member
Posts: 121
Joined: Mon Jul 05, 2021 6:57 pm

Re: compiler-rt without red zone

Post by davmac314 »

Also, use:

Code: Select all

make VERBOSE=1
... to actually see the compilation commands.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: compiler-rt without red zone

Post by nexos »

Thanks, I didn't think of that!
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Post Reply