@@ -296,18 +296,22 @@ function patchLinuxRuntimeRpaths(binaryDir, manifest, libTriplet) {
296296 for ( const entry of fs . readdirSync ( binaryDir , { withFileTypes : true } ) ) {
297297 const filePath = path . join ( binaryDir , entry . name ) ;
298298 if ( entry . isFile ( ) && isElfFile ( filePath ) ) {
299- run ( 'patchelf' , [ '--set-rpath' , executableRpath , filePath ] ) ;
299+ setLinuxRpath ( filePath , executableRpath ) ;
300300 }
301301 }
302302
303303 patchElfTree ( manifest . libDir , '$ORIGIN:$ORIGIN/..:$ORIGIN/../..:$ORIGIN/../../..' ) ;
304304 patchElfTree ( manifest . pluginDir , '$ORIGIN/..' ) ;
305305 patchElfTree ( manifest . binDir , `$ORIGIN/../lib/${ libTriplet } ` ) ;
306306 if ( isElfFile ( manifest . scannerPath ) ) {
307- run ( 'patchelf' , [ '--set-rpath' , `$ORIGIN/../../lib/${ libTriplet } ` , manifest . scannerPath ] ) ;
307+ setLinuxRpath ( manifest . scannerPath , `$ORIGIN/../../lib/${ libTriplet } ` ) ;
308308 }
309309}
310310
311+ function setLinuxRpath ( filePath , rpath ) {
312+ run ( 'patchelf' , [ '--force-rpath' , '--set-rpath' , rpath , filePath ] ) ;
313+ }
314+
311315function patchElfTree ( root , rpath ) {
312316 if ( ! fs . existsSync ( root ) ) {
313317 return ;
@@ -319,7 +323,7 @@ function patchElfTree(root, rpath) {
319323 continue ;
320324 }
321325 if ( entry . isFile ( ) && isElfFile ( entryPath ) ) {
322- run ( 'patchelf' , [ '--set- rpath' , rpath , entryPath ] ) ;
326+ setLinuxRpath ( entryPath , rpath ) ;
323327 }
324328 }
325329}
0 commit comments