mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 00:43:54 +08:00
thneed: lookup dlsym offset at compile time (#20019)
old-commit-hash: 1744076514
This commit is contained in:
@@ -3,6 +3,15 @@ lenv = env.Clone()
|
||||
|
||||
libs = [cereal, messaging, common, 'OpenCL', 'SNPE', 'symphony-cpu', 'capnp', 'zmq', 'kj', 'yuv', gpucommon, visionipc]
|
||||
|
||||
def get_dlsym_offset():
|
||||
"""Returns the offset between dlopen and dlsym in libdl.so"""
|
||||
import ctypes
|
||||
libdl = ctypes.PyDLL('libdl.so')
|
||||
dlopen = ctypes.cast(libdl.dlopen, ctypes.c_void_p).value
|
||||
dlsym = ctypes.cast(libdl.dlsym, ctypes.c_void_p).value
|
||||
return dlsym - dlopen
|
||||
|
||||
|
||||
common_src = [
|
||||
"models/commonmodel.cc",
|
||||
"runners/snpemodel.cc",
|
||||
@@ -21,8 +30,9 @@ if arch == "aarch64" or arch == "larch64":
|
||||
libs += ['gnustl_shared'] if arch == "aarch64" else ['pthread', 'dl']
|
||||
|
||||
common_src += thneed_src
|
||||
lenv['CFLAGS'].append("-DUSE_THNEED")
|
||||
dlsym_offset = get_dlsym_offset()
|
||||
lenv['CXXFLAGS'].append("-DUSE_THNEED")
|
||||
lenv['CXXFLAGS'].append(f"-DDLSYM_OFFSET={dlsym_offset}")
|
||||
else:
|
||||
libs += ['pthread']
|
||||
|
||||
@@ -45,6 +55,7 @@ else:
|
||||
|
||||
common_model = lenv.Object(common_src)
|
||||
|
||||
|
||||
# build thneed model
|
||||
if arch == "aarch64" or arch == "larch64":
|
||||
compiler = lenv.Program('thneed/compile', ["thneed/compile.cc" ]+common_model, LIBS=libs)
|
||||
|
||||
Reference in New Issue
Block a user