Eventmachine 1.2.7 构建失败,Amazon Linux AMI 上的 Ruby 2.5.1 - "rhel fedora"

Eventmachine 1.2.7 build fails with Ruby 2.5.1 on Amazon Linux AMI - "rhel fedora"

在 Amazon linux ami 上安装 eventmachine gem 时遇到问题,在 ruby-2.3.6 上工作正常,在 ruby-2.5.1[ 上中断=18=] 步骤:
gem install eventmachine

注:gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)
错误日志:

Building native extensions. This could take a while...
ERROR:  Error installing eventmachine:
ERROR: Failed to build gem native extension.
current directory: /home/ec2-user/.rvm/gems/ruby-2.5.1/gems/eventmachine-1.2.7/ext
/home/ec2-user/.rvm/rubies/ruby-2.5.1/bin/ruby -r ./siteconf20180724- 
3006-y7es83.rb extconf.rb
checking for -lcrypto... yes
checking for -lssl... yes
checking for openssl/ssl.h... yes

checking for CLOCK_MONOTONIC in time.h... yes
CXXFLAGS=$(cxxflags)

creating Makefile
current directory: /home/ec2-user/.rvm/gems/ruby 2.5.1/gems/eventmachine-1.2.7/ext
make "DESTDIR=" clean
current directory: /home/ec2-user/.rvm/gems/ruby- 
2.5.1/gems/eventmachine-1.2.7/ext
make "DESTDIR="

compiling binder.cpp
g++: error: unrecognized command line option ‘-Wmisleading-indentation’
g++: error: unrecognized command line option ‘-Wimplicit-fallthrough=0’
g++: error: unrecognized command line option ‘-Wduplicated-cond’
g++: error: unrecognized command line option ‘-Wrestrict’

make: *** [binder.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/ec2-user/.rvm/gems/ruby-2.5.1/gems/eventmachine-1.2.7 for inspection.
Results logged to /home/ec2-user/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/eventmachine-1.2.7/gem_make.out

这似乎是 AWS 内核更新后 AWS 上的 gcc 和 g++ 版本不匹配的根本原因。解决方法是运行:

sudo yum remove gcc48-c++
sudo yum install gcc72-c++

https://github.com/cowboyd/therubyracer/issues/446