Bug 1716324

Summary: Module::Build lists the object files after the linker flags, causing underlinking with -Wl,--as-needed
Product: [Fedora] Fedora Reporter: Petr Pisar <ppisar>
Component: perl-ExtUtils-CBuilderAssignee: Jitka Plesnikova <jplesnik>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 38CC: i, jose.p.oliveira.oss, jplesnik, mmaslano, mspacek, paul, perl-devel, ppisar, steve
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Pisar 2019-06-03 08:40:53 UTC
perl-Text-Xslate-3.5.6-5.fc30 lost a dependency on libperl.so since -Wl,--as-needed was added to distribution-wide linker flags:

$ scanelf -n blib/arch/auto/Text/Xslate/Xslate.so 
 TYPE   NEEDED FILE 
ET_DYN libc.so.6 blib/arch/auto/Text/Xslate/Xslate.so 

$ ldd -r  blib/arch/auto/Text/Xslate/Xslate.so
        linux-vdso.so.1 (0x00007fff0d5cb000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f948b9a1000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f948bb8f000)
undefined symbol: Perl_sv_cmp   (blib/arch/auto/Text/Xslate/Xslate.so)
undefined symbol: PL_ppaddr     (blib/arch/auto/Text/Xslate/Xslate.so)
[...]

Xslate.so is built like this:

gcc -lpthread -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -fstack-protector-strong -lperl -o blib/arch/auto/Text/Xslate/Xslate.so lib/Text/Xslate.o src/xslate_methods.o

The cause is that -Wl,--as-needed takes effect when library is supplied and considering only preceding object files and ignoring and following object files. A correct linker command must list all object files before -l flags. Like this:

gcc lib/Text/Xslate.o src/xslate_methods.o -lpthread -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -fstack-protector-strong -lperl -o blib/arch/auto/Text/Xslate/Xslate.so

Either there is bug in perl-Text-Xslate build script or in Module::Build::XSUtil that it uses.

Comment 1 Ben Cotton 2020-04-30 21:51:59 UTC
This message is a reminder that Fedora 30 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 30 on 2020-05-26.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '30'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 30 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 2 Petr Pisar 2020-05-01 06:53:03 UTC
Still issue in F33.

Comment 3 Petr Pisar 2020-05-01 07:04:37 UTC
I read Module::Build::XSUtil, and it does not do anything special regarding the order of object files and linker flags. Module::Build::XSUtil inherits from Module::Build. I checked perl-RPM2 that also uses Module::Build, and the issue manifests there either:

  gcc -lpthread -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -fstack-protector-strong -lperl -o blib/arch/auto/RPM2/RPM2.so lib/RPM2.o -lrpm -lrpmio

I conclude this is a bug in perl-Module-Build.

Comment 4 Paul Howarth 2020-05-14 19:49:10 UTC
I think the problem may actually lie within ExtUtils::CBuilder (which Module::Build delegates the processes of compiling and linking to), and more specifically to the patch we added to get the linking to libperl to happen in the first place. In that patch, $cf->{lddlflags} has "-lperl" appended to it, and that goes before the object files in the linker command. On the other hand, the ExtUtils::CBuilder::Platform::android module already has code to add libperl to the mix, and does it by fiddling with $args{extra_linker_flags} instead. Maybe our patch should do the same?

Comment 5 Fedora Admin user for bugzilla script actions 2020-09-07 14:52:39 UTC
This package has changed maintainer in the Fedora.
Reassigning to the new maintainer of this component.

Comment 6 Ben Cotton 2020-11-03 15:15:18 UTC
This message is a reminder that Fedora 31 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 31 on 2020-11-24.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '31'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 31 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 7 Ben Cotton 2021-02-09 15:09:59 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.

Comment 8 Ben Cotton 2022-05-12 15:34:15 UTC
This message is a reminder that Fedora Linux 34 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 34 on 2022-06-07.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '34'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 34 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 9 Petr Pisar 2022-05-13 08:43:45 UTC
Based on perl-Text-Xslate package in F35, this is still an issue.

Comment 10 Ben Cotton 2022-11-29 16:46:20 UTC
This message is a reminder that Fedora Linux 35 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 35 on 2022-12-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '35'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 35 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 11 Paul Howarth 2022-11-30 08:58:39 UTC
No activity this cycle, presumably still an issue.

Comment 12 Michal Josef Spacek 2023-01-03 16:04:12 UTC
(In reply to Paul Howarth from comment #4)
> On the other hand, the ExtUtils::CBuilder::Platform::android module already has
> code to add libperl to the mix, and does it by fiddling with
> $args{extra_linker_flags} instead. Maybe our patch should do the same?

I think yes.

This issue isn't related to Fedora settings. The same situation is in Debian or a fresh install of the Text::Xslate.
There are many similar issues in Fedora: like perl-Data-MessagePack