Do not use -Ofast.
Use devel/readline instead of readline in the base system.
Use curses for terminfo.

Index: CMakeLists.txt
--- CMakeLists.txt.orig
+++ CMakeLists.txt
@@ -338,7 +338,7 @@ endif()
 if(WIN32 OR ARM OR PPC64LE OR PPC64 OR PPC)
   set(OPT_FLAGS_RELEASE "-O2")
 else()
-  set(OPT_FLAGS_RELEASE "-Ofast")
+  set(OPT_FLAGS_RELEASE "")
 endif()
 
 # BUILD_TAG is used to select the build type to check for a new version
@@ -1177,10 +1177,10 @@ endif()
 elseif(USE_READLINE AND DEPENDS AND NOT MINGW)
-  find_path(Readline_INCLUDE_PATH readline/readline.h)
-  find_library(Readline_LIBRARY readline)
-  find_library(Terminfo_LIBRARY tinfo)
+  find_path(Readline_INCLUDE_PATH ereadline/readline/readline.h)
+  find_library(Readline_LIBRARY ereadline)
+  find_library(Terminfo_LIBRARY curses)
   set(Readline_LIBRARY "${Readline_LIBRARY};${Terminfo_LIBRARY}")
   set(GNU_READLINE_LIBRARY ${Readline_LIBRARY})
   add_definitions(-DHAVE_READLINE)
   set(EPEE_READLINE epee_readline)
 endif()
 