nim: fix Musl build with new compilers (#48487)

* nim: fix build with new compilers

* narrow condition for disabling warnings

* move flags into offending module

disables warnings also for compiling projects other than the Nim compiler when necessary

* specify different versions pthread modules

* instead patch SysThread type

* adapt patch for old Nim versions

* Specify hypothetical `:@0.19.6` for patch version constraint
This commit is contained in:
Buldram 2025-02-19 23:16:12 -05:00 committed by GitHub
parent e9d8c5767b
commit 81e08167e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -105,9 +105,7 @@ class Nim(Package):
phases = ["build", "install"] phases = ["build", "install"]
def patch(self): def patch(self):
"""Hardcode dependency dynamic library paths into # Hardcode dependency dynamic library paths into wrapper modules using rpath
wrapper modules using rpath."""
def append_rpath(path, libdirs): def append_rpath(path, libdirs):
"""Add a pragma at the end of the file which passes """Add a pragma at the end of the file which passes
rpath with libdirs to the linker when the module is used.""" rpath with libdirs to the linker when the module is used."""
@ -133,6 +131,22 @@ def append_rpath(path, libdirs):
if spec.satisfies("+sqlite"): if spec.satisfies("+sqlite"):
append_rpath("lib/wrappers/sqlite3.nim", spec["sqlite"].libs.directories) append_rpath("lib/wrappers/sqlite3.nim", spec["sqlite"].libs.directories)
# Musl defines SysThread as a struct *pthread_t rather than an unsigned long as glibc does.
if self.spec.satisfies("^[virtuals=libc] musl"):
if self.spec.satisfies("@devel,1.9.3:"):
pthreadModule = "lib/std/private/threadtypes.nim"
elif self.spec.satisfies("@:0.19.6"):
pthreadModule = "lib/system/threads.nim"
else:
pthreadModule = "lib/system/threadlocalstorage.nim"
filter_file(
'header: "<sys/types.h>" .} = distinct culong',
'header: "<sys/types.h>" .} = pointer',
pthreadModule,
string=True,
)
def build(self, spec, prefix): def build(self, spec, prefix):
if spec.satisfies("@devel"): if spec.satisfies("@devel"):
with working_dir("csources_v2"): with working_dir("csources_v2"):