build: fix sigsetjmp issues and ensure required libs on Linux

1. Handle `sigsetjmp` platform differences:
   - Separate `sigsetjmp` linkage to platform-specific files.
   - Use `__sigsetjmp` on Linux to handle `sigsetjmp` being a macro.
   - Maintain original implementation for Darwin.

2. Ensure linking of required libs:
   - Explicitly link against fundamental libs (e.g., libm, libatomic).
   - Address the fact that typical Linux linkers don't link these by
     default.
This commit is contained in:
Aofei Sheng
2024-07-29 08:58:13 +08:00
parent 9dca62ff8b
commit e7d72b6f53
4 changed files with 26 additions and 3 deletions

View File

@@ -356,6 +356,8 @@ func linkMainPkg(ctx *context, pkg *packages.Package, pkgs []*aPackage, llFiles
"-rpath", "$ORIGIN",
"-rpath", "$ORIGIN/../lib",
"-Xlinker", "--gc-sections",
"-lm",
"-latomic",
"-lpthread", // libpthread is built-in since glibc 2.34 (2021-08-01); we need to support earlier versions.
)
}