Bug 624279

Summary: programs using __sync_fetch_and_and() do not build
Product: Red Hat Enterprise Linux 5 Reporter: Avi Kivity <avi>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: qe-baseos-tools-bugs
Severity: medium Docs Contact:
Priority: low    
Version: 5.5CC: knoel
Target Milestone: rc   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-08-15 18:42:12 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Avi Kivity 2010-08-15 15:24:24 UTC
Description of problem:

Programs using __sync_fetch_and_and() fail to build with a link error:

# make sync_fetch_and_and
cc    -c -o sync_fetch_and_and.o sync_fetch_and_and.c
cc   sync_fetch_and_and.o   -o sync_fetch_and_and
sync_fetch_and_and.o: In function `f':
sync_fetch_and_and.c:(.text+0x15): undefined reference to `__sync_fetch_and_add_4'
collect2: ld returned 1 exit status
make: *** [sync_fetch_and_and] Error 1


Version-Release number of selected component (if applicable):
gcc-4.1.2-48.el5

How reproducible:
Always

Steps to Reproduce:
1. 'make sync_fetch_and_and' with the following program:

int f(unsigned *p)
{
  return __sync_fetch_and_and(p, 0);
}

int main(int ac, char **av)
{
  unsigned v = 3;
  f(&v);
  return v;
}
  
Actual results:
/tmp/ccsXNXmr.o: In function `f':
sync_fetch_and_and.c:(.text+0x15): undefined reference to `__sync_fetch_and_and_4'
collect2: ld returned 1 exit status


Expected results:
Clean build

Additional info:
Works as expected with gcc44.

Comment 1 Jakub Jelinek 2010-08-15 18:42:12 UTC
Only i486 and up supports that, so you need to compile with -march=i486 or above.  In RHEL6 we default to -march=i686, so you don't need to pass anything special, but in RHEL5 we default to -march=i386.