Skip to content

Commit 3c50de7

Browse files
committed
Add --enable-host-debug-info, --with-host-cflags and --with-host-cxxflags options
1. --enable-host-debug-info builds host tools (Binutils, GDB and GCC) with debug symbols. 2. --with-host-cflags and --with-host-cxxflags adds extra CFLAGS/CXXFLAGS for building host tools (Binutils, GDB and GCC). Maybe useful for debugging host tools. Note that these options affect only baremetal toolchains and they have not been tested for Linux host and native toolchains. Signed-off-by: Yuriy Kolerov <[email protected]>
1 parent 1cef9ad commit 3c50de7

File tree

3 files changed

+110
-9
lines changed

3 files changed

+110
-9
lines changed

Makefile.in

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ PK_SRCDIR := @with_pk_src@
1616
LLVM_SRCDIR := @with_llvm_src@
1717
DEJAGNU_SRCDIR := @with_dejagnu_src@
1818
DEBUG_INFO := @debug_info@
19+
HOST_DEBUG_INFO := @host_debug_info@
1920
ENABLE_DEFAULT_PIE := @enable_default_pie@
2021
DEJAGNU_SRCDIR := @with_dejagnu_src@
2122

@@ -108,6 +109,8 @@ else
108109
CMODEL_FOR_TARGET := @cmodel@
109110
endif
110111

112+
CFLAGS_FOR_HOST := $(CFLAGS_FOR_HOST_EXTRA) $(HOST_DEBUG_INFO) @host_cflags@
113+
CXXFLAGS_FOR_HOST := $(CXXFLAGS_FOR_HOST_EXTRA) $(HOST_DEBUG_INFO) @host_cxxflags@
111114
CFLAGS_FOR_TARGET := $(CFLAGS_FOR_TARGET_EXTRA) $(DEBUG_INFO) @target_cflags@ $(CMODEL_FOR_TARGET)
112115
CXXFLAGS_FOR_TARGET := $(CXXFLAGS_FOR_TARGET_EXTRA) $(DEBUG_INFO) @target_cxxflags@ $(CMODEL_FOR_TARGET)
113116
ASFLAGS_FOR_TARGET := $(ASFLAGS_FOR_TARGET_EXTRA) $(DEBUG_INFO) $(CMODEL_FOR_TARGET)
@@ -661,7 +664,9 @@ stamps/build-binutils-newlib: $(BINUTILS_SRCDIR) $(BINUTILS_SRC_GIT) $(PREPARATI
661664
--disable-sim \
662665
--disable-libdecnumber \
663666
--disable-readline \
664-
$(WITH_ISA_SPEC)
667+
$(WITH_ISA_SPEC) \
668+
CFLAGS="$(CFLAGS_FOR_HOST)" \
669+
CXXFLAGS="$(CXXFLAGS_FOR_HOST)"
665670
$(MAKE) -C $(notdir $@)
666671
$(MAKE) -C $(notdir $@) install
667672
mkdir -p $(dir $@) && touch $@
@@ -682,7 +687,9 @@ stamps/build-gdb-newlib: $(GDB_SRCDIR) $(GDB_SRC_GIT) $(PREPARATION_STAMP)
682687
--disable-binutils \
683688
--disable-ld \
684689
--disable-gold \
685-
--disable-gprof
690+
--disable-gprof \
691+
CFLAGS="$(CFLAGS_FOR_HOST)" \
692+
CXXFLAGS="$(CXXFLAGS_FOR_HOST)"
686693
$(MAKE) -C $(notdir $@)
687694
$(MAKE) -C $(notdir $@) install
688695
mkdir -p $(dir $@) && touch $@
@@ -716,6 +723,8 @@ stamps/build-gcc-newlib-stage1: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-binuti
716723
$(WITH_TUNE) \
717724
$(WITH_ISA_SPEC) \
718725
$(GCC_EXTRA_CONFIGURE_FLAGS) \
726+
CFLAGS="$(CFLAGS_FOR_HOST)" \
727+
CXXFLAGS="$(CXXFLAGS_FOR_HOST)" \
719728
CFLAGS_FOR_TARGET="-Os $(CFLAGS_FOR_TARGET)" \
720729
CXXFLAGS_FOR_TARGET="-Os $(CXXFLAGS_FOR_TARGET)"
721730
$(MAKE) -C $(notdir $@) all-gcc
@@ -830,6 +839,8 @@ stamps/build-gcc-newlib-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-newlib
830839
$(WITH_TUNE) \
831840
$(WITH_ISA_SPEC) \
832841
$(GCC_EXTRA_CONFIGURE_FLAGS) \
842+
CFLAGS="$(CFLAGS_FOR_HOST)" \
843+
CXXFLAGS="$(CXXFLAGS_FOR_HOST)" \
833844
CFLAGS_FOR_TARGET="-Os $(CFLAGS_FOR_TARGET)" \
834845
CXXFLAGS_FOR_TARGET="-Os $(CXXFLAGS_FOR_TARGET)"
835846
$(MAKE) -C $(notdir $@)

configure

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,8 @@ enable_gdb
636636
with_guile
637637
with_system_zlib
638638
configure_host
639+
host_cxxflags
640+
host_cflags
639641
target_cxxflags
640642
target_cflags
641643
cmodel
@@ -652,9 +654,10 @@ WITH_ISA_SPEC
652654
WITH_TUNE
653655
WITH_ABI
654656
WITH_ARCH
655-
enable_default_pie
656657
vendor_alias
657658
vendor
659+
enable_default_pie
660+
host_debug_info
658661
debug_info
659662
default_target
660663
FETCHER
@@ -718,6 +721,7 @@ ac_user_opts='
718721
enable_option_checking
719722
enable_linux
720723
enable_debug_info
724+
enable_host_debug_info
721725
enable_default_pie
722726
with_vendor
723727
with_vendor_alias
@@ -734,6 +738,8 @@ enable_gcc_checking
734738
with_cmodel
735739
with_target_cflags
736740
with_target_cxxflags
741+
with_host_cflags
742+
with_host_cxxflags
737743
with_host
738744
with_system_zlib
739745
with_guile
@@ -1386,6 +1392,9 @@ Optional Features:
13861392
[--disable-linux]
13871393
--enable-debug-info build glibc/musl/newlibc/libgcc with debug
13881394
information
1395+
--enable-host-debug-info
1396+
build host Binutils, GDB and GCC with debug
1397+
information
13891398
--enable-default-pie build linux toolchain with default PIE
13901399
[--enable-default-pie]
13911400
--enable-multilib build both RV32 and RV64 runtime libraries
@@ -1402,10 +1411,10 @@ Optional Features:
14021411
Optional Packages:
14031412
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
14041413
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
1405-
--with-arch=rv64gc Sets the base RISC-V ISA, defaults to rv64gc
14061414
--with-vendor=unknown Sets the vendor part of the triplet
14071415
--with-vendor-alias=unknown
14081416
Sets the vendor part of the triplet alias
1417+
--with-arch=rv64gc Sets the base RISC-V ISA, defaults to rv64gc
14091418
--with-abi=lp64d Sets the base RISC-V ABI, defaults to lp64d
14101419
--with-tune=rocket Set the base RISC-V CPU, defaults to rocket
14111420
--with-isa-spec=20191213
@@ -1431,6 +1440,9 @@ Optional Packages:
14311440
libgcc [--with-cmodel=medlow]
14321441
--with-target-cflags Add extra target flags for C for library code
14331442
--with-target-cxxflags Add extra target flags for C++ for library code
1443+
--with-host-cflags Add extra flags for C for host Binutils, GDB and GCC
1444+
--with-host-cxxflags Add extra flags for C++ for host Binutils, GDB and
1445+
GCC
14341446
--with-host=x86_64-w64-mingw32
14351447
Sets the host for the tools, you probably want
14361448
nothing
@@ -3974,6 +3986,33 @@ else $as_nop
39743986
39753987
fi
39763988
3989+
# Check whether --enable-host_debug_info was given.
3990+
if test ${enable_host_debug_info+y}
3991+
then :
3992+
enableval=$enable_host_debug_info; enable_host_debug_info=yes
3993+
else $as_nop
3994+
enable_host_debug_info=no
3995+
3996+
fi
3997+
3998+
3999+
if test "x$enable_host_debug_info" != xyes
4000+
then :
4001+
disable_host_debug_info=yes
4002+
else $as_nop
4003+
disable_host_debug_info=no
4004+
4005+
fi
4006+
4007+
if test "x$enable_host_debug_info" != xyes
4008+
then :
4009+
host_debug_info=""
4010+
4011+
else $as_nop
4012+
host_debug_info="-g"
4013+
4014+
fi
4015+
39774016
# Check whether --enable-default-pie was given.
39784017
if test ${enable_default_pie+y}
39794018
then :
@@ -3994,21 +4033,22 @@ else $as_nop
39944033
fi
39954034
39964035
3997-
39984036
# Check whether --with-vendor was given.
3999-
if test "${with_vendor+set}" = set; then :
4037+
if test ${with_vendor+y}
4038+
then :
40004039
withval=$with_vendor;
4001-
else
4040+
else $as_nop
40024041
with_vendor=unknown
40034042
40044043
fi
40054044
40064045
40074046
40084047
# Check whether --with-vendor_alias was given.
4009-
if test "${with_vendor_alias+set}" = set; then :
4048+
if test ${with_vendor_alias+y}
4049+
then :
40104050
withval=$with_vendor_alias;
4011-
else
4051+
else $as_nop
40124052
with_vendor_alias=unknown
40134053
40144054
fi
@@ -4254,6 +4294,25 @@ fi
42544294
target_cxxflags=$with_target_cxxflags
42554295
42564296
4297+
4298+
# Check whether --with-host_cflags was given.
4299+
if test ${with_host_cflags+y}
4300+
then :
4301+
withval=$with_host_cflags;
4302+
fi
4303+
4304+
host_cflags=$with_host_cflags
4305+
4306+
4307+
# Check whether --with-host_cxxflags was given.
4308+
if test ${with_host_cxxflags+y}
4309+
then :
4310+
withval=$with_host_cxxflags;
4311+
fi
4312+
4313+
host_cxxflags=$with_host_cxxflags
4314+
4315+
42574316
ac_config_files="$ac_config_files Makefile"
42584317
42594318
ac_config_files="$ac_config_files scripts/wrapper/awk/awk"

configure.ac

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ AS_IF([test "x$enable_debug_info" != xyes],
6767
[AC_SUBST(debug_info, "")],
6868
[AC_SUBST(debug_info, "-g")])
6969

70+
AC_ARG_ENABLE(host_debug_info,
71+
[AS_HELP_STRING([--enable-host-debug-info],
72+
[build host Binutils, GDB and GCC with debug information])],
73+
[enable_host_debug_info=yes],
74+
[enable_host_debug_info=no]
75+
)
76+
77+
AS_IF([test "x$enable_host_debug_info" != xyes],
78+
[disable_host_debug_info=yes],
79+
[disable_host_debug_info=no]
80+
)
81+
82+
AS_IF([test "x$enable_host_debug_info" != xyes],
83+
[AC_SUBST(host_debug_info, "")],
84+
[AC_SUBST(host_debug_info, "-g")])
85+
7086
AC_ARG_ENABLE(default-pie,
7187
[AS_HELP_STRING([--enable-default-pie],
7288
[build linux toolchain with default PIE @<:@--enable-default-pie@:>@])],
@@ -234,6 +250,21 @@ AC_ARG_WITH(target_cxxflags,
234250
)
235251
AC_SUBST(target_cxxflags, $with_target_cxxflags)
236252

253+
AC_ARG_WITH(host_cflags,
254+
[AS_HELP_STRING([--with-host-cflags],
255+
[Add extra flags for C for host Binutils, GDB and GCC])],
256+
[],
257+
[]
258+
)
259+
AC_SUBST(host_cflags, $with_host_cflags)
260+
AC_ARG_WITH(host_cxxflags,
261+
[AS_HELP_STRING([--with-host-cxxflags],
262+
[Add extra flags for C++ for host Binutils, GDB and GCC])],
263+
[],
264+
[]
265+
)
266+
AC_SUBST(host_cxxflags, $with_host_cxxflags)
267+
237268
AC_CONFIG_FILES([Makefile])
238269
AC_CONFIG_FILES([scripts/wrapper/awk/awk], [chmod +x scripts/wrapper/awk/awk])
239270
AC_CONFIG_FILES([scripts/wrapper/sed/sed], [chmod +x scripts/wrapper/sed/sed])

0 commit comments

Comments
 (0)