11:51:42 #startmeeting 11:51:42 Meeting started Fri Jun 25 11:51:42 2010 UTC. The chair is CyrusYzGTt. Information about MeetBot at http://wiki.debian.org/MeetBot. 11:51:42 Useful Commands: #action #agreed #halp #info #idea #link #topic. 11:54:43 UnderstandingDSOLinkChange - FedoraProject http://fedoraproject.org/w/index.php?title=Under... 11:54:43 UnderstandingDSOLinkChange 11:54:43 Understanding the (Proposed) Change to DSO Linking 11:54:43 A quick list of packages that were found to have DSO link issues in mock builds is at DSOLinkBugs 11:54:44 Basics 11:54:46 The default behaviour for ld allows users to 'indirectly' link to required objects/libraries through intermediate objects/libraries. While this is convenient, it can 11:54:51 also be dangerous because it makes your program's dependencies tied to the dependencies of other objects. If those objects ever change their linkages, they 11:54:54 can break your program without any changes to your own code! 11:54:59 For example : 11:54:59 libxml2.so has: 11:55:00 NEEDED Shared library: [libdl.so.2] 11:55:06 NEEDED Shared library: [libz.so.1] 11:55:06 Under the old system, a program that links with libxml2 and uses dlopen need not link with libdl, and a program that links with libxml2 and uses gzopen need 11:55:07 not link with libz. While these programs will work, they will break if libxml2 is ever changed to omit the dependency on libdl/libz. 11:55:10 What's the difference? 11:55:12 For example (courtesy Roland McGrath): 11:55:14 ==> foo1.c <== 11:55:16 #include 11:55:20 extern int foo (); 11:55:22 int 11:55:24 main () 11:55:26 { 11:55:28 printf ("%d\n", foo ()); 11:55:30 } 11:55:32 ==> foo2.c <== 11:55:34 extern int foo (); 11:55:39 int bar () { return foo (); } 11:55:40 ==> foo3.c <== 11:55:40 int foo () { return 0; } 11:55:42 Prepare position-independent code: 11:55:44 gcc -g -fPIC -c foo1.c foo2.c foo3.c 11:55:47 Generate foo3.so: 11:55:50 gcc -shared -o foo3.so foo3.o 11:55:52 Generate foo2.so, linking foo3.so: 11:55:54 gcc -shared -o foo2.so foo2.o foo3.so 11:55:56 The proposed change will affect the next step: Creating foo1. 11:55:58 Current 11:56:00 A call to gcc will succeed qu 11:56:02 What do I do? 11:56:04 If you encounter this error, the error message will prompt you to explicitly link to the DSO that you need. From the foo example, adding foo3.so will get rid of 11:56:07 the error: 11:56:09 gcc -o foo1 foo1.o foo2.so foo3.so -Wl,--rpath-link=. 11:56:11 Example deltarpm 11:56:13 Run fedora-cvs deltarpm or check out a 'devel' version of deltarpm from : 11:56:15 :pserver:anonymous@cvs.fedproject.org:/cvs/pkgs 11:56:17 Go to the devel folder and run 'make srpm' to produce a source rpm. 11:56:22 In /etc/mock, copy the desired fedora-rawhide-*.cfg file to test.cfg. In the test.cfg file, change the root to 'test'. 11:56:24 Add the following to test.cfg: 11:56:26 [ld-test] 11:56:28 name=ld-test 11:56:30 baseurl=http://roland.fedorapeople.org/ld-test/ 11:56:32 enabled=1 11:56:34 gpgcheck=0 11:56:52 (Note that the changes to ld are within gcc-4.4.3-5.fc13 so this step should not be necessary) 11:56:52 This will enable the mock build to pull the latest test version of ld. Next, run the build by executing mock -r /path/to/deltarpm/srpm 11:56:52 The following error should appear in /var/lib/mock/test/result/build.log : 11:56:52 RPM build errors: 11:56:52 /usr/bin/ld.bfd: rpmdumpheader.o: undefined reference to symbol 'Fopen' 11:56:53 /usr/bin/ld.bfd: note: 'Fopen' is defined in DSO /usr/lib/librpmio.so.0 so try adding it to the linker command line 11:56:54 /usr/lib/librpmio.so.0: could not read symbols: Invalid operation 11:56:59 *** /usr/bin/ld: ld behavior mismatch! *** 11:57:00 *** /usr/bin/ld.bfd succeeeded *** 11:57:00 *** /usr/bin/ld.bfd --no-add-needed exits 1 *** 11:57:02 *** arguments: --eh-frame-hdr --build-id -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 -o rpmdumpheader 11:57:03 /usr/lib/gcc/i686-redhat-linux/4.4.2/../../../crt1.o /usr/lib/gcc/i686-redhat-linux/4.4.2/../../../crti.o /usr/lib/gcc/i686-redhat-linux/4.4.2/crtbegin.o 11:57:06 -L/usr/lib/gcc/i686-redhat-linux/4.4.2 -L/usr/lib/gcc/i686-redhat-linux/4.4.2 -L/usr/lib/gcc/i686-redhat-linux/4.4.2/../../.. rpmdumpheader.o -lrpm -lgcc 11:57:09 --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-redhat-linux/4.4.2/crtend.o 11:57:12 /usr/lib/gcc/i686-redhat-linux/4.4.2/../../../crtn.o 11:57:14 collect2: ld returned 1 exit status 11:57:16 make: *** [rpmdumpheader] Error 1 11:57:20 This indicates that deltarpm used /usr/lib/librpmio.so.0 without explicitly linking to it. To fix, add -lrpmio to the gcc command for any binaries that use librpmio. 11:57:23 In deltarpm, this can be done quickly by changing the Makefile: 11:57:25 rpmdumpheader: rpmdumpheader.o 11:57:27 - $(CC) $(LDFLAGS) $^ -lrpm -o $@ 11:57:29 + $(CC) $(LDFLAGS) $^ -lrpm -lrpmio -o $@ 11:57:31 Retrieved from "https://fedoraproject.org/wiki/UnderstandingDSOLinkChange" 11:57:33 @endmeeting 11:57:35 #endmeeting