Fossil SCM
Add rpath when required (eg for NetBSD) so libs in less-common directories are found at runtime
Commit
d45b557c00f6c5a774a3a4aca4f4ea231459d94ee40a16ff272b35e0e359e5e2
Parent
f116b4ed598e8c5…
1 file changed
+26
-1
M
auto.def
+26
-1
| --- auto.def | ||
| +++ auto.def | ||
| @@ -377,11 +377,34 @@ | ||
| 377 | 377 | } else { |
| 378 | 378 | msg-result "no" |
| 379 | 379 | return 0 |
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | - | |
| 382 | +# | |
| 383 | +# Give a runtime search path to every -L directory we added ourselves. | |
| 384 | +# | |
| 385 | +# The probes below look outside the compiler's default paths for various OSs. | |
| 386 | +# A -L will link at build time but the runtime linker needs to find the libs too. | |
| 387 | +# The pkgsrc convention is to add the matching rpath so rtld works. | |
| 388 | +# | |
| 389 | +proc fossil-rpath-ldflags {ldflags} { | |
| 390 | + set rv {} | |
| 391 | + foreach flag $ldflags { | |
| 392 | + if {![string match -L* $flag]} continue | |
| 393 | + set dir [string range $flag 2 end] | |
| 394 | + if {$dir eq "" || ![file isdirectory $dir]} continue | |
| 395 | + set rp "-Wl,-rpath,$dir" | |
| 396 | + if {$rp in $rv} continue | |
| 397 | + if {[cctest -link 1 -cflags $rp]} { | |
| 398 | + lappend rv $rp | |
| 399 | + } | |
| 400 | + } | |
| 401 | + if {[llength $rv]} { | |
| 402 | + define-append EXTRA_LDFLAGS {*}$rv | |
| 403 | + msg-result "Runtime search path: $rv" | |
| 404 | + } | |
| 405 | +} | |
| 383 | 406 | # |
| 384 | 407 | # Check for zlib, using the given location if specified |
| 385 | 408 | # |
| 386 | 409 | proc handle-zlib {} { |
| 387 | 410 | set ::zlibpath [opt-val with-zlib]; # used by downstream tcl tests |
| @@ -429,10 +452,11 @@ | ||
| 429 | 452 | if {$lcheck eq ""} { |
| 430 | 453 | msg-result "Linked to zlib via default library path" |
| 431 | 454 | } else { |
| 432 | 455 | define-append EXTRA_LDFLAGS "$lcheck" |
| 433 | 456 | msg-result "Linked to zlib via $lcheck" |
| 457 | + fossil-rpath-ldflags $lcheck | |
| 434 | 458 | } |
| 435 | 459 | # Keep the flags that worked for every later probe too, in the |
| 436 | 460 | # persistent form of cc-with, as the --with-zlib=tree branch above |
| 437 | 461 | # already does. check-for-openssl appends $::zlib_lib to its own link |
| 438 | 462 | # test, and without these it links a bare -lz against a path autosetup |
| @@ -530,10 +554,11 @@ | ||
| 530 | 554 | } |
| 531 | 555 | if {$found} { |
| 532 | 556 | define FOSSIL_ENABLE_SSL |
| 533 | 557 | define-append EXTRA_CFLAGS $cflags |
| 534 | 558 | define-append EXTRA_LDFLAGS $ldflags |
| 559 | + fossil-rpath-ldflags $ldflags | |
| 535 | 560 | if {[info exists ssllibs]} { |
| 536 | 561 | define-append LIBS $ssllibs |
| 537 | 562 | } else { |
| 538 | 563 | define-append LIBS -lssl -lcrypto |
| 539 | 564 | } |
| 540 | 565 |
| --- auto.def | |
| +++ auto.def | |
| @@ -377,11 +377,34 @@ | |
| 377 | } else { |
| 378 | msg-result "no" |
| 379 | return 0 |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | # |
| 384 | # Check for zlib, using the given location if specified |
| 385 | # |
| 386 | proc handle-zlib {} { |
| 387 | set ::zlibpath [opt-val with-zlib]; # used by downstream tcl tests |
| @@ -429,10 +452,11 @@ | |
| 429 | if {$lcheck eq ""} { |
| 430 | msg-result "Linked to zlib via default library path" |
| 431 | } else { |
| 432 | define-append EXTRA_LDFLAGS "$lcheck" |
| 433 | msg-result "Linked to zlib via $lcheck" |
| 434 | } |
| 435 | # Keep the flags that worked for every later probe too, in the |
| 436 | # persistent form of cc-with, as the --with-zlib=tree branch above |
| 437 | # already does. check-for-openssl appends $::zlib_lib to its own link |
| 438 | # test, and without these it links a bare -lz against a path autosetup |
| @@ -530,10 +554,11 @@ | |
| 530 | } |
| 531 | if {$found} { |
| 532 | define FOSSIL_ENABLE_SSL |
| 533 | define-append EXTRA_CFLAGS $cflags |
| 534 | define-append EXTRA_LDFLAGS $ldflags |
| 535 | if {[info exists ssllibs]} { |
| 536 | define-append LIBS $ssllibs |
| 537 | } else { |
| 538 | define-append LIBS -lssl -lcrypto |
| 539 | } |
| 540 |
| --- auto.def | |
| +++ auto.def | |
| @@ -377,11 +377,34 @@ | |
| 377 | } else { |
| 378 | msg-result "no" |
| 379 | return 0 |
| 380 | } |
| 381 | } |
| 382 | # |
| 383 | # Give a runtime search path to every -L directory we added ourselves. |
| 384 | # |
| 385 | # The probes below look outside the compiler's default paths for various OSs. |
| 386 | # A -L will link at build time but the runtime linker needs to find the libs too. |
| 387 | # The pkgsrc convention is to add the matching rpath so rtld works. |
| 388 | # |
| 389 | proc fossil-rpath-ldflags {ldflags} { |
| 390 | set rv {} |
| 391 | foreach flag $ldflags { |
| 392 | if {![string match -L* $flag]} continue |
| 393 | set dir [string range $flag 2 end] |
| 394 | if {$dir eq "" || ![file isdirectory $dir]} continue |
| 395 | set rp "-Wl,-rpath,$dir" |
| 396 | if {$rp in $rv} continue |
| 397 | if {[cctest -link 1 -cflags $rp]} { |
| 398 | lappend rv $rp |
| 399 | } |
| 400 | } |
| 401 | if {[llength $rv]} { |
| 402 | define-append EXTRA_LDFLAGS {*}$rv |
| 403 | msg-result "Runtime search path: $rv" |
| 404 | } |
| 405 | } |
| 406 | # |
| 407 | # Check for zlib, using the given location if specified |
| 408 | # |
| 409 | proc handle-zlib {} { |
| 410 | set ::zlibpath [opt-val with-zlib]; # used by downstream tcl tests |
| @@ -429,10 +452,11 @@ | |
| 452 | if {$lcheck eq ""} { |
| 453 | msg-result "Linked to zlib via default library path" |
| 454 | } else { |
| 455 | define-append EXTRA_LDFLAGS "$lcheck" |
| 456 | msg-result "Linked to zlib via $lcheck" |
| 457 | fossil-rpath-ldflags $lcheck |
| 458 | } |
| 459 | # Keep the flags that worked for every later probe too, in the |
| 460 | # persistent form of cc-with, as the --with-zlib=tree branch above |
| 461 | # already does. check-for-openssl appends $::zlib_lib to its own link |
| 462 | # test, and without these it links a bare -lz against a path autosetup |
| @@ -530,10 +554,11 @@ | |
| 554 | } |
| 555 | if {$found} { |
| 556 | define FOSSIL_ENABLE_SSL |
| 557 | define-append EXTRA_CFLAGS $cflags |
| 558 | define-append EXTRA_LDFLAGS $ldflags |
| 559 | fossil-rpath-ldflags $ldflags |
| 560 | if {[info exists ssllibs]} { |
| 561 | define-append LIBS $ssllibs |
| 562 | } else { |
| 563 | define-append LIBS -lssl -lcrypto |
| 564 | } |
| 565 |