diff --git a/ruby/ext/google/protobuf_c/extconf.rb b/ruby/ext/google/protobuf_c/extconf.rb
index 4bb49bb..37266d7 100755
--- a/ruby/ext/google/protobuf_c/extconf.rb
+++ b/ruby/ext/google/protobuf_c/extconf.rb
@@ -14,7 +14,8 @@ end
 
 if RUBY_PLATFORM =~ /linux/
   # Instruct the linker to point memcpy calls at our __wrap_memcpy wrapper.
-  $LDFLAGS += " -Wl,-wrap,memcpy"
+  $CFLAGS += " -fno-lto"
+  $LDFLAGS += " -Wl,-wrap,memcpy -fno-lto"
 end
 
 $VPATH << "$(srcdir)/third_party/utf8_range"
