Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 259569

Summary: sys-fs/device-mapper ebuild fails with unresolved symbols with --as-needed and --no-undefined
Product: Gentoo Linux Reporter: James C. Georgas <james.georgas>
Component: New packagesAssignee: Gentoo's Team for Core System packages <base-system>
Severity: normal CC: agk, flameeyes
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 129413    
Attachments: Makefile patch to fix link order
ebuild patch to apply makefile patch

Description James C. Georgas 2009-02-19 08:32:59 UTC
device-mapper ebuild fails with unresolved symbols with --as-needed and --no-undefined

The problem is that the one of the makefiles puts the libraries before the regular objects on the link command line. --as-needed seems to scan the command line from left to right, so it ends up stripping out all the libraries that the regular objects reference. Luckily, I have --no-undefined in my linker options, and this caught the problem.

Here is a patch for, which fixes the problem, and also a patch for the device-mapper-1.02.28.ebuild, to apply the patch.

Reproducible: Always

Steps to Reproduce:
1. add --as-needed and --no-undefined to your linker options
2. emerge device-mapper
3. observe stream of undefined reference errors.

Actual Results:  
emerge fails with unsuccessful link step for

Expected Results:  
successful emerge

Not sure if this is a bug in the makefile or in the linker. Maybe --as-needed shouldn't be so picky about the order. Either way, it's gotta go upstream. In the meantime, these patches should make it work.
Comment 1 James C. Georgas 2009-02-19 08:34:21 UTC
Created attachment 182518 [details, diff]
Makefile patch to fix link order
Comment 2 James C. Georgas 2009-02-19 08:34:57 UTC
Created attachment 182520 [details, diff]
ebuild patch to apply makefile patch
Comment 3 Diego Elio Pettenò (RETIRED) gentoo-dev 2009-02-19 14:42:37 UTC
The patch looks good to me.
Comment 4 Samuli Suominen (RETIRED) gentoo-dev 2009-12-21 13:26:01 UTC
+  21 Dec 2009; Samuli Suominen <>                                                                              
+  device-mapper-1.02.28.ebuild, +files/device-mapper-1.02.28-asneeded.patch:                                                       
+  Fix building with -Wl,--as-needed wrt #259569 by James C. Georgas.