-
Notifications
You must be signed in to change notification settings - Fork 1
/
gcc.spec
1927 lines (1736 loc) · 67.7 KB
/
gcc.spec
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
# Combined gcc / cross-armv*-gcc) specfile
Name: gcc
# Keep Name on top !
%if "%{?bootstrap}" == ""
%define bootstrap 0
%else
%if "%{bootstrap}" != "0" && "%{bootstrap}" != "1" && "%{bootstrap}" != "2"
%{error:Bootstrap parameter should me one of: 0, 1, 2}
%endif
%endif
%ifarch aarch64 x86_64
%define _libdir /usr/lib64
%define _lib lib64
%endif
# crossbuild / accelerator section
# \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
%define crossbuild 0
%if "%{name}" != "gcc"
# this is the ix86 -> arm cross compiler (cross-armv*-gcc)
#
# We set requires/provides by hand and disable post-build-checks.
# Captain Trunk: Sledge, you cannot disarm that nuclear bomb!
# Sledge Hammer: Trust me, I know what I'm doing.
AutoReqProv: 0
AutoReq: false
#!BuildIgnore: rpmlint-Moblin
#!BuildIgnore: rpmlint-mini
#!BuildIgnore: post-build-checks
# cross platform
%if %(echo %{crossarch} | grep -q "^arm" && echo 1 || echo 0)
%define cross_gcc_target_platform %{crossarch}-%{_vendor}-linux-gnueabi
%else
%define cross_gcc_target_platform %{crossarch}-%{_vendor}-linux-gnu
%endif
# gcc_target_platform holds the host (executing the compiler)
# cross_gcc_target_platform holds the target (for which the compiler is producing binaries)
# prefix for cross compiler
%define _prefix /opt/cross
# strip of 'foreign arch' symbols fails
%define __strip /bin/true
# sysroot for cross-compiler
%define crosssysroot %{_prefix}/%{cross_gcc_target_platform}/sys-root
# flag
%define crossbuild 1
# macros in buildrequires is hard to expand for the scheduler (e.g. crossarch) which would make this easier.
%if %{bootstrap} == 2
%define cross_deps cross-%{crossarch}-glibc-headers cross-%{crossarch}-libxcrypt-devel cross-%{crossarch}-kernel-headers cross-%{crossarch}-binutils
%endif
%if %{bootstrap} == 0
%define cross_deps cross-%{crossarch}-glibc cross-%{crossarch}-glibc-devel cross-%{crossarch}-libxcrypt cross-%{crossarch}-libxcrypt-devel cross-%{crossarch}-glibc-headers cross-%{crossarch}-kernel-headers cross-%{crossarch}-binutils
%endif
%if %{bootstrap} == 1
%define cross_deps cross-%{crossarch}-kernel-headers cross-%{crossarch}-binutils
%endif
BuildRequires: %{cross_deps}
# Fixme: find way to make this without listing every package
%if "%{crossarch}" == "armv5tel"
%define crossextraconfig %{nil}
%endif
%if "%{crossarch}" == "armv6l"
%define crossextraconfig --with-fpu=vfp --with-arch=armv6
%endif
%if "%{crossarch}" == "armv7l"
%define crossextraconfig --with-fpu=vfpv3-d16 --with-arch=armv7-a
%endif
%if "%{crossarch}" == "armv7hl"
%define crossextraconfig --with-float=hard --with-fpu=neon --with-arch=armv7-a --with-mode=thumb
%endif
%if "%{crossarch}" == "armv7nhl"
%define crossextraconfig --with-float=hard --with-fpu=neon --with-arch=armv7-a
%endif
%if "%{crossarch}" == "armv7thl"
%define crossextraconfig --with-float=hard --with-fpu=vfpv3-d16 --with-arch=armv7-a --with-mode=thumb
%endif
%if "%{crossarch}" == "armv7tnhl"
%define crossextraconfig --with-float=hard --with-fpu=neon --with-arch=armv7-a --with-mode=thumb
%endif
%if "%{crossarch}" == "mipsel"
%define crossextraconfig --disable-fixed-point --disable-ssp --disable-libstdcxx-pch --with-arch=mips32
%endif
%if "%{crossarch}" == "i486"
%define crossextraconfig --disable-libstdcxx-pch --with-arch=i686 --with-fpmatch=sse --with-gnu-as=/opt/cross/bin/i486-meego-linux-gnu-as --with-gnu-ld=/opt/cross/bin/i486-meego-linux-gnu-ld --with-as=/opt/cross/bin/i486-meego-linux-gnu-as --with-ld=/opt/cross/bin/i486-meego-linux-gnu-ld
%endif
%if "%{crossarch}" == "x86_64"
%define crossextraconfig --disable-libstdcxx-pch
%endif
%if "%{crossarch}" == "aarch64"
%define crossextraconfig --with-arch=armv8-a
%endif
# single target atm.
ExclusiveArch: %ix86 x86_64
#
# /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
# end crossbuild / accelerator section
%endif
%global gcc_version 10.3.1
%global gcc_release 1
%global _unpackaged_files_terminate_build 0
%global _performance_build 1
%global build_ada 0
%global build_objc 0
%global build_go 0
%global build_d 0
%global include_gappletviewer 0
%global build_libstdcxx_doc 0
%global multilib_64_archs %{nil}
%ifarch x86_64
%global multilib_32_arch i686
%endif
%global build_64bit_multilib 0
%ifarch %{ix86} x86_64
%global build_libquadmath 1
%else
%global build_libquadmath 0
%endif
%ifarch %{ix86} x86_64 ppc ppc64 ppc64le ppc64p7 s390 s390x %{arm} aarch64
%global build_libasan 1
%else
%global build_libasan 0
%endif
%ifarch x86_64 ppc64 ppc64le aarch64
%global build_libtsan 1
%else
%global build_libtsan 0
%endif
%ifarch x86_64 ppc64 ppc64le aarch64
%global build_liblsan 1
%else
%global build_liblsan 0
%endif
%ifarch %{ix86} x86_64 ppc ppc64 ppc64le ppc64p7 s390 s390x %{arm} aarch64
%global build_libubsan 1
%else
%global build_libubsan 0
%endif
%ifarch %{ix86} x86_64 ppc ppc64 ppc64le ppc64p7 s390 s390x %{arm} aarch64 %{mips}
%global build_libatomic 1
%else
%global build_libatomic 0
%endif
%ifarch %{ix86} x86_64 %{arm} alpha ppc ppc64 ppc64le ppc64p7 s390 s390x aarch64
%global build_libitm 1
%else
%global build_libitm 0
%endif
%ifarch %{ix86} x86_64 ppc ppc64 ppc64le ppc64p7 s390 s390x %{arm} aarch64 %{mips}
%global attr_ifunc 1
%else
%global attr_ifunc 0
%endif
#GCC Graphite needs isl
%global build_isl 1
Summary: Various compilers (C, C++, Objective-C, Java, ...)
Version: %{gcc_version}
%if %{bootstrap}
Release: 0.%{bootstrap}.%{gcc_release}
%else
Release: %{gcc_release}
%endif
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
URL: https://developer.arm.com/downloads/-/gnu-a
Source0: https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/srcrel/gcc-arm-src-snapshot-10.3-2021.07.tar.xz
Source3: gcc-rpmlintrc
Source4: baselibs.conf
Source5: precheckin.sh
Source6: aaa_README.PACKAGER
Patch0: gcc10-hack.patch
Patch1: gcc10-i386-libgomp.patch
Patch3: gcc10-libgomp-omp_h-multilib.patch
Patch4: gcc10-libtool-no-rpath.patch
Patch5: gcc10-isl-dl.patch
Patch6: gcc10-libstdc++-docs.patch
Patch7: gcc10-no-add-needed.patch
Patch8: gcc10-foffload-default.patch
Patch9: gcc10-Wno-format-security.patch
Patch10: gcc10-rh1574936.patch
Patch11: gcc10-d-shared-libphobos.patch
Patch12: gcc10-pr96383.patch
Patch13: gcc10-pr96939.patch
Patch14: gcc10-pr96939-2.patch
Patch15: gcc10-pr96939-3.patch
Patch16: gcc10-reproducible-builds.patch
Patch17: gcc10-reproducible-builds-buildid-for-checksum.patch
BuildRequires: binutils >= 2.31
BuildRequires: glibc-static
BuildRequires: zlib-devel, gettext, bison, flex
BuildRequires: mpc-devel
BuildRequires: glibc-devel >= 2.4.90-13
BuildRequires: elfutils-devel >= 0.147
BuildRequires: libstdc++-devel
BuildRequires: libgomp
BuildRequires: libxcrypt-devel
BuildRequires: libzstd-devel
%if %{build_libstdcxx_doc}
BuildRequires: doxygen
BuildRequires: graphviz
%endif
%if !%{crossbuild}
Requires: cpp = %{version}-%{release}
Requires: libgcc >= %{version}-%{release}
Requires: libgomp = %{version}-%{release}
Requires: glibc-devel
Requires: binutils >= 2.25
%endif
%if !%{crossbuild}
%if %{build_64bit_multilib}
Requires: glibc64bit-helper
%endif
Obsoletes: gcc < %{version}-%{release}
AutoReq: true
# /!crossbuild
%endif
#We need -gnueabi indicator for ARM
%ifnarch %{arm} aarch64
%global _gnu %{nil}
%endif
%global gcc_target_platform %{_target_platform}
%description
The gcc package contains the GNU Compiler Collection version 4.9.
You'll need this package in order to compile C code.
%if !%{crossbuild}
%package doc
Summary: Documentation for %{name}
Requires: %{name} = %{version}-%{release}
%description doc
Man and info pages for %{name}.
%endif # !crossbuild
%package -n libgcc
Summary: GCC version 10.3 shared support library
Obsoletes: libgcc < %{version}-%{release}
Autoreq: true
%if "%{version}" != "%{gcc_version}"
Provides: libgcc = %{gcc_provides}
%endif
%description -n libgcc
This package contains GCC shared support library which is needed
e.g. for exception handling support.
%package c++
Summary: C++ support for GCC
Requires: gcc = %{version}-%{release}
Requires: libstdc++ = %{version}-%{release}
Requires: libstdc++-devel = %{version}-%{release}
Obsoletes: gcc-c++ < %{version}-%{release}
Autoreq: true
%description c++
This package adds C++ support to the GNU Compiler Collection.
It includes support for most of the current C++ specification,
including templates and exception handling.
%package -n libstdc++
Summary: GNU Standard C++ Library
Obsoletes: libstdc++ < %{version}-%{release}
Obsoletes: libstdc++6 < %{version}-%{release}
Autoreq: true
Requires: glibc
%description -n libstdc++
The libstdc++ package contains a rewritten standard compliant GCC Standard
C++ Library.
%package -n libstdc++-devel
Summary: Header files and libraries for C++ development
Requires: libstdc++ = %{version}-%{release}
Obsoletes: libstdc++-devel < %{version}-%{release}
Autoreq: true
%description -n libstdc++-devel
This is the GNU implementation of the standard C++ libraries. This
package includes the header files and libraries needed for C++
development. This includes rewritten implementation of STL.
%package -n libstdc++-static
Summary: Static libraries for the GNU standard C++ library
Requires: libstdc++-devel = %{version}-%{release}
Autoreq: true
%description -n libstdc++-static
Static libraries for the GNU standard C++ library.
%if !%{crossbuild}
%package -n libstdc++-doc
Summary: Documentation for the GNU standard C++ library
Requires: libstdc++ = %{version}-%{release}
Obsoletes: libstdc++-docs
Autoreq: true
%description -n libstdc++-doc
Manual, doxygen generated API information and Frequently Asked Questions
for the GNU standard C++ library.
%endif # !crossbuild
%package -n libgomp
Summary: GCC OpenMP v4.5 shared support library
Obsoletes: libgomp < %{version}-%{release}
%description -n libgomp
This package contains GCC shared support library which is needed
for OpenMP v3.0 support.
%package -n libquadmath
Summary: GCC __float128 shared support library
%description -n libquadmath
This package contains GCC shared support library which is needed
for __float128 math support and for Fortran REAL*16 support.
%package -n libquadmath-devel
Summary: GCC __float128 support
Requires: libquadmath = %{version}-%{release}
Requires: gcc = %{version}-%{release}
%description -n libquadmath-devel
This package contains headers for building Fortran programs using
REAL*16 and programs using __float128 math.
%package -n libquadmath-static
Summary: Static libraries for __float128 support
Requires: libquadmath-devel = %{version}-%{release}
%description -n libquadmath-static
This package contains static libraries for building Fortran programs
using REAL*16 and programs using __float128 math.
%package -n libitm
Summary: The GNU Transactional Memory library
%description -n libitm
This package contains the GNU Transactional Memory library
which is a GCC transactional memory support runtime library.
%package -n libitm-devel
Summary: The GNU Transactional Memory support
Requires: libitm = %{version}-%{release}
Requires: gcc = %{version}-%{release}
%description -n libitm-devel
This package contains headers and support files for the
GNU Transactional Memory library.
%package -n libitm-static
Summary: The GNU Transactional Memory static library
Requires: libitm-devel = %{version}-%{release}
%description -n libitm-static
This package contains GNU Transactional Memory static libraries.
%package -n libatomic
Summary: The GNU Atomic library
%description -n libatomic
This package contains the GNU Atomic library
which is a GCC support runtime library for atomic operations not supported
by hardware.
%package -n libatomic-static
Summary: The GNU Atomic static library
Requires: libatomic = %{version}-%{release}
%description -n libatomic-static
This package contains GNU Atomic static libraries.
%package -n libasan
Summary: The Address Sanitizer runtime library
%description -n libasan
This package contains the Address Sanitizer library
which is used for -fsanitize=address instrumented programs.
%package -n libasan-static
Summary: The Address Sanitizer static library
Requires: libasan = %{version}-%{release}
%description -n libasan-static
This package contains Address Sanitizer static runtime library.
%package -n libtsan
Summary: The Thread Sanitizer runtime library
%description -n libtsan
This package contains the Thread Sanitizer library
which is used for -fsanitize=thread instrumented programs.
%package -n libtsan-static
Summary: The Thread Sanitizer static library
Requires: libtsan = %{version}-%{release}
%description -n libtsan-static
This package contains Thread Sanitizer static runtime library.
%package -n libubsan
Summary: The Undefined Behavior Sanitizer runtime library
%description -n libubsan
This package contains the Undefined Behavior Sanitizer library
which is used for -fsanitize=undefined instrumented programs.
%package -n libubsan-static
Summary: The Undefined Behavior Sanitizer static library
Requires: libubsan = %{version}-%{release}
%description -n libubsan-static
This package contains Undefined Behavior Sanitizer static runtime library.
%package -n liblsan
Summary: The Leak Sanitizer runtime library
%description -n liblsan
This package contains the Leak Sanitizer library
which is used for -fsanitize=leak instrumented programs.
%package -n liblsan-static
Summary: The Leak Sanitizer static library
Requires: liblsan = %{version}-%{release}
%description -n liblsan-static
This package contains Leak Sanitizer static runtime library.
%package -n cpp
Summary: The C Preprocessor
Requires: mpc
Obsoletes: cpp < %{version}-%{release}
Autoreq: true
%description -n cpp
Cpp is the GNU C-Compatible Compiler Preprocessor.
Cpp is a macro processor which is used automatically
by the C compiler to transform your program before actual
compilation. It is called a macro processor because it allows
you to define macros, abbreviations for longer
constructs.
The C preprocessor provides four separate functionalities: the
inclusion of header files (files of declarations that can be
substituted into your program); macro expansion (you can define macros,
and the C preprocessor will replace the macros with their definitions
throughout the program); conditional compilation (using special
preprocessing directives, you can include or exclude parts of the
program according to various conditions); and line control (if you use
a program to combine or rearrange source files into an intermediate
file which is then compiled, you can use line control to inform the
compiler about where each source line originated).
You should install this package if you are a C programmer and you use
macros.
%package -n gcc-multilib
Summary: for 64bit multilib support
Autoreq: true
%description -n gcc-multilib
This is one set of libraries which support 64bit multilib on top of
32bit enviroment from compiler side.
%package plugin-devel
Summary: Support for compiling GCC plugins
Requires: gcc = %{version}-%{release}
Requires: gmp-devel >= 4.1.2-8, mpfr-devel >= 3.1.0, libmpc-devel >= 0.8.1
%description plugin-devel
This package contains header files and other support files
for compiling GCC plugins. The GCC plugin ABI is currently
not stable, so plugins must be rebuilt any time GCC is updated.
%prep
%setup -q -n gcc-arm-src-snapshot-10.3-2021.07
%patch0 -p0 -b .hack~
%patch1 -p0 -b .i386-libgomp~
%patch3 -p0 -b .libgomp-omp_h-multilib~
%patch4 -p0 -b .libtool-no-rpath~
%if %{build_isl}
%patch5 -p0 -b .isl-dl~
%endif
%if %{build_libstdcxx_doc}
%patch6 -p0 -b .libstdc++-docs~
%endif
%patch7 -p0 -b .no-add-needed~
%patch8 -p0 -b .foffload-default~
%patch9 -p0 -b .Wno-format-security~
%patch10 -p0 -b .rh1574936~
%patch11 -p0 -b .d-shared-libphobos~
%patch12 -p0 -b .pr96383~
%patch13 -p0 -b .pr96939~
%patch14 -p0 -b .pr96939-2~
%patch15 -p0 -b .pr96939-3~
%patch16 -p0 -b .reproducible-builds~
%patch17 -p1 -b .reproducible-builds-buildid-for-checksum~
echo 'Sailfish OS gcc %{version}-%{gcc_release}' > gcc/DEV-PHASE
cp -a libstdc++-v3/config/cpu/i{4,3}86/atomicity.h
./contrib/gcc_update --touch
LC_ALL=C sed -i -e 's/\xa0/ /' gcc/doc/options.texi
%build
rm -fr obj-%{gcc_target_platform}
mkdir obj-%{gcc_target_platform}
cd obj-%{gcc_target_platform}
%if %{build_isl}
mkdir isl-build isl-install
%ifarch s390 s390x
ISL_FLAG_PIC=-fPIC
%else
ISL_FLAG_PIC=-fpic
%endif
cd isl-build
../../../isl/configure --disable-shared \
CC=/usr/bin/gcc CXX=/usr/bin/g++ \
CFLAGS="${CFLAGS:-%optflags} $ISL_FLAG_PIC" --prefix=`cd ..; pwd`/isl-install
make %{?_smp_mflags}
make %{?_smp_mflags} install
cd ..
%endif
CC=gcc
OPT_FLAGS=`echo %{optflags}|sed -e 's/\(-Wp,\)\?-D_FORTIFY_SOURCE=[12]//g'`
OPT_FLAGS=`echo $OPT_FLAGS|sed -e 's/-m64//g;s/-m32//g;s/-m31//g'`
%ifarch %{ix86}
OPT_FLAGS=`echo $OPT_FLAGS|sed -e 's/-march=i.86//g'`
%endif
OPT_FLAGS=`echo $OPT_FLAGS| sed -e 's/[[:blank:]]\+/ /g'`
OPT_FLAGS=`echo $OPT_FLAGS|sed -e 's/-Werror=format-security/-Wformat-security/g'`
case "$OPT_FLAGS" in
*-fasynchronous-unwind-tables*)
sed -i -e 's/-fno-exceptions /-fno-exceptions -fno-asynchronous-unwind-tables/' \
../gcc/Makefile.in
;;
esac
%ifarch mipsel
# Apply this in case you ever need to qemu bootstrap --cvm
#
# export OPT_FLAGS="$OPT_FLAGS --param ggc-min-expand=0 --param ggc-min-heapsize=65536"
%endif
%ifarch %arm aarch64
%define ARM_EXTRA_CONFIGURE ""
# for armv7hl reset the gcc specs
%ifarch armv6l
%define ARM_EXTRA_CONFIGURE --with-fpu=vfp --with-arch=armv6
%endif
%ifarch armv7l
%define ARM_EXTRA_CONFIGURE --with-fpu=vfpv3-d16 --with-arch=armv7-a
%endif
%ifarch armv7hl
%define ARM_EXTRA_CONFIGURE --with-float=hard --with-fpu=neon --with-mode=thumb --with-arch=armv7-a
%endif
# for armv7nhl reset the gcc specs
%ifarch armv7nhl
%define ARM_EXTRA_CONFIGURE --with-float=hard --with-fpu=neon --with-arch=armv7-a
%endif
# for armv7thl reset the gcc specs
%ifarch armv7thl
%define ARM_EXTRA_CONFIGURE --with-float=hard --with-fpu=vfpv3-d16 --with-arch=armv7-a --with-mode=thumb
%endif
# for armv7tnhl reset the gcc specs
%ifarch armv7tnhl
%define ARM_EXTRA_CONFIGURE --with-float=hard --with-fpu=neon --with-arch=armv7-a --with-mode=thumb
%endif
# aarch64
%ifarch aarch64
%define ARM_EXTRA_CONFIGURE --with-arch=armv8-a
%endif
%endif
#export OPT_FLAGS=`echo "$OPT_FLAGS" | sed -e "s/-O2/-O2 -fkeep-inline-functions/g"`
export OPT_FLAGS=`echo "$OPT_FLAGS" | sed -e "s/-fstack-protector//g"`
%if %{crossbuild}
# cross build
export PATH=/opt/cross/bin:$PATH
# strip all after -march . no arch specific options in cross-compiler build .
# -march=core2 -mssse3 -mtune=atom -mfpmath=sse -fasynchronous-unwi
export OPT_FLAGS=`echo "$OPT_FLAGS" | sed -e "s#\-march=.*##g" | sed -e 's#\-mtune=.*##g`
%endif
CC="$CC" CFLAGS="$OPT_FLAGS" CXXFLAGS="`echo $OPT_FLAGS | sed 's/ -Wall / /g'`" XCFLAGS="$OPT_FLAGS" TCFLAGS="$OPT_FLAGS" \
GCJFLAGS="$OPT_FLAGS" \
../configure --prefix=%{_prefix} --mandir=%{_mandir} \
%if !%{crossbuild}
%if ! 0%{?qemu_user_space_build}
--enable-bootstrap \
%else
--disable-bootstrap \
%endif
%else
--disable-bootstrap \
%endif
--with-bugurl=https://git.sailfishos.org/ \
--build=%{gcc_target_platform} \
%if %{build_isl}
--with-isl=`pwd`/isl-install \
%endif
%if %{crossbuild}
--host=%{gcc_target_platform} \
--target=%{cross_gcc_target_platform} \
--with-sysroot=%{crosssysroot} \
--disable-multilib \
%else
%ifarch mipsel
--disable-fixed-point \
--disable-ssp \
--disable-libstdcxx-pch \
--with-arch=mips32 \
%endif
--enable-plugin --enable-initfini-array\
%ifarch %{arm} aarch64
%ARM_EXTRA_CONFIGURE \
--disable-sjlj-exceptions \
--enable-gold \
--with-plugin-ld=gold \
%endif
%ifarch aarch64 x86_64
--libdir=/usr/lib64 \
%endif
%ifarch %{ix86} x86_64
--with-tune=generic \
%endif
%ifarch i586
--with-arch=core2 --with-tune=atom --with-fpmath=sse \
%endif
%ifarch i486
--with-arch=i686 --with-fpmath=sse \
%endif
%ifarch x86_64
--disable-libstdcxx-pch \
%endif
%endif
%if %{build_64bit_multilib}
--enable-targets=all \
--enable-multilib \
%else
--disable-multilib \
%endif
--enable-checking=release \
--disable-fixed-point \
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions \
--enable-gnu-unique-object \
--enable-lto \
--enable-linker-build-id \
--disable-libmpx \
%if %{bootstrap} == 0
--enable-languages=c,c++,lto \
--enable-threads=posix \
--enable-shared \
%endif
%if %{bootstrap} == 1
--enable-languages=c \
--without-headers \
--with-newlib \
--disable-decimal-float \
--disable-fixed-point \
--disable-threads \
--disable-shared \
--disable-libssp \
--disable-libgomp \
--disable-libquadmath \
%endif
%if %{bootstrap} == 2
--enable-languages=c \
--with-sysroot=%{crosssysroot} \
--disable-libssp \
--disable-libgomp \
--disable-libquadmath \
%endif
--disable-libgcj \
--disable-libcilkrts \
%if %{attr_ifunc}
--enable-gnu-indirect-function \
%endif
%if %{crossbuild}
%{crossextraconfig} \
%endif
--build=%{gcc_target_platform} || ( cat config.log ; exit 1 )
GCJFLAGS="$OPT_FLAGS" make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS"
# Make
#make -C gcc CC="./xgcc -B ./ -O2" all
# Make generated man pages even if Pod::Man is not new enough
perl -pi -e 's/head3/head2/' ../contrib/texi2pod.pl
for i in ../gcc/doc/*.texi; do
cp -a $i $i.orig; sed 's/ftable/table/' $i.orig > $i
done
make %{?_smp_mflags} -C gcc generated-manpages
for i in ../gcc/doc/*.texi; do mv -f $i.orig $i; done
# Make generated doxygen pages.
%if %{build_libstdcxx_doc}
cd %{gcc_target_platform}/libstdc++-v3
make doc-html-doxygen
make doc-man-doxygen
cd ../..
%endif
# Copy various doc files here and there
cd ..
mkdir -p rpm.doc/gfortran rpm.doc/objc rpm.doc/gdc rpm.doc/libphobos
mkdir -p rpm.doc/go rpm.doc/libgo rpm.doc/libquadmath rpm.doc/libitm
mkdir -p rpm.doc/changelogs/{gcc/cp,gcc/ada,gcc/jit,libstdc++-v3,libobjc,libgomp,libcc1,libatomic,libsanitizer}
for i in {gcc,gcc/cp,gcc/ada,gcc/jit,libstdc++-v3,libobjc,libgomp,libcc1,libatomic,libsanitizer}/ChangeLog*; do
cp -p $i rpm.doc/changelogs/$i
done
%if %{build_objc}
(cd libobjc; for i in README*; do
cp -p $i ../rpm.doc/objc/$i.libobjc
done)
%endif
%if %{build_d}
(cd gcc/d; for i in ChangeLog*; do
cp -p $i ../../rpm.doc/gdc/$i.gdc
done)
(cd libphobos; for i in ChangeLog*; do
cp -p $i ../rpm.doc/libphobos/$i.libphobos
done
cp -a src/LICENSE*.txt libdruntime/LICENSE ../rpm.doc/libphobos/)
%endif
%if %{build_libquadmath}
(cd libquadmath; for i in ChangeLog* COPYING.LIB; do
cp -p $i ../rpm.doc/libquadmath/$i.libquadmath
done)
%endif
%if %{build_libitm}
(cd libitm; for i in ChangeLog*; do
cp -p $i ../rpm.doc/libitm/$i.libitm
done)
%endif
%if %{build_go}
(cd gcc/go; for i in README* ChangeLog*; do
cp -p $i ../../rpm.doc/go/$i
done)
(cd libgo; for i in LICENSE* PATENTS* README; do
cp -p $i ../rpm.doc/libgo/$i.libgo
done)
%endif
rm -f rpm.doc/changelogs/gcc/ChangeLog.[1-9]
find rpm.doc -name \*ChangeLog\* | xargs bzip2 -9
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
cd obj-%{gcc_target_platform}
%if !%{crossbuild}
# native
TARGET_PLATFORM=%{gcc_target_platform}
# There are some MP bugs in libstdc++ Makefiles
make %{?_smp_mflags} -C %{gcc_target_platform}/libstdc++-v3
%else
# cross build
export PATH=/opt/cross/bin:$PATH
# strip all after -march . no arch specific options in cross-compiler build .
# -march=core2 -mssse3 -mtune=atom -mfpmath=sse -fasynchronous-unwi
export OPT_FLAGS=`echo "$OPT_FLAGS" | sed -e "s#\-march=.*##g"`
echo "$OPT_FLAGS"
TARGET_PLATFORM=%{cross_gcc_target_platform}
# There are some MP bugs in libstdc++ Makefiles
make %{?_smp_mflags} -C %{cross_gcc_target_platform}/libstdc++-v3
%endif
make %{?_smp_mflags} prefix=%{buildroot}%{_prefix} mandir=%{buildroot}%{_mandir} libdir=%{buildroot}%{_libdir} \
install
%if !%{crossbuild}
# native
# \/\/\/
FULLPATH=%{buildroot}%{_prefix}/%{_lib}/gcc/%{gcc_target_platform}/%{gcc_version}
FULLEPATH=%{buildroot}%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_version}
mkdir -p $FULLPATH
mkdir -p $FULLEPATH
ln -sf gcc %{buildroot}%{_prefix}/bin/cc
mkdir -p %{buildroot}/%{_lib}
ln -sf ..%{_prefix}/bin/cpp %{buildroot}/%{_lib}/cpp
cxxconfig="`find %{gcc_target_platform}/libstdc++-v3/include -name c++config.h`"
for i in `find %{gcc_target_platform}/[36]*/libstdc++-v3/include -name c++config.h 2>/dev/null`; do
if ! diff -up $cxxconfig $i; then
cat > %{buildroot}%{_prefix}/include/c++/%{gcc_version}/%{gcc_target_platform}/bits/c++config.h <<EOF
#ifndef _CPP_CPPCONFIG_WRAPPER
#define _CPP_CPPCONFIG_WRAPPER 1
#include <bits/wordsize.h>
#if __WORDSIZE == 32
%ifarch %{multilib_64_archs}
`cat $(find %{gcc_target_platform}/32/libstdc++-v3/include -name c++config.h)`
%else
`cat $(find %{gcc_target_platform}/libstdc++-v3/include -name c++config.h)`
%endif
#else
%ifarch %{multilib_64_archs}
`cat $(find %{gcc_target_platform}/libstdc++-v3/include -name c++config.h)`
%else
`cat $(find %{gcc_target_platform}/64/libstdc++-v3/include -name c++config.h)`
%endif
#endif
#endif
EOF
break
fi
done
for f in `find %{buildroot}%{_prefix}/include/c++/%{gcc_version}/%{gcc_target_platform}/ -name c++config.h`; do
for i in 1 2 4 8; do
sed -i -e 's/#define _GLIBCXX_ATOMIC_BUILTINS_'$i' 1/#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_'$i'\
&\
#endif/' $f
done
done
# Nuke bits/stdc++.h.gch dirs
# 1) there is no bits/stdc++.h header installed, so when gch file can't be
# used, compilation fails
# 2) sometimes it is hard to match the exact options used for building
# libstdc++-v3 or they aren't desirable
# 3) there are multilib issues, conflicts etc. with this
# 4) it is huge
# People can always precompile on their own whatever they want, but
# shipping this for everybody is unnecessary.
rm -rf %{buildroot}%{_prefix}/include/c++/%{gcc_version}/%{gcc_target_platform}/bits/*.h.gch
%if %{build_libstdcxx_doc}
libstdcxx_doc_builddir=%{gcc_target_platform}/libstdc++-v3/doc/doxygen
mkdir -p ../rpm.doc/libstdc++-v3
cp -r -p ../libstdc++-v3/doc/html ../rpm.doc/libstdc++-v3/html
mv $libstdcxx_doc_builddir/html ../rpm.doc/libstdc++-v3/html/api
mkdir -p %{buildroot}%{_mandir}
mv $libstdcxx_doc_builddir/man/man3 %{buildroot}%{_mandir}/man3/
find ../rpm.doc/libstdc++-v3 -name \*~ | xargs rm
%endif
#Debug
#set -x
#find %{buildroot}%{_prefix}/
FULLLSUBDIR=
%ifarch sparcv9 ppc
FULLLSUBDIR=lib32
%endif
%ifarch sparc64 ppc64 ppc64p7
FULLLSUBDIR=lib64
%endif
if [ -n "$FULLLSUBDIR" ]; then
FULLLPATH=$FULLPATH/$FULLLSUBDIR
mkdir -p $FULLLPATH
else
FULLLPATH=$FULLPATH
fi
find %{buildroot} -name \*.la | xargs rm -f
%if %{build_d}
mv %{buildroot}%{_prefix}/%{_lib}/libgphobos.spec $FULLPATH/
%endif
%if %{build_libitm}
mv %{buildroot}%{_prefix}/%{_lib}/libitm.spec $FULLPATH/
%endif
%if %{build_libasan}
mv %{buildroot}%{_prefix}/%{_lib}/libsanitizer.spec $FULLPATH/
%endif
mkdir -p %{buildroot}/%{_lib}
mv -f %{buildroot}%{_prefix}/%{_lib}/libgcc_s.so.1 %{buildroot}/%{_lib}/libgcc_s-%{gcc_version}.so.1
chmod 755 %{buildroot}/%{_lib}/libgcc_s-%{gcc_version}.so.1
ln -sf libgcc_s-%{gcc_version}.so.1 %{buildroot}/%{_lib}/libgcc_s.so.1
%ifarch %{ix86} x86_64 ppc ppc64 ppc64p7 ppc64le %{arm} aarch64
rm -f $FULLPATH/libgcc_s.so
echo '/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT('`gcc -Wl,--print-output-format -nostdlib -r -o /dev/null`')
GROUP ( /%{_lib}/libgcc_s.so.1 libgcc.a )' > $FULLPATH/libgcc_s.so
%else
ln -sf /%{_lib}/libgcc_s.so.1 $FULLPATH/libgcc_s.so
%endif
%ifarch sparcv9 ppc
%ifarch ppc
rm -f $FULLPATH/64/libgcc_s.so
echo '/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT('`gcc -m64 -Wl,--print-output-format -nostdlib -r -o /dev/null`')
GROUP ( /lib64/libgcc_s.so.1 libgcc.a )' > $FULLPATH/64/libgcc_s.so
%else
ln -sf /lib64/libgcc_s.so.1 $FULLPATH/64/libgcc_s.so
%endif
%endif
%ifarch %{multilib_64_archs}
%ifarch x86_64 ppc64 ppc64p7
rm -f $FULLPATH/64/libgcc_s.so
echo '/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT('`gcc -m32 -Wl,--print-output-format -nostdlib -r -o /dev/null`')
GROUP ( /%{_lib}/libgcc_s.so.1 libgcc.a )' > $FULLPATH/32/libgcc_s.so
%else
ln -sf /lib/libgcc_s.so.1 $FULLPATH/32/libgcc_s.so
%endif
%endif
mv -f %{buildroot}%{_prefix}/%{_lib}/libgomp.spec $FULLPATH/
mkdir -p %{buildroot}%{_prefix}/libexec/getconf
if gcc/xgcc -B gcc/ -E -P -dD -xc /dev/null | grep '__LONG_MAX__.*\(2147483647\|0x7fffffff\($\|[LU]\)\)'; then
ln -sf POSIX_V6_ILP32_OFF32 %{buildroot}%{_prefix}/libexec/getconf/default
else
ln -sf POSIX_V6_LP64_OFF64 %{buildroot}%{_prefix}/libexec/getconf/default
fi
mkdir -p %{buildroot}%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}
mv -f %{buildroot}%{_prefix}/%{_lib}/libstdc++*gdb.py* \
%{buildroot}%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/
pushd $FULLPATH
if [ "%{_lib}" = "lib" ]; then
%if %{build_objc}
ln -sf ../../../libobjc.so.4 libobjc.so
%endif
ln -sf ../../../libstdc++.so.6.*[0-9] libstdc++.so
ln -sf ../../../libgomp.so.1.* libgomp.so
%if %{build_go}
ln -sf ../../../libgo.so.16.* libgo.so
%endif
%if %{build_libquadmath}
ln -sf ../../../libquadmath.so.0.* libquadmath.so
%endif
%if %{build_d}
ln -sf ../../../libgdruntime.so.1.* libgdruntime.so
ln -sf ../../../libgphobos.so.1.* libgphobos.so
%endif
%if %{build_libitm}
ln -sf ../../../libitm.so.1.* libitm.so
%endif
%if %{build_libatomic}
ln -sf ../../../libatomic.so.1.* libatomic.so
%endif
%if %{build_libasan}
ln -sf ../../../libasan.so.6.* libasan.so
mv ../../../libasan_preinit.o libasan_preinit.o
%endif
%if %{build_libubsan}
ln -sf ../../../libubsan.so.1.* libubsan.so
%endif
else
%if %{build_objc}
ln -sf ../../../../%{_lib}/libobjc.so.4 libobjc.so
%endif
ln -sf ../../../../%{_lib}/libstdc++.so.6.*[0-9] libstdc++.so
ln -sf ../../../../%{_lib}/libgomp.so.1.* libgomp.so
%if %{build_go}
ln -sf ../../../../%{_lib}/libgo.so.16.* libgo.so
%endif
%if %{build_libquadmath}
ln -sf ../../../../%{_lib}/libquadmath.so.0.* libquadmath.so
%endif
%if %{build_d}
ln -sf ../../../../%{_lib}/libgdruntime.so.1.* libgdruntime.so
ln -sf ../../../../%{_lib}/libgphobos.so.1.* libgphobos.so
%endif
%if %{build_libitm}
ln -sf ../../../../%{_lib}/libitm.so.1.* libitm.so
%endif
%if %{build_libatomic}
ln -sf ../../../../%{_lib}/libatomic.so.1.* libatomic.so
%endif
%if %{build_libasan}
ln -sf ../../../../%{_lib}/libasan.so.6.* libasan.so