diff --git a/es2panda/BUILD.gn b/es2panda/BUILD.gn index b6f2a746ef298c1ccd484ea27378ec48d80c3516..82a0d44c8f9595342c74c84c01e8e28a05da4276 100644 --- a/es2panda/BUILD.gn +++ b/es2panda/BUILD.gn @@ -396,12 +396,25 @@ ohos_executable("es2panda") { deps = [ ":es2panda_lib" ] + ldflags = [] if (is_linux) { if (build_public_version) { - ldflags = [ "-static-libstdc++" ] + ldflags += [ "-static-libstdc++" ] } else { libs = [ libcpp_static_lib ] } + + # for statically linking pthread + ldflags += [ + "-Wl,--whole-archive", + "-lrt", + "-lpthread", + "-Wl,--no-whole-archive", + ] + } + + if (!is_mac) { + static_link = true } if (enable_bytecode_optimizer) {