RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1433347 - glibc: Selective static linking of libm.a fails due to unresolved _dl_x86_cpu_features symbol
Summary: glibc: Selective static linking of libm.a fails due to unresolved _dl_x86_cpu...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: glibc
Version: 7.3
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: glibc team
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-03-17 12:46 UTC by Piyush Bhoot
Modified: 2020-04-15 15:31 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-06-22 18:40:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Sourceware 21264 0 P2 RESOLVED Selective static linking of libm.a fails due to unresolved _dl_x86_cpu_features symbol 2020-11-22 09:49:12 UTC

Description Piyush Bhoot 2017-03-17 12:46:04 UTC
Description of problem:

In RHEL 7.3 libm fails to link statically 
Demo program provided

Version-Release number of selected component (if applicable):
glibc-static-2.17-157.el7.x86_64
glibc-devel-2.17-157.el7.x86_64
glibc-2.17-157.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, char **argv)
{
        printf("string:%s\n",argv[1]);
	float input=strtof(argv[1],NULL);
	printf("input:%f\n",input);
        float result;
        result = sin(input);
        printf("%f\n",result);
	return 0;
}


2.  gcc test.c -Wl,-Bstatic -lm -Wl,-Bdynamic -lc 

Actual results:

>gcc test.c -Wl,-Bstatic -lm -Wl,-Bdynamic -lc 
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libm.a(s_sin.o): In function `__cos':
>gcc test.c -Wl,-Bstatic -lm -Wl,-Bdynamic -lc 
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libm.a(s_sin.o): In function `__cos':
(.text+0x4682): undefined reference to `_dl_x86_cpu_features'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libm.a(s_sin.o): In function `__sin':
(.text+0x46b2): undefined reference to `_dl_x86_cpu_features'
collect2: error: ld returned 1 exit status


Expected results:
No error


Additional info:


 RHEL 7.2: works
 RHEL 7.3: does not work

Comment 2 Florian Weimer 2017-03-17 14:32:37 UTC
This is an upstream issue which we incorporated with x86_64-specific math library backports.

Note that static linking is unsupported on Red Hat Enterprise Linux (as glibc-static is in the Optional channels).

Comment 3 Carlos O'Donell 2017-03-17 16:39:22 UTC
(In reply to Piyush Bhoot from comment #0)
> Description of problem:
> 
> In RHEL 7.3 libm fails to link statically 
> Demo program provided
> 
> Version-Release number of selected component (if applicable):
> glibc-static-2.17-157.el7.x86_64
> glibc-devel-2.17-157.el7.x86_64
> glibc-2.17-157.el7.x86_64
> 
> How reproducible:
> Always
> 
> Steps to Reproduce:
> 1.
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <math.h>
> 
> int main(int argc, char **argv)
> {
>         printf("string:%s\n",argv[1]);
> 	float input=strtof(argv[1],NULL);
> 	printf("input:%f\n",input);
>         float result;
>         result = sin(input);
>         printf("%f\n",result);
> 	return 0;
> }
> 
> 
> 2.  gcc test.c -Wl,-Bstatic -lm -Wl,-Bdynamic -lc 
> 
> Actual results:
> 
> >gcc test.c -Wl,-Bstatic -lm -Wl,-Bdynamic -lc 
> /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libm.a(s_sin.o): In
> function `__cos':
> >gcc test.c -Wl,-Bstatic -lm -Wl,-Bdynamic -lc 
> /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libm.a(s_sin.o): In
> function `__cos':
> (.text+0x4682): undefined reference to `_dl_x86_cpu_features'
> /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libm.a(s_sin.o): In
> function `__sin':
> (.text+0x46b2): undefined reference to `_dl_x86_cpu_features'
> collect2: error: ld returned 1 exit status

This is not supported.

You would be mixing a static libm.a with future libc.so.6 and ld.so and that breaks the interdependencies between the core libraries which form "the implemetnation of the C runtime."

Either the entire implementation of the runtime is statically linked or none of it is statically linked. You can't choose to link parts of it statically and not others because each part depends on the other to form a complete implementation. The math library is not a thin you can link against statically, it happens we have a libm.a, but that's an implementation detail.

Please use '-static' for the entire application.

What use case do you have for this?


Note You need to log in before you can comment on or make changes to this bug.