--- a/build.sbt
+++ b/build.sbt
@@ -64,7 +64,7 @@
 
 jniGccFlags ++= Seq(
   "-std=c99", "-Wundef", "-Wshadow", "-Wcast-align", "-Wstrict-prototypes", "-Wno-unused-variable",
-  "-Wpointer-arith", "-DZSTD_LEGACY_SUPPORT=4", "-DZSTD_MULTITHREAD=1", "-lpthread", "-flto"
+  "-Wpointer-arith", "-DZSTD_LEGACY_SUPPORT=4", "-DZSTD_MULTITHREAD=1", "-flto=auto", "-ffat-lto-objects"
 )
 
 // compilation on Windows with MSYS/gcc needs extra flags in order
@@ -82,7 +82,7 @@
   else
     // the default is compilation with GCC
     jniGccFlags.value ++ Seq(
-        "-static-libgcc", "-Wl,--version-script=" + PWD + "/libzstd-jni.so.map")
+        "-Wl,--version-script=" + PWD + "/libzstd-jni.so.map")
   )
 
 // Special case the jni platform header on windows (use the one from the repo)
