1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
|
other: 0.326
KVM: 0.263
debug: 0.261
graphic: 0.260
device: 0.250
permissions: 0.250
files: 0.243
PID: 0.240
boot: 0.239
vnc: 0.238
performance: 0.233
semantic: 0.232
socket: 0.228
network: 0.226
QEMU fails to build on CentOS 5.10 with relocation R_X86_64_PC32 error
lt LINK libcacard.la
/usr/bin/ld: libcacard/.libs/vcard.o: relocation R_X86_64_PC32 against `vcard_buffer_response_delete' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[4]: *** [libcacard.la] Error 1
make[3]: *** [subdir-libcacard] Error 2
I have bisect'd this to:
dcs-xen-53:~/qemu>git-bisect next
00c705fb92bc6e69e955aeac3614e05ca02feacd is the first bad commit
commit 00c705fb92bc6e69e955aeac3614e05ca02feacd
Author: Paolo Bonzini <email address hidden>
Date: Tue May 29 11:40:24 2012 +0200
build: libcacard Makefile cleanups
Build vscclient from toplevel Makefile, limit usage of vpath.
Signed-off-by: Paolo Bonzini <email address hidden>
:100644 100644 a10005a22fe44a107dfec15106960612b43be71f 1d34b9539e9ba47fdb7028ad0569389fa48712b9 M Makefile
:100644 100644 ae3770a5f718742838844f9064be6a7153ac7469 74110dda7e38b8ddae47a53ad4cb6ecf48231fa0 M Makefile.objs
:100644 100644 3dfdf925fdc2c92239b7053a3d4e09687dcc2171 555894db4aa717f15cfc24093d838131f422fc78 M Makefile.target
:100755 100755 e50ad0bb8fc2e331562f3c09e605af6597a143b1 cd5e8b349c137f621d2e9dc516145bc650d977c0 M configure
:040000 040000 160d565b7e551c3248333c9e49f34edb7a30f5e0 008bc3fccda52f78accf9494539ba62bfb1621a0 M libcacard
dcs-xen-53:~/qemu>git bisect log
git bisect start
# bad: [7457fe9541b5162f285454947448d553a5d5a531] Update version for v1.7.0-rc2 release
git bisect bad 7457fe9541b5162f285454947448d553a5d5a531
# good: [ed7ec8400707fe42f4a0f40db2f2d5827ecea789] Merge remote-tracking branch 'bonzini/scsi.2' into staging
git bisect good ed7ec8400707fe42f4a0f40db2f2d5827ecea789
# bad: [1d31fca470648ec66afd8743491bfb5846306341] qemu-barrier: Fix compilation on i386 hosts
git bisect bad 1d31fca470648ec66afd8743491bfb5846306341
# good: [9de36b1a7cf61aa8be365f13c81668b3e19fbc7f] Make -machine/-enable-kvm options merge into a single list
git bisect good 9de36b1a7cf61aa8be365f13c81668b3e19fbc7f
# bad: [3edb8f92e8b5f18797693d8ed9fad3962e11e25d] target-s390x: Pass S390CPU to s390_cpu_restart()
git bisect bad 3edb8f92e8b5f18797693d8ed9fad3962e11e25d
# good: [aecff6924dab0197b6c8f132e44502b25fd98a38] hw/arm_gic: Make gic_reset a sysbus reset function
git bisect good aecff6924dab0197b6c8f132e44502b25fd98a38
# good: [b9531b6eed93c9e1769d6f371c4da5d1f955e0d1] block/qcow2: Add missing GCC_FMT_ATTR to function report_unsupported()
git bisect good b9531b6eed93c9e1769d6f371c4da5d1f955e0d1
# good: [dd86df756e02b684718dd5378725927361b0ad36] Merge remote-tracking branch 'sstabellini/for_1.1_rc3' into staging
git bisect good dd86df756e02b684718dd5378725927361b0ad36
# good: [8ebdf9dcc6036171a9f8bac3fe8dc459725a3e83] sun4u: Use cpu_sparc_init() to obtain SPARCCPU
git bisect good 8ebdf9dcc6036171a9f8bac3fe8dc459725a3e83
# good: [8867aef02e1e5817c72b2e09be4ae952eb0c9d9d] build: move ui/ objects to nested Makefile.objs
git bisect good 8867aef02e1e5817c72b2e09be4ae952eb0c9d9d
# bad: [e8de1ea849176812765bf30514f66c5450a1edc6] target-xtensa: add attributes to helper functions
git bisect bad e8de1ea849176812765bf30514f66c5450a1edc6
# bad: [fa79c914efd35cb60e0bc18512c03690c48b13e2] Merge remote-tracking branch 'bonzini/nested-makefiles-3' into staging
git bisect bad fa79c914efd35cb60e0bc18512c03690c48b13e2
# good: [c353f261946ddbd814b333ae2440712b486977fd] build: move per-target hw/ objects to nested Makefile.objs
git bisect good c353f261946ddbd814b333ae2440712b486977fd
# bad: [25f27a4f7160d077d6992e811021b4bc3a82abc1] build: compile oslib-obj-y once
git bisect bad 25f27a4f7160d077d6992e811021b4bc3a82abc1
# bad: [00c705fb92bc6e69e955aeac3614e05ca02feacd] build: libcacard Makefile cleanups
git bisect bad 00c705fb92bc6e69e955aeac3614e05ca02feacd
# good: [49ac9e0a8cfb737d6da9c0b056c062e3dec0ba45] build: move device tree to per-target Makefile.objs
git bisect good 49ac9e0a8cfb737d6da9c0b056c062e3dec0ba45
On 12/03/13 09:06, Paolo Bonzini wrote:
> Il 03/12/2013 14:25, Stefano Stabellini ha scritto:
>> CC'ing Paolo and xen-devel.
>> The original thread is here:
>>
>> http://marc.info/?l=xen-devel&m=135718999710640
>>
>> On Mon, 2 Dec 2013, Don Slutz wrote:
>>>> Public bug reported:
>>>>
>>>> lt LINK libcacard.la
>>>> /usr/bin/ld: libcacard/.libs/vcard.o: relocation R_X86_64_PC32 against `vcard_buffer_response_delete' can not be used when making a shared object; recompile with -fPIC
>>>> /usr/bin/ld: final link failed: Bad value
>>>> collect2: ld returned 1 exit status
>>>> make[4]: *** [libcacard.la] Error 1
>>>> make[3]: *** [subdir-libcacard] Error 2
> Thanks, I'll try to reproduce. Please send the "make V=1" output for a
> full build in the meanwhile.
Here it is for a full build of:
* 7dc65c0 (HEAD, origin/master, origin/HEAD, master) Open 2.0
development tree
-Don Slutz
> Paolo
On 12/03/13 12:15, Paolo Bonzini wrote:
> Il 03/12/2013 14:25, Stefano Stabellini ha scritto:
>> CC'ing Paolo and xen-devel.
>> The original thread is here:
>>
>> http://marc.info/?l=xen-devel&m=135718999710640
>>
>> On Mon, 2 Dec 2013, Don Slutz wrote:
>>> Public bug reported:
>>>
>>> lt LINK libcacard.la
>>> /usr/bin/ld: libcacard/.libs/vcard.o: relocation R_X86_64_PC32 against `vcard_buffer_response_delete' can not be used when making a shared object; recompile with -fPIC
>>> /usr/bin/ld: final link failed: Bad value
>>> collect2: ld returned 1 exit status
>>> make[4]: *** [libcacard.la] Error 1
>>> make[3]: *** [subdir-libcacard] Error 2
> This is a bug in RHEL5 binutils. Configure with --disable-pie to work
> around it.
Any hints or pointers about the bug in RHEL5 binutils? I can try and
make a patch to auto detect this.
That still fails for (7dc65c0 (HEAD, origin/master, origin/HEAD, master)
Open 2.0 development tree):
...
libtool --mode=link --tag=CC cc -m64 -D_GNU_SOURCE
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes
-Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes
-fno-strict-aliasing -Wendif-labels -Wmissing-include-dirs
-Wnested-externs -Wformat-security -Wformat-y2k -Winit-self
-Wold-style-definition -fstack-protector-all -I/usr/include/libpng12
-I/usr/include/nss3 -I/usr/include/nspr4 -pthread
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
-I/usr/include/pixman-1 -I/home/don/qemu/dtc/libfdt -pthread
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
-I/home/don/qemu/tests -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g
-Wl,--warn-common -m64 -g -o vscclient libcacard/vscclient.o
libcacard.la -Wc,-fstack-protector-all -lrt -pthread -L/lib64
-lgthread-2.0 -lglib-2.0 -lz -L/usr/kerberos/lib64 -lcurl -ldl
-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz -luuid
cc -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings
-Wmissing-prototypes -fno-strict-aliasing -Wendif-labels
-Wmissing-include-dirs -Wnested-externs -Wformat-security -Wformat-y2k
-Winit-self -Wold-style-definition -fstack-protector-all
-I/usr/include/libpng12 -I/usr/include/nss3 -I/usr/include/nspr4
-pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
-I/usr/include/pixman-1 -I/home/don/qemu/dtc/libfdt -pthread
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
-I/home/don/qemu/tests -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g
-Wl,--warn-common -m64 -g -o .libs/vscclient libcacard/vscclient.o
-Wl,-fstack-protector-all -pthread ./.libs/libcacard.so -L/lib64
-L/usr/kerberos/lib64 -lssl3 -lsmime3 -lnss3 -lnssutil3 -lplds4 -lplc4
-lnspr4 -lpthread -lrt -lgthread-2.0 -lglib-2.0 -lcurl -ldl
-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz
-luuid -Wl,--rpath -Wl,/usr/local/lib
/usr/bin/ld: -f may not be used without -shared
collect2: ld returned 1 exit status
make: *** [vscclient] Error 1
Attached is the full "make V=1" output.
Here is the configure output:
dcs-xen-53:~/qemu>rm -rf out/tmp;mkdir out/tmp;pushd
out/tmp;../../configure --disable-pie;make V=1 1>zz1 2>&1;popd
~/qemu/out/tmp ~/qemu
Install prefix /usr/local
BIOS directory /usr/local/share/qemu
binary directory /usr/local/bin
library directory /usr/local/lib
libexec directory /usr/local/libexec
include directory /usr/local/include
config directory /usr/local/etc
local state directory /usr/local/var
Manual directory /usr/local/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path /home/don/qemu
C compiler cc
Host C compiler cc
C++ compiler c++
Objective-C compiler cc
ARFLAGS rv
CFLAGS -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g
QEMU_CFLAGS -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef
-Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -Wendif-labels
-Wmissing-include-dirs -Wnested-externs -Wformat-security -Wformat-y2k
-Winit-self -Wold-style-definition -fstack-protector-all
-I/usr/include/libpng12 -I/usr/include/nss3 -I/usr/include/nspr4
-pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
-I/usr/include/pixman-1 -I$(SRC_PATH)/dtc/libfdt
LDFLAGS -Wl,--warn-common -m64 -g
make make
install install
python python
smbd /usr/sbin/smbd
host CPU x86_64
host big endian no
target list alpha-softmmu arm-softmmu cris-softmmu i386-softmmu
lm32-softmmu m68k-softmmu microblaze-softmmu microblazeel-softmmu
mips-softmmu mips64-softmmu mips64el-softmmu mipsel-softmmu
moxie-softmmu or32-softmmu ppc-softmmu ppc64-softmmu ppcemb-softmmu
s390x-softmmu sh4-softmmu sh4eb-softmmu sparc-softmmu sparc64-softmmu
unicore32-softmmu x86_64-softmmu xtensa-softmmu xtensaeb-softmmu
alpha-linux-user arm-linux-user armeb-linux-user cris-linux-user
i386-linux-user m68k-linux-user microblaze-linux-user
microblazeel-linux-user mips-linux-user mips64-linux-user
mips64el-linux-user mipsel-linux-user mipsn32-linux-user
mipsn32el-linux-user or32-linux-user ppc-linux-user ppc64-linux-user
ppc64abi32-linux-user s390x-linux-user sh4-linux-user sh4eb-linux-user
sparc-linux-user sparc32plus-linux-user sparc64-linux-user
unicore32-linux-user x86_64-linux-user
tcg debug enabled no
gprof enabled no
sparse enabled no
strip binaries yes
profiler no
static build no
-Werror enabled no
pixman system
SDL support yes
GTK support no
curses support yes
curl support yes
mingw32 support no
Audio drivers oss
Block whitelist (rw)
Block whitelist (ro)
VirtFS support yes
VNC support yes
VNC TLS support no
VNC SASL support yes
VNC JPEG support yes
VNC PNG support yes
VNC WS support no
xen support yes
brlapi support no
bluez support no
Documentation yes
GUEST_BASE yes
PIE no
vde support no
Linux AIO support no
ATTR/XATTR support yes
Install blobs yes
KVM support yes
RDMA support no
TCG interpreter no
fdt support yes
preadv support no
fdatasync yes
madvise yes
posix_madvise yes
sigev_thread_id yes
uuid support yes
libcap-ng support no
vhost-net support yes
vhost-scsi support yes
Trace backend nop
Trace output file trace-<pid>
spice support no (/)
rbd support no
xfsctl support no
nss used yes
libusb no
usb net redir no
GLX support yes
libiscsi support no
build guest agent yes
QGA VSS support no
seccomp support no
coroutine backend ucontext
coroutine pool yes
GlusterFS support no
virtio-blk-data-plane no
gcov gcov
gcov enabled no
TPM support no
libssh2 support no
TPM passthrough no
QOM debugging yes
vhdx yes
I bisect'd this to:
dcs-xen-53:~/qemu>git-bisect good
37746c5eacf309fa019ea0fa45f776c36c561457 is the first bad commit
commit 37746c5eacf309fa019ea0fa45f776c36c561457
Author: Marc-André Lureau <email address hidden>
Date: Mon Feb 25 23:31:12 2013 +0100
build-sys: must link with -fstack-protector
It is needed to give that flag to the linker as well, but latest
libtool 2.4.2 still swallows that argument, so let's pass it with
libtool -Wc argument.
qemu-1.4.0/stubs/arch-query-cpu-def.c:6: undefined reference to
`__stack_chk_guard'
Signed-off-by: Marc-André Lureau <email address hidden>
Reviewed-by: Alon Levy <email address hidden>
:100755 100755 33d3354ea30838694020660f5822f551293d7e9a
ee2e7e8ad9b8a23af96e4e404e3f7658efcbe74b M configure
:100644 100644 edc2552f0886c99608b97f85bd932460fa50da73
36aba2de1fa9e0f8acde7640818e94a28dd03c80 M rules.mak
Do you want a bug opened for this?
-Don Slutz
> Paolo
On 12/05/13 10:18, Paolo Bonzini wrote:
> Il 04/12/2013 02:32, Don Slutz ha scritto:
>> Any hints or pointers about the bug in RHEL5 binutils? I can try and
>> make a patch to auto detect this.
> Actually it's RHEL5 GCC:
>
> $ cat f.c
> void *
> f(unsigned char *buf, int len)
> {
> return (void*)0L;
> }
>
>
> void *
> g(unsigned char *buf, int len)
> {
> return f(buf, len);
> }
> $ gcc -shared -o f.so f.c -fPIE -fPIC
> /usr/bin/ld: /tmp/ccQc9els.o: relocation R_X86_64_PC32 against `f' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: final link failed: Bad value
> collect2: ld returned 1 exit status
>
>
> The bug is simply that "-fPIE -fPIC" counts as -fPIE rather than -fPIC:
>
> $ gcc -S -o - f.c -fPIE |grep call
> call f # PC32 relocation
> $ gcc -S -o - f.c -fPIC |grep call
> call f@PLT # PLT32 relocation
>
> On RHEL5:
> $ gcc -S -o - f.c -fPIE -fPIC |grep call
> call f
>
> On RHEL6:
> $ gcc -S -o - f.c -fPIE -fPIC |grep call
> call f@PLT
>
> Paolo
How about this as a patch:
From 282fba086186ff3b8e2b2b15e647df2b58d082dd Mon Sep 17 00:00:00 2001
From: Don Slutz <email address hidden>
Date: Thu, 5 Dec 2013 18:50:18 +0000
Subject: [PATCH] configure: Auto disabling of PIE due to broken toolchain
support (bug #1257099)
See https://bugs.launchpad.net/bugs/1257099
On RHEL5 GCC, you can get 'relocation R_X86_64_PC32' errors from ld.
So disable PIE is this is true.
Signed-off-by: Don Slutz <email address hidden>
---
configure | 43 +++++++++++++++++++++++++++++++++++--------
1 file changed, 35 insertions(+), 8 deletions(-)
diff --git a/configure b/configure
index cf8123b..a51a9dd 100755
--- a/configure
+++ b/configure
@@ -1339,23 +1339,50 @@ if test "$pie" != "no" ; then
# define THREAD
#endif
+void *f(unsigned char *buf, int len);
+void *g(unsigned char *buf, int len);
+
+void *
+f(unsigned char *buf, int len)
+{
+ return (void*)0L;
+}
+
+
+void *
+g(unsigned char *buf, int len)
+{
+ return f(buf, len);
+}
+
+#ifdef PIE
static THREAD int tls_var;
int main(void) { return tls_var; }
+#endif
EOF
- if compile_prog "-fPIE -DPIE" "-pie"; then
- QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
- LDFLAGS="-pie $LDFLAGS"
- pie="yes"
- if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
- LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
+ if compile_prog "-shared -fPIE -fPIC" ""; then
+ if compile_prog "-fPIE -DPIE" "-pie"; then
+ QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
+ LDFLAGS="-pie $LDFLAGS"
+ pie="yes"
+ if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
+ LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
+ fi
+ else
+ if test "$pie" = "yes"; then
+ error_exit "PIE not available due to missing toolchain support"
+ else
+ echo "Disabling PIE due to missing toolchain support"
+ pie="no"
+ fi
fi
else
if test "$pie" = "yes"; then
- error_exit "PIE not available due to missing toolchain support"
+ error_exit "PIE not available due to broken toolchain support"
else
- echo "Disabling PIE due to missing toolchain support"
+ echo "Disabling PIE due to broken toolchain support"
pie="no"
fi
fi
--
1.8.2.1
On 12/06/2013 04:18 AM, Paolo Bonzini wrote:
> $ gcc -shared -o f.so f.c -fPIE -fPIC
> /usr/bin/ld: /tmp/ccQc9els.o: relocation R_X86_64_PC32 against `f' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: final link failed: Bad value
> collect2: ld returned 1 exit status
>
>
> The bug is simply that "-fPIE -fPIC" counts as -fPIE rather than -fPIC:
>
> $ gcc -S -o - f.c -fPIE |grep call
> call f # PC32 relocation
> $ gcc -S -o - f.c -fPIC |grep call
> call f@PLT # PLT32 relocation
The easy workaround is to drop -fPIE when we're adding -fPIC.
r~
On 12/05/13 16:24, Richard Henderson wrote:
> On 12/06/2013 04:18 AM, Paolo Bonzini wrote:
>> $ gcc -shared -o f.so f.c -fPIE -fPIC
>> /usr/bin/ld: /tmp/ccQc9els.o: relocation R_X86_64_PC32 against `f' can not be used when making a shared object; recompile with -fPIC
>> /usr/bin/ld: final link failed: Bad value
>> collect2: ld returned 1 exit status
>>
>>
>> The bug is simply that "-fPIE -fPIC" counts as -fPIE rather than -fPIC:
>>
>> $ gcc -S -o - f.c -fPIE |grep call
>> call f # PC32 relocation
>> $ gcc -S -o - f.c -fPIC |grep call
>> call f@PLT # PLT32 relocation
> The easy workaround is to drop -fPIE when we're adding -fPIC.
>
>
> r~
Here is a possible patch based on this statement:
From 6e57382c58fa1b9be0fe9db8f35f53a7a7858ccd Mon Sep 17 00:00:00 2001
From: Don Slutz <email address hidden>
Date: Fri, 6 Dec 2013 03:12:12 +0000
Subject: [PATCH] configure: Auto disabling of libtool due to broken
toolchain
support (bug #1257099)
See https://bugs.launchpad.net/bugs/1257099
On RHEL5 GCC with libtool and PIE, you get 'relocation R_X86_64_PC32'
errors from ld.
So disable libtool which disables smartcard-nss (aka nss) if this is true.
Signed-off-by: Don Slutz <email address hidden>
---
configure | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/configure b/configure
index 0666228..5e34095 100755
--- a/configure
+++ b/configure
@@ -1310,6 +1310,33 @@ if compile_prog "-Werror -fno-gcse" "" ; then
TRANSLATE_OPT_CFLAGS=-fno-gcse
fi
+# check for broken GCC in RHEL5 with PIE
+if test -n "$libtool" -a "$pie" = "" ; then
+ cat > $TMPC << EOF
+
+void *f(unsigned char *buf, int len);
+void *g(unsigned char *buf, int len);
+
+void *
+f(unsigned char *buf, int len)
+{
+ return (void*)0L;
+}
+
+void *
+g(unsigned char *buf, int len)
+{
+ return f(buf, len);
+}
+
+EOF
+ if ! compile_prog "-shared -fPIE -fPIC" ""; then
+ echo "Disabling libtool due to broken toolchain support"
+ echo "Defaulting to --disable-smartcard-nss"
+ libtool=
+ fi
+fi
+
if test "$static" = "yes" ; then
if test "$pie" = "yes" ; then
error_exit "static and pie are mutually incompatible"
--
1.8.2.1
-Don Slutz
On 12/05/13 10:18, Paolo Bonzini wrote:
> Il 04/12/2013 02:32, Don Slutz ha scritto:
>> Any hints or pointers about the bug in RHEL5 binutils? I can try and
>> make a patch to auto detect this.
> Actually it's RHEL5 GCC:
>
> $ cat f.c
> void *
> f(unsigned char *buf, int len)
> {
> return (void*)0L;
> }
>
>
> void *
> g(unsigned char *buf, int len)
> {
> return f(buf, len);
> }
> $ gcc -shared -o f.so f.c -fPIE -fPIC
> /usr/bin/ld: /tmp/ccQc9els.o: relocation R_X86_64_PC32 against `f' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: final link failed: Bad value
> collect2: ld returned 1 exit status
>
>
> The bug is simply that "-fPIE -fPIC" counts as -fPIE rather than -fPIC:
>
> $ gcc -S -o - f.c -fPIE |grep call
> call f # PC32 relocation
> $ gcc -S -o - f.c -fPIC |grep call
> call f@PLT # PLT32 relocation
>
> On RHEL5:
> $ gcc -S -o - f.c -fPIE -fPIC |grep call
> call f
>
> On RHEL6:
> $ gcc -S -o - f.c -fPIE -fPIC |grep call
> call f@PLT
>
> Paolo
RHEL5 also "works" if you add -pie:
dcs-xen-53:~/tmp>gcc -shared -o f.so f.c -fPIE -fPIC
/usr/bin/ld: /tmp/cc6pp1n2.o: relocation R_X86_64_PC32 against `f' can
not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
dcs-xen-53:~/tmp>gcc -shared -o f.so f.c -fPIE -fPIC -pie
dcs-xen-53:~/tmp>gcc -S -o - f.c -fPIE -pie|grep call
call f
I have not figured out a way to take advantage of this.
I just checked and Fedora 17 has the same issue with gcc:
FC17:
dcs-xen-52:~/tmp>gcc -S -o - f.c -fPIE -fPIC |grep call
call f
dcs-xen-52:~/tmp>gcc -shared -o f.so f.c -fPIE -fPIC
/usr/bin/ld: /tmp/ccUlVgMP.o: relocation R_X86_64_PC32 against symbol
`f' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
However QEMU builds just fine. So it is looking like libtool is also
part of the problem.
-Don Slutz
On 12/05/13 22:20, Don Slutz wrote:
> On 12/05/13 16:24, Richard Henderson wrote:
>> On 12/06/2013 04:18 AM, Paolo Bonzini wrote:
>>> $ gcc -shared -o f.so f.c -fPIE -fPIC
>>> /usr/bin/ld: /tmp/ccQc9els.o: relocation R_X86_64_PC32 against `f'
>>> can not be used when making a shared object; recompile with -fPIC
>>> /usr/bin/ld: final link failed: Bad value
>>> collect2: ld returned 1 exit status
>>>
>>>
>>> The bug is simply that "-fPIE -fPIC" counts as -fPIE rather than -fPIC:
>>>
>>> $ gcc -S -o - f.c -fPIE |grep call
>>> call f # PC32 relocation
>>> $ gcc -S -o - f.c -fPIC |grep call
>>> call f@PLT # PLT32 relocation
>> The easy workaround is to drop -fPIE when we're adding -fPIC.
>>
>>
>> r~
[snip]
Attached is a much better version. It drops -fPIE and adds -fPIC for
libtool.
-Don Slutz
On 12/09/13 08:22, Paolo Bonzini wrote:
> Il 09/12/2013 13:47, Don Slutz ha scritto:
>> On 12/05/13 22:20, Don Slutz wrote:
>>> On 12/05/13 16:24, Richard Henderson wrote:
>>>> On 12/06/2013 04:18 AM, Paolo Bonzini wrote:
>>>>> $ gcc -shared -o f.so f.c -fPIE -fPIC
>>>>> /usr/bin/ld: /tmp/ccQc9els.o: relocation R_X86_64_PC32 against `f'
>>>>> can not be used when making a shared object; recompile with -fPIC
>>>>> /usr/bin/ld: final link failed: Bad value
>>>>> collect2: ld returned 1 exit status
>>>>>
>>>>>
>>>>> The bug is simply that "-fPIE -fPIC" counts as -fPIE rather than -fPIC:
>>>>>
>>>>> $ gcc -S -o - f.c -fPIE |grep call
>>>>> call f # PC32 relocation
>>>>> $ gcc -S -o - f.c -fPIC |grep call
>>>>> call f@PLT # PLT32 relocation
>>>> The easy workaround is to drop -fPIE when we're adding -fPIC.
>>>>
>>>>
>>>> r~
>> [snip]
>>
>> Attached is a much better version. It drops -fPIE and adds -fPIC for
>> libtool.
> It's not much better, because using position-independent code for shared
> libraries is really platform-dependent knowledge of the kind that
> libtool is supposed to hide.
>
> For example, on Mac OS X everything is position-independent by default.
> And on some platforms you have -fpic instead of -fPIC.
>
> So I prefer the patch you had that disabled libtool if the platform is
> buggy.
>
> Paolo
Well, the detection code is too simple:
FC17 system:
dcs-xen-52:~/tmp/libtool>uname -a
Linux dcs-xen-52 3.8.11-100.fc17.x86_64 #1 SMP Wed May 1 19:31:26
UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
dcs-xen-52:~/tmp/libtool>gcc -shared -fPIE -DPIE f.c -fPIC -DPIC -o f.so
/usr/bin/ld: /tmp/ccl4By1r.o: relocation R_X86_64_PC32 against
symbol `f' can not be used when making a shared object; recompile
with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
dcs-xen-52:~/tmp/libtool>libtool --mode=compile gcc -g -c -fPIE
-DPIE f.c
libtool: compile: gcc -g -c -DPIE f.c -fPIC -DPIC -o .libs/f.o
libtool: compile: gcc -g -c -DPIE f.c -fPIE -o f.o >/dev/null 2>&1
dcs-xen-52:~/tmp/libtool>libtool --mode=link gcc -g -o libf.la f.lo
-rpath /usr/local/lib
libtool: link: gcc -shared -fPIC -DPIC .libs/f.o -Wl,-soname
-Wl,libf.so.0 -o .libs/libf.so.0.0.0
libtool: link: (cd ".libs" && rm -f "libf.so.0" && ln -s
"libf.so.0.0.0" "libf.so.0")
libtool: link: (cd ".libs" && rm -f "libf.so" && ln -s
"libf.so.0.0.0" "libf.so")
libtool: link: ar cru .libs/libf.a f.o
libtool: link: ranlib .libs/libf.a
libtool: link: ( cd ".libs" && rm -f "libf.la" && ln -s "../libf.la"
"libf.la" )
CentOS 5.10:
dcs-xen-53:~/tmp/libtool>uname -a
Linux dcs-xen-53 2.6.18-371.el5xen #1 SMP Tue Oct 1 09:15:30 EDT
2013 x86_64 x86_64 x86_64 GNU/Linux
dcs-xen-53:~/tmp/libtool>gcc -shared -fPIE -DPIE f.c -fPIC -DPIC -o f.so
/usr/bin/ld: /tmp/ccAy1vZK.o: relocation R_X86_64_PC32 against `f'
can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
dcs-xen-53:~/tmp/libtool>libtool --mode=compile gcc -g -c -fPIE
-DPIE f.c
mkdir .libs
gcc -g -c -fPIE -DPIE f.c -fPIC -DPIC -o .libs/f.o
gcc -g -c -fPIE -DPIE f.c -o f.o >/dev/null 2>&1
dcs-xen-53:~/tmp/libtool>libtool --mode=link gcc -g -o libf.la f.lo
-rpath /usr/local/lib
gcc -shared .libs/f.o -Wl,-soname -Wl,libf.so.0 -o
.libs/libf.so.0.0.0
/usr/bin/ld: .libs/f.o: relocation R_X86_64_PC32 against `f' can not
be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
I have attached a patch that uses libtool to determine if gcc & libtool
is broken.
-Don
On 12/14/13 15:21, Don Slutz wrote:
> On 12/09/13 08:22, Paolo Bonzini wrote:
>> Il 09/12/2013 13:47, Don Slutz ha scritto:
>>> On 12/05/13 22:20, Don Slutz wrote:
>>>> On 12/05/13 16:24, Richard Henderson wrote:
>>>>> On 12/06/2013 04:18 AM, Paolo Bonzini wrote:
>>>>>> $ gcc -shared -o f.so f.c -fPIE -fPIC
>>>>>> /usr/bin/ld: /tmp/ccQc9els.o: relocation R_X86_64_PC32 against `f'
>>>>>> can not be used when making a shared object; recompile with -fPIC
>>>>>> /usr/bin/ld: final link failed: Bad value
>>>>>> collect2: ld returned 1 exit status
>>>>>>
>>>>>>
>>>>>> The bug is simply that "-fPIE -fPIC" counts as -fPIE rather than -fPIC:
>>>>>>
>>>>>> $ gcc -S -o - f.c -fPIE |grep call
>>>>>> call f # PC32 relocation
>>>>>> $ gcc -S -o - f.c -fPIC |grep call
>>>>>> call f@PLT # PLT32 relocation
>>>>> The easy workaround is to drop -fPIE when we're adding -fPIC.
>>>>>
>>>>>
>>>>> r~
>>> [snip]
>>>
>>> Attached is a much better version. It drops -fPIE and adds -fPIC for
>>> libtool.
>> It's not much better, because using position-independent code for shared
>> libraries is really platform-dependent knowledge of the kind that
>> libtool is supposed to hide.
>>
>> For example, on Mac OS X everything is position-independent by default.
>> And on some platforms you have -fpic instead of -fPIC.
>>
>> So I prefer the patch you had that disabled libtool if the platform is
>> buggy.
>>
>> Paolo
> Well, the detection code is too simple:
>
> FC17 system:
>
> dcs-xen-52:~/tmp/libtool>uname -a
> Linux dcs-xen-52 3.8.11-100.fc17.x86_64 #1 SMP Wed May 1 19:31:26
> UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
> dcs-xen-52:~/tmp/libtool>gcc -shared -fPIE -DPIE f.c -fPIC -DPIC
> -o f.so
> /usr/bin/ld: /tmp/ccl4By1r.o: relocation R_X86_64_PC32 against
> symbol `f' can not be used when making a shared object; recompile
> with -fPIC
> /usr/bin/ld: final link failed: Bad value
> collect2: error: ld returned 1 exit status
> dcs-xen-52:~/tmp/libtool>libtool --mode=compile gcc -g -c -fPIE
> -DPIE f.c
> libtool: compile: gcc -g -c -DPIE f.c -fPIC -DPIC -o .libs/f.o
> libtool: compile: gcc -g -c -DPIE f.c -fPIE -o f.o >/dev/null 2>&1
> dcs-xen-52:~/tmp/libtool>libtool --mode=link gcc -g -o libf.la
> f.lo -rpath /usr/local/lib
> libtool: link: gcc -shared -fPIC -DPIC .libs/f.o -Wl,-soname
> -Wl,libf.so.0 -o .libs/libf.so.0.0.0
> libtool: link: (cd ".libs" && rm -f "libf.so.0" && ln -s
> "libf.so.0.0.0" "libf.so.0")
> libtool: link: (cd ".libs" && rm -f "libf.so" && ln -s
> "libf.so.0.0.0" "libf.so")
> libtool: link: ar cru .libs/libf.a f.o
> libtool: link: ranlib .libs/libf.a
> libtool: link: ( cd ".libs" && rm -f "libf.la" && ln -s
> "../libf.la" "libf.la" )
>
> CentOS 5.10:
>
> dcs-xen-53:~/tmp/libtool>uname -a
> Linux dcs-xen-53 2.6.18-371.el5xen #1 SMP Tue Oct 1 09:15:30 EDT
> 2013 x86_64 x86_64 x86_64 GNU/Linux
> dcs-xen-53:~/tmp/libtool>gcc -shared -fPIE -DPIE f.c -fPIC -DPIC
> -o f.so
> /usr/bin/ld: /tmp/ccAy1vZK.o: relocation R_X86_64_PC32 against `f'
> can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: final link failed: Bad value
> collect2: ld returned 1 exit status
> dcs-xen-53:~/tmp/libtool>libtool --mode=compile gcc -g -c -fPIE
> -DPIE f.c
> mkdir .libs
> gcc -g -c -fPIE -DPIE f.c -fPIC -DPIC -o .libs/f.o
> gcc -g -c -fPIE -DPIE f.c -o f.o >/dev/null 2>&1
> dcs-xen-53:~/tmp/libtool>libtool --mode=link gcc -g -o libf.la
> f.lo -rpath /usr/local/lib
> gcc -shared .libs/f.o -Wl,-soname -Wl,libf.so.0 -o
> .libs/libf.so.0.0.0
> /usr/bin/ld: .libs/f.o: relocation R_X86_64_PC32 against `f' can
> not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: final link failed: Bad value
> collect2: ld returned 1 exit status
>
> I have attached a patch that uses libtool to determine if gcc &
> libtool is broken.
> -Don
>
Early today it hit me that the new check was a little to early in
configure. Needs to be after PIE check.
Attached is a v2 of the patch.
-Don Slutz
From bb68898eb787cbb1748d4aeb31a4184339d38300 Mon Sep 17 00:00:00 2001
From: Don Slutz <email address hidden>
Date: Sat, 14 Dec 2013 19:43:56 +0000
Subject: [PATCH] configure: Disable libtool if -fPIE does not work with it
(bug #1257099)
Adjust TMPO and added TMPB, TMPL, and TMPA. libtool needs the names
to be fixed (TMPB).
Add new functions do_libtool and libtool_prog.
Add check for broken gcc and libtool.
Signed-off-by: Don Slutz <email address hidden>
---
configure | 63
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index edfea95..852d021 100755
--- a/configure
+++ b/configure
@@ -12,7 +12,10 @@ else
fi
TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
-TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
+TMPB="qemu-conf-${RANDOM}-$$-${RANDOM}"
+TMPO="${TMPDIR1}/${TMPB}.o"
+TMPL="${TMPDIR1}/${TMPB}.lo"
+TMPA="${TMPDIR1}/lib${TMPB}.la"
TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
# NB: do not call "exit" in the trap handler; this is buggy with some
shells;
@@ -86,6 +89,38 @@ compile_prog() {
do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
}
+do_libtool() {
+ local mode=$1
+ shift
+ # Run the compiler, capturing its output to the log.
+ echo $libtool $mode --tag=CC $cc "$@" >> config.log
+ $libtool $mode --tag=CC $cc "$@" >> config.log 2>&1 || return $?
+ # Test passed. If this is an --enable-werror build, rerun
+ # the test with -Werror and bail out if it fails. This
+ # makes warning-generating-errors in configure test code
+ # obvious to developers.
+ if test "$werror" != "yes"; then
+ return 0
+ fi
+ # Don't bother rerunning the compile if we were already using -Werror
+ case "$*" in
+ *-Werror*)
+ return 0
+ ;;
+ esac
+ echo $libtool $mode --tag=CC $cc -Werror "$@" >> config.log
+ $libtool $mode --tag=CC $cc -Werror "$@" >> config.log 2>&1 &&
return $?
+ error_exit "configure test passed without -Werror but failed with
-Werror." \
+ "This is probably a bug in the configure script. The failing
command" \
+ "will be at the bottom of config.log." \
+ "You can run configure with --disable-werror to bypass this check."
+}
+
+libtool_prog() {
+ do_libtool --mode=compile $QEMU_CFLAGS -c -fPIE -DPIE -o $TMPO
$TMPC || return $?
+ do_libtool --mode=link $LDFLAGS -o $TMPA $TMPL -rpath /usr/local/lib
+}
+
# symbolically link $1 to $2. Portable version of "ln -sf".
symlink() {
rm -rf "$2"
@@ -1367,6 +1402,32 @@ EOF
fi
fi
+# check for broken gcc and libtool in RHEL5
+if test -n "$libtool" -a "$pie" != "no" ; then
+ cat > $TMPC <<EOF
+
+void *f(unsigned char *buf, int len);
+void *g(unsigned char *buf, int len);
+
+void *
+f(unsigned char *buf, int len)
+{
+ return (void*)0L;
+}
+
+void *
+g(unsigned char *buf, int len)
+{
+ return f(buf, len);
+}
+
+EOF
+ if ! libtool_prog; then
+ echo "Disabling libtool due to broken toolchain support"
+ libtool=
+ fi
+fi
+
##########################################
# __sync_fetch_and_and requires at least -march=i486. Many toolchains
# use i686 as default anyway, but for those that don't, an explicit
--
1.8.2.1
Adjust TMPO and added TMPB, TMPL, and TMPA. libtool needs the names
to be fixed (TMPB).
Add new functions do_libtool and libtool_prog.
Add check for broken gcc and libtool.
Signed-off-by: Don Slutz <email address hidden>
---
Was posted as an attachment.
https://lists.gnu.org/archive/html/qemu-devel/2013-12/msg02678.html
configure | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index edfea95..852d021 100755
--- a/configure
+++ b/configure
@@ -12,7 +12,10 @@ else
fi
TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
-TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
+TMPB="qemu-conf-${RANDOM}-$$-${RANDOM}"
+TMPO="${TMPDIR1}/${TMPB}.o"
+TMPL="${TMPDIR1}/${TMPB}.lo"
+TMPA="${TMPDIR1}/lib${TMPB}.la"
TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
# NB: do not call "exit" in the trap handler; this is buggy with some shells;
@@ -86,6 +89,38 @@ compile_prog() {
do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
}
+do_libtool() {
+ local mode=$1
+ shift
+ # Run the compiler, capturing its output to the log.
+ echo $libtool $mode --tag=CC $cc "$@" >> config.log
+ $libtool $mode --tag=CC $cc "$@" >> config.log 2>&1 || return $?
+ # Test passed. If this is an --enable-werror build, rerun
+ # the test with -Werror and bail out if it fails. This
+ # makes warning-generating-errors in configure test code
+ # obvious to developers.
+ if test "$werror" != "yes"; then
+ return 0
+ fi
+ # Don't bother rerunning the compile if we were already using -Werror
+ case "$*" in
+ *-Werror*)
+ return 0
+ ;;
+ esac
+ echo $libtool $mode --tag=CC $cc -Werror "$@" >> config.log
+ $libtool $mode --tag=CC $cc -Werror "$@" >> config.log 2>&1 && return $?
+ error_exit "configure test passed without -Werror but failed with -Werror." \
+ "This is probably a bug in the configure script. The failing command" \
+ "will be at the bottom of config.log." \
+ "You can run configure with --disable-werror to bypass this check."
+}
+
+libtool_prog() {
+ do_libtool --mode=compile $QEMU_CFLAGS -c -fPIE -DPIE -o $TMPO $TMPC || return $?
+ do_libtool --mode=link $LDFLAGS -o $TMPA $TMPL -rpath /usr/local/lib
+}
+
# symbolically link $1 to $2. Portable version of "ln -sf".
symlink() {
rm -rf "$2"
@@ -1367,6 +1402,32 @@ EOF
fi
fi
+# check for broken gcc and libtool in RHEL5
+if test -n "$libtool" -a "$pie" != "no" ; then
+ cat > $TMPC <<EOF
+
+void *f(unsigned char *buf, int len);
+void *g(unsigned char *buf, int len);
+
+void *
+f(unsigned char *buf, int len)
+{
+ return (void*)0L;
+}
+
+void *
+g(unsigned char *buf, int len)
+{
+ return f(buf, len);
+}
+
+EOF
+ if ! libtool_prog; then
+ echo "Disabling libtool due to broken toolchain support"
+ libtool=
+ fi
+fi
+
##########################################
# __sync_fetch_and_and requires at least -march=i486. Many toolchains
# use i686 as default anyway, but for those that don't, an explicit
--
1.8.2.1
On 01/02/14 21:12, Don Slutz wrote:
Ping.
> Adjust TMPO and added TMPB, TMPL, and TMPA. libtool needs the names
> to be fixed (TMPB).
>
> Add new functions do_libtool and libtool_prog.
>
> Add check for broken gcc and libtool.
>
> Signed-off-by: Don Slutz <email address hidden>
> ---
> Was posted as an attachment.
>
> https://lists.gnu.org/archive/html/qemu-devel/2013-12/msg02678.html
>
> configure | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 62 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index edfea95..852d021 100755
> --- a/configure
> +++ b/configure
> @@ -12,7 +12,10 @@ else
> fi
>
> TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
> -TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
> +TMPB="qemu-conf-${RANDOM}-$$-${RANDOM}"
> +TMPO="${TMPDIR1}/${TMPB}.o"
> +TMPL="${TMPDIR1}/${TMPB}.lo"
> +TMPA="${TMPDIR1}/lib${TMPB}.la"
> TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
>
> # NB: do not call "exit" in the trap handler; this is buggy with some shells;
> @@ -86,6 +89,38 @@ compile_prog() {
> do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
> }
>
> +do_libtool() {
> + local mode=$1
> + shift
> + # Run the compiler, capturing its output to the log.
> + echo $libtool $mode --tag=CC $cc "$@" >> config.log
> + $libtool $mode --tag=CC $cc "$@" >> config.log 2>&1 || return $?
> + # Test passed. If this is an --enable-werror build, rerun
> + # the test with -Werror and bail out if it fails. This
> + # makes warning-generating-errors in configure test code
> + # obvious to developers.
> + if test "$werror" != "yes"; then
> + return 0
> + fi
> + # Don't bother rerunning the compile if we were already using -Werror
> + case "$*" in
> + *-Werror*)
> + return 0
> + ;;
> + esac
> + echo $libtool $mode --tag=CC $cc -Werror "$@" >> config.log
> + $libtool $mode --tag=CC $cc -Werror "$@" >> config.log 2>&1 && return $?
> + error_exit "configure test passed without -Werror but failed with -Werror." \
> + "This is probably a bug in the configure script. The failing command" \
> + "will be at the bottom of config.log." \
> + "You can run configure with --disable-werror to bypass this check."
> +}
> +
> +libtool_prog() {
> + do_libtool --mode=compile $QEMU_CFLAGS -c -fPIE -DPIE -o $TMPO $TMPC || return $?
> + do_libtool --mode=link $LDFLAGS -o $TMPA $TMPL -rpath /usr/local/lib
> +}
> +
> # symbolically link $1 to $2. Portable version of "ln -sf".
> symlink() {
> rm -rf "$2"
> @@ -1367,6 +1402,32 @@ EOF
> fi
> fi
>
> +# check for broken gcc and libtool in RHEL5
> +if test -n "$libtool" -a "$pie" != "no" ; then
> + cat > $TMPC <<EOF
> +
> +void *f(unsigned char *buf, int len);
> +void *g(unsigned char *buf, int len);
> +
> +void *
> +f(unsigned char *buf, int len)
> +{
> + return (void*)0L;
> +}
> +
> +void *
> +g(unsigned char *buf, int len)
> +{
> + return f(buf, len);
> +}
> +
> +EOF
> + if ! libtool_prog; then
> + echo "Disabling libtool due to broken toolchain support"
> + libtool=
> + fi
> +fi
> +
> ##########################################
> # __sync_fetch_and_and requires at least -march=i486. Many toolchains
> # use i686 as default anyway, but for those that don't, an explicit
Patch has been included here:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=66518bf668f09eaab14c174
==> Fix released.
|