If you're installing 2.7.1 or older version of ruby on m1 macbook use this command:
CFLAGS="-Wno-error=implicit-function-declaration" rvm install 2.7.1