Bug 722216

Summary: GCC error while trying to statically link to libc.a
Product: Red Hat Enterprise Linux 6 Reporter: josh.yggdrasil
Component: glibcAssignee: Andreas Schwab <schwab>
Status: CLOSED NOTABUG QA Contact: qe-baseos-tools-bugs
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.1CC: fweimer, mfranc
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-15 06:26:41 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description josh.yggdrasil 2011-07-14 16:22:48 UTC
Description of problem:
GCC (ld) error while passing -static flag for compilation


Version-Release number of selected component (if applicable):
$ gcc --version
gcc (GCC) 4.4.5 20110214 (Red Hat 4.4.5-6)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ld --version
GNU ld version 2.20.51.0.2-5.20.el6 20091009
Copyright 2009 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.


How reproducible:
Every time


Steps to Reproduce:
1.  Make a very simple program, with few or no deps other than libc, this one works;

$ cat hello.c 
#include <stdio.h>

int main(void) 
{
	printf("hello, world.\n");
	return 0;
}

2.  Try to compile the program
$ gcc -static -o hello hello.c


Actual results:
$ gcc -static -o hello hello.c
/usr/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
(and no binary is produced)


Expected results:
$ gcc -static -o hello hello.c
$ ldd hello
        not a dynamic executable
$ ./hello
hello, world.


Additional info:
-libc.a is not in /usr/lib64, but libc_nonshared.a is, as is libc.so

-tried yum whatprovides /usr/lib64/libc.a, but no packages matched

-tried a sym link, from libc.a to libc_shared.a, but that just produced a different linking error...

-this works on prior versions of RH

Comment 2 Andreas Schwab 2011-07-15 06:26:41 UTC
Install glibc-static.