3
3
# Include utils library
4
4
script_dir=$( dirname " $0 " )
5
5
source " $script_dir /utils.sh"
6
+ source " $script_dir /full_build_conf.sh"
6
7
7
8
# Don't want random unknown things to fail in the build procecss!
8
9
set -e
@@ -50,36 +51,53 @@ function set_compliation_variables() {
50
51
export CC=" ${CROSS} gcc"
51
52
export CXX=" ${CROSS} g++"
52
53
53
- export CFLAGS=" -O2 "
54
- export CXXFLAGS=" -O2 "
54
+ export CFLAGS=" -Os "
55
+ export CXXFLAGS=" -Os "
55
56
56
57
# Strip the binary to reduce it's size.
57
58
export LDFLAGS=" -s"
58
59
}
59
60
60
- function set_up_lib_search_paths() {
61
+ function set_up_lib_search_path() {
62
+ # Set up library-related linker search paths.
63
+ #
64
+ # Parameters:
65
+ # $1: library install dir
66
+ # $2: whether to add linker search path or not (include path is always added).
67
+ local lib_install_dir=" $1 "
68
+ local add_linker_include_path=" $2 "
69
+
70
+ if [[ $add_linker_include_path == 1 ]]; then
71
+ # Add library to the linker's include path.
72
+ export LDFLAGS=" -L$lib_install_dir /lib $LDFLAGS "
73
+ fi
74
+
75
+ # Add library standard headers to the CC / CXX flags.
76
+ local include_paths=" -I$lib_install_dir /include"
77
+ export CC=" $CC $include_paths "
78
+ export CXX=" $CXX $include_paths "
79
+ }
80
+
81
+ function set_up_base_lib_search_paths() {
61
82
# Set up library-related linker search paths.
62
83
#
63
84
# Parameters:
64
85
# $1: iconv build dir
65
86
# $2: gmp build dir
66
87
# $3: mpfr build dir
67
88
# $4: ncursesw build dir
68
- # $5: libexpat build dir
89
+ # $5: expat build dir
69
90
local iconv_build_dir=" $1 "
70
91
local gmp_build_dir=" $2 "
71
92
local mpfr_build_dir=" $3 "
72
93
local ncursesw_build_dir=" $4 "
73
- local libexpat_build_dir =" $5 "
94
+ local expat_build_dir =" $5 "
74
95
75
- # I) Allow tui mode by adding our custom built static ncursesw library to the linker search path.
76
- # II) Allow parsing xml files by adding libexpat library to the linker search path.
77
- export LDFLAGS=" -L$ncursesw_build_dir /lib -L$libexpat_build_dir /lib/ $LDFLAGS "
78
-
79
- # Add library standard headers to the CC / CXX flags.
80
- export INCLUDE_PATHS=" -I$iconv_build_dir /include -I$gmp_build_dir /include -I$mpfr_build_dir /include -I$ncursesw_build_dir /include -I$libexpat_build_dir /include"
81
- export CC=" $CC $INCLUDE_PATHS "
82
- export CXX=" $CXX $INCLUDE_PATHS "
96
+ set_up_lib_search_path $iconv_build_dir 0
97
+ set_up_lib_search_path $gmp_build_dir 0
98
+ set_up_lib_search_path $mpfr_build_dir 0
99
+ set_up_lib_search_path $ncursesw_build_dir 1
100
+ set_up_lib_search_path $expat_build_dir 1
83
101
}
84
102
85
103
function build_iconv() {
@@ -489,10 +507,11 @@ function build_gdb() {
489
507
# $1: gdb directory
490
508
# $2: target architecture
491
509
# $3: libiconv prefix
492
- # $4: liblzma prefix
493
- # $5: libgmp prefix
494
- # $6: libmpfr prefix
495
- # $7: whether to build with python or not
510
+ # $4: libgmp prefix
511
+ # $5: libmpfr prefix
512
+ # $6: liblzma prefix
513
+ # $7: whether to build gdb with all extra configurations specified in src/compilation/full_build_conf.sh
514
+ # $8: gdb cross-architecture binary format support formats (relevant for full builds only).
496
515
#
497
516
# Echoes:
498
517
# The gdb build directory
@@ -504,17 +523,28 @@ function build_gdb() {
504
523
local gdb_dir=" $1 "
505
524
local target_arch=" $2 "
506
525
local libiconv_prefix=" $3 "
507
- local liblzma_prefix=" $4 "
508
- local libgmp_prefix=" $5 "
509
- local libmpfr_prefix=" $6 "
510
- local with_python=" $7 "
511
-
512
- if [[ " $with_python " == " yes" ]]; then
513
- local python_flag=" --with-python=/app/gdb/build/packages/cpython-static/build-$target_arch /bin/python3-config"
514
- local gdb_build_dir=" $( realpath " $gdb_dir /build-${target_arch} _with_python" ) "
526
+ local libgmp_prefix=" $4 "
527
+ local libmpfr_prefix=" $5 "
528
+ local liblzma_prefix=" $6 "
529
+ local full_build=" $7 "
530
+ local gdb_bfd_archs=" $8 "
531
+
532
+ local extra_flags=()
533
+ if [[ " $full_build " == " yes" ]]; then
534
+ if [[ $full_build_supported_targets -eq 1 ]]; then
535
+ extra_flags+=(" --enable-targets=$gdb_bfd_archs " " --enable-64-bit-bfd" )
536
+ fi
537
+
538
+ if [[ $full_build_python_support -eq 1 ]]; then
539
+ extra_flags+=(" --with-python=/app/gdb/build/packages/cpython-static/build-$target_arch /bin/python3-config" )
540
+ else
541
+ extra_flags+=(" --without-python" )
542
+ fi
543
+
544
+ local gdb_build_dir=" $( realpath " $gdb_dir /build-${target_arch} _full" ) "
515
545
else
516
- local python_flag= " --without-python"
517
- local gdb_build_dir=" $( realpath " $gdb_dir /build-${target_arch} " ) "
546
+ extra_flags+=( " --without-python" )
547
+ local gdb_build_dir=" $( realpath " $gdb_dir /build-${target_arch} _slim " ) "
518
548
fi
519
549
520
550
echo " $gdb_build_dir "
@@ -530,16 +560,16 @@ function build_gdb() {
530
560
>&2 fancy_title " Building gdb for $target_arch "
531
561
532
562
../configure --enable-static --with-static-standard-libraries --disable-inprocess-agent \
533
- --enable-targets=all --enable-64-bit-bfd \
534
- --enable-tui " $python_flag " \
535
- --with-expat --with-libexpat-type=" static" \
536
563
--with-gdb-datadir=" /usr/share/gdb" --with-separate-debug-dir=" /usr/lib/debug" \
537
564
--with-system-gdbinit=" /etc/gdb/gdbinit" --with-system-gdbinit-dir=" /etc/gdb/gdbinit.d" \
538
565
--with-jit-reader-dir=" /usr/lib/gdb" \
539
- " --with-libiconv-prefix=$libiconv_prefix " --with-libiconv-type=static \
540
- " --with-liblzma-prefix=$liblzma_prefix " --with-liblzma-type=static --with-lzma=yes \
541
- " --with-gmp=$libgmp_prefix " \
542
- " --with-mpfr=$libmpfr_prefix " \
566
+ --with-libiconv-prefix=" $libiconv_prefix " --with-libiconv-type=static \
567
+ --with-gmp=" $libgmp_prefix " \
568
+ --with-mpfr=" $libmpfr_prefix " \
569
+ --enable-tui \
570
+ --with-expat --with-libexpat-type=static \
571
+ --with-lzma=yes --with-liblzma-prefix=" $liblzma_prefix " --with-liblzma-type=" static" \
572
+ " ${extra_flags[@]} " \
543
573
" CC=$CC " " CXX=$CXX " " LDFLAGS=$LDFLAGS " " --host=$HOST " \
544
574
" CFLAGS=$CFLAGS " " CXXFLAGS=$CXXFLAGS " 1>&2
545
575
if [[ $? -ne 0 ]]; then
@@ -563,7 +593,7 @@ function install_gdb() {
563
593
# $1: gdb build directory
564
594
# $2: artifacts directory
565
595
# $3: target architecture
566
- # $4: whether gdb was built with or without python
596
+ # $4: whether to build gdb with all extra configurations specified in src/compilation/full_build_conf.sh
567
597
#
568
598
# Returns:
569
599
# 0: success
@@ -572,12 +602,12 @@ function install_gdb() {
572
602
local gdb_build_dir=" $1 "
573
603
local artifacts_dir=" $2 "
574
604
local target_arch=" $3 "
575
- local with_python =" $4 "
605
+ local full_build =" $4 "
576
606
577
- if [[ " $with_python " == " yes" ]]; then
578
- local artifacts_location=" $artifacts_dir /${target_arch} _with_python "
607
+ if [[ " $full_build " == " yes" ]]; then
608
+ local artifacts_location=" $artifacts_dir /${target_arch} _full "
579
609
else
580
- local artifacts_location=" $artifacts_dir /${target_arch} "
610
+ local artifacts_location=" $artifacts_dir /${target_arch} _slim "
581
611
fi
582
612
583
613
if [[ -d " $artifacts_location " && -n " $( ls -A " $artifacts_location " ) " ]]; then
@@ -608,32 +638,34 @@ function build_and_install_gdb() {
608
638
# Parameters:
609
639
# $1: gdb package directory
610
640
# $2: libiconv prefix
611
- # $3: liblzma prefix
612
- # $4: libgmp prefix
613
- # $5: libmpfr prefix
614
- # $6: whether to build with python or not
615
- # $7: install directory
616
- # $8: target architecture
641
+ # $3: libgmp prefix
642
+ # $4: libmpfr prefix
643
+ # $5: liblzma prefix.
644
+ # $6: whether to build gdb with all extra configurations specified in src/compilation/full_build_conf.sh
645
+ # $7: gdb cross-architecture binary format support formats (relevant for full builds only).
646
+ # $8: install directory
647
+ # $9: target architecture
617
648
#
618
649
# Returns:
619
650
# 0: success
620
651
# 1: failure
621
652
622
653
local gdb_dir=" $1 "
623
654
local libiconv_prefix=" $2 "
624
- local liblzma_prefix=" $3 "
625
- local libgmp_prefix=" $4 "
626
- local libmpfr_prefix=" $5 "
627
- local with_python=" $6 "
628
- local artifacts_dir=" $7 "
629
- local target_arch=" $8 "
655
+ local libgmp_prefix=" $3 "
656
+ local libmpfr_prefix=" $4 "
657
+ local liblzma_prefix=" $5 "
658
+ local full_build=" $6 "
659
+ local gdb_bfd_archs=" $7 "
660
+ local artifacts_dir=" $8 "
661
+ local target_arch=" $9 "
630
662
631
- gdb_build_dir=" $( build_gdb " $gdb_dir " " $target_arch " " $libiconv_prefix " " $liblzma_prefix " " $libgmp_prefix " " $libmpfr_prefix " " $with_python " ) "
663
+ gdb_build_dir=" $( build_gdb " $gdb_dir " " $target_arch " " $libiconv_prefix " " $libgmp_prefix " " $libmpfr_prefix " " $liblzma_prefix " " $full_build " " $gdb_bfd_archs " ) "
632
664
if [[ $? -ne 0 ]]; then
633
665
return 1
634
666
fi
635
667
636
- install_gdb " $gdb_build_dir " " $artifacts_dir " " $target_arch " " $with_python "
668
+ install_gdb " $gdb_build_dir " " $artifacts_dir " " $target_arch " " $full_build "
637
669
if [[ $? -ne 0 ]]; then
638
670
return 1
639
671
fi
@@ -646,12 +678,14 @@ function build_gdb_with_dependencies() {
646
678
# $1: target architecture
647
679
# $2: build directory
648
680
# $3: src directory
649
- # $4: whether to build gdb with python or not
681
+ # $4: whether to build gdb with all extra configurations specified in src/compilation/full_build_conf.sh
682
+ # $5: gdb cross-architecture binary format support formats (relevant for full builds only).
650
683
651
684
local target_arch=" $1 "
652
685
local build_dir=" $2 "
653
686
local source_dir=" $3 "
654
- local with_python=" $4 "
687
+ local full_build=" $4 "
688
+ local gdb_bfd_archs=" $5 "
655
689
local packages_dir=" $build_dir /packages"
656
690
local artifacts_dir=" $build_dir /artifacts"
657
691
@@ -667,11 +701,6 @@ function build_gdb_with_dependencies() {
667
701
return 1
668
702
fi
669
703
670
- lzma_build_dir=" $( build_lzma " $packages_dir /xz" " $target_arch " ) "
671
- if [[ $? -ne 0 ]]; then
672
- return 1
673
- fi
674
-
675
704
gmp_build_dir=" $( build_libgmp " $packages_dir /gmp" " $target_arch " ) "
676
705
if [[ $? -ne 0 ]]; then
677
706
return 1
@@ -692,13 +721,19 @@ function build_gdb_with_dependencies() {
692
721
return 1
693
722
fi
694
723
695
- set_up_lib_search_paths " $iconv_build_dir " \
696
- " $gmp_build_dir " \
697
- " $mpfr_build_dir " \
698
- " $ncursesw_build_dir " \
699
- " $libexpat_build_dir "
724
+ lzma_build_dir=" $( build_lzma " $packages_dir /xz" " $target_arch " ) "
725
+ if [[ $? -ne 0 ]]; then
726
+ return 1
727
+ fi
728
+
729
+ set_up_base_lib_search_paths " $iconv_build_dir " \
730
+ " $gmp_build_dir " \
731
+ " $mpfr_build_dir " \
732
+ " $ncursesw_build_dir " \
733
+ " $libexpat_build_dir "
700
734
701
- if [[ " $with_python " == " yes" ]]; then
735
+ # Optional build components
736
+ if [[ $full_build == " yes" && $full_build_python_support -eq 1 ]]; then
702
737
local gdb_python_dir=" $packages_dir /binutils-gdb/gdb/python/lib/"
703
738
local pygments_source_dir=" $packages_dir /pygments/"
704
739
local python_build_dir=" $( build_python " $packages_dir /cpython-static" " $target_arch " " $gdb_python_dir " " $pygments_source_dir " ) "
@@ -709,10 +744,11 @@ function build_gdb_with_dependencies() {
709
744
710
745
build_and_install_gdb " $packages_dir /binutils-gdb" \
711
746
" $iconv_build_dir " \
712
- " $lzma_build_dir " \
713
747
" $gmp_build_dir " \
714
748
" $mpfr_build_dir " \
715
- " $with_python " \
749
+ " $lzma_build_dir " \
750
+ " $full_build " \
751
+ " $gdb_bfd_archs " \
716
752
" $artifacts_dir " \
717
753
" $target_arch "
718
754
if [[ $? -ne 0 ]]; then
@@ -721,17 +757,19 @@ function build_gdb_with_dependencies() {
721
757
}
722
758
723
759
function main() {
724
- if [[ $# -lt 3 ]]; then
725
- >&2 echo " Usage: $0 <target_arch> <build_dir> <src_dir> [--with-python ]"
760
+ if [[ $# -lt 4 ]]; then
761
+ >&2 echo " Usage: $0 <target_arch> <build_dir> <src_dir> <slim/full> [gdb-bfd-archs ]"
726
762
exit 1
727
763
fi
728
764
729
- local with_python=" no"
730
- if [[ " $4 " == " --with-python" ]]; then
731
- with_python=" yes"
765
+ local full_build=" no"
766
+ if [[ " $4 " == " full" ]]; then
767
+ full_build=" yes"
768
+ else
769
+ full_build=" no"
732
770
fi
733
771
734
- build_gdb_with_dependencies " $1 " " $2 " " $3 " " $with_python "
772
+ build_gdb_with_dependencies " $1 " " $2 " " $3 " " $full_build " " $5 "
735
773
if [[ $? -ne 0 ]]; then
736
774
>&2 echo " Error: failed to build gdb with dependencies"
737
775
exit 1
0 commit comments