@@ -12,6 +12,11 @@ trait imagemagick
1212{
1313 protected function build (): void
1414 {
15+ $ original_ldflags = $ this ->builder ->arch_ld_flags ;
16+ if (str_contains ($ this ->builder ->arch_ld_flags , '-Wl,--as-needed ' )) {
17+ $ this ->builder ->arch_ld_flags = str_replace ('-Wl,--as-needed ' , '' , $ original_ldflags );
18+ }
19+
1520 $ ac = UnixAutoconfExecutor::create ($ this )
1621 ->optionalLib ('libzip ' , ...ac_with_args ('zip ' ))
1722 ->optionalLib ('libjpeg ' , ...ac_with_args ('jpeg ' ))
@@ -33,9 +38,6 @@ protected function build(): void
3338
3439 // special: linux-static target needs `-static`
3540 $ ldflags = SPCTarget::isStatic () ? '-static -ldl ' : '-ldl ' ;
36- if (str_contains ($ this ->builder ->arch_ld_flags , '-Wl,--as-needed ' )) {
37- $ ldflags = str_replace ('-ldl ' , '-Wl,--no-as-needed -ldl -Wl,--as-needed ' , $ ldflags );
38- }
3941
4042 // special: macOS needs -iconv
4143 $ libs = SPCTarget::getTargetOS () === 'Darwin ' ? '-liconv ' : '' ;
@@ -48,6 +50,8 @@ protected function build(): void
4850
4951 $ ac ->configure ()->make ();
5052
53+ $ this ->builder ->arch_ld_flags = $ original_ldflags ;
54+
5155 $ filelist = [
5256 'ImageMagick.pc ' ,
5357 'ImageMagick-7.Q16HDRI.pc ' ,
0 commit comments