Skip to content

Commit a340648

Browse files
Arielfoevercmuellner
authored andcommitted
Modify the enabled languages in stage2 builds to the macro @WITH_LANGUAGES@.
Use ./configure --with-languages=c,c++,fortran to adjust the enabled languages. This change only affects the GNU toolchain.
1 parent 3d5dc88 commit a340648

File tree

4 files changed

+60
-36
lines changed

4 files changed

+60
-36
lines changed

Makefile.in

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ SYSROOT := $(INSTALL_DIR)/sysroot
4646
ENABLE_LIBSANITIZER ?= @enable_libsanitizer@
4747
QEMU_TARGETS ?= @qemu_targets@
4848

49+
ENABLED_LANGUAGES ?= @WITH_LANGUAGES@
50+
ifeq ($(ENABLED_LANGUAGES),)
51+
undefine ENABLED_LANGUAGES
52+
endif
53+
4954
SHELL := /bin/sh
5055
AWK := @GAWK@
5156
SED := @GSED@
@@ -499,6 +504,7 @@ stamps/build-gcc-linux-stage1: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-binutil
499504
$(MAKE) -C $(notdir $@) inhibit-libc=true install-target-libgcc
500505
mkdir -p $(dir $@) && touch $@
501506

507+
stamps/build-gcc-linux-stage2: ENABLED_LANGUAGES?="c,c++,fortran"
502508
stamps/build-gcc-linux-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) $(addprefix stamps/build-glibc-linux-,$(GLIBC_MULTILIB_NAMES)) \
503509
stamps/build-glibc-linux-headers
504510
rm -rf $@ $(notdir $@)
@@ -512,7 +518,7 @@ stamps/build-gcc-linux-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) $(addprefix stamps/b
512518
@with_system_zlib@ \
513519
--enable-shared \
514520
--enable-tls \
515-
--enable-languages=c,c++,fortran \
521+
--enable-languages=$(ENABLED_LANGUAGES) \
516522
--disable-libmudflap \
517523
--disable-libssp \
518524
--disable-libquadmath \
@@ -558,6 +564,8 @@ stamps/build-binutils-linux-native: $(BINUTILS_SRCDIR) $(BINUTILS_SRC_GIT) stamp
558564
$(MAKE) -C $(notdir $@) install
559565
mkdir -p $(dir $@) && touch $@
560566

567+
568+
stamps/build-gcc-linux-native: ENABLED_LANGUAGES?="c,c++,fortran"
561569
stamps/build-gcc-linux-native: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-gcc-linux-stage2 stamps/build-binutils-linux-native
562570
if test -f $</contrib/download_prerequisites; then cd $< && ./contrib/download_prerequisites; fi
563571
rm -rf $@ $(notdir $@)
@@ -570,7 +578,7 @@ stamps/build-gcc-linux-native: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-gcc-lin
570578
--without-system-zlib \
571579
--enable-shared \
572580
--enable-tls \
573-
--enable-languages=c,c++,fortran \
581+
--enable-languages=$(ENABLED_LANGUAGES) \
574582
--disable-libmudflap \
575583
--disable-libssp \
576584
--disable-libquadmath \
@@ -741,6 +749,7 @@ stamps/merge-newlib-nano: stamps/build-newlib-nano stamps/build-newlib
741749
$(INSTALL_DIR)/$(NEWLIB_TUPLE)/include/newlib-nano/newlib.h; \
742750
mkdir -p $(dir $@) && touch $@
743751

752+
stamps/build-gcc-newlib-stage2: ENABLED_LANGUAGES?="c,c++"
744753
stamps/build-gcc-newlib-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-newlib \
745754
stamps/merge-newlib-nano
746755
rm -rf $@ $(notdir $@)
@@ -751,7 +760,7 @@ stamps/build-gcc-newlib-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-newlib
751760
--prefix=$(INSTALL_DIR) \
752761
--disable-shared \
753762
--disable-threads \
754-
--enable-languages=c,c++ \
763+
--enable-languages=$(ENABLED_LANGUAGES) \
755764
--with-pkgversion="$(GCCPKGVER)" \
756765
@with_system_zlib@ \
757766
--enable-tls \
@@ -901,6 +910,7 @@ stamps/build-musl-linux: $(MUSL_SRCDIR) $(MUSL_SRC_GIT) stamps/build-gcc-musl-st
901910
+flock $(SYSROOT)/.lock $(MAKE) -C $(notdir $@) install
902911
mkdir -p $(dir $@) && touch $@
903912

913+
stamps/build-gcc-musl-stage2: ENABLED_LANGUAGES?="c,c++"
904914
stamps/build-gcc-musl-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-musl-linux \
905915
stamps/build-musl-linux-headers
906916
rm -rf $@ $(notdir $@)
@@ -915,7 +925,7 @@ stamps/build-gcc-musl-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-musl-lin
915925
@with_system_zlib@ \
916926
--enable-shared \
917927
--enable-tls \
918-
--enable-languages=c,c++ \
928+
--enable-languages=$(ENABLED_LANGUAGES) \
919929
--disable-libmudflap \
920930
--disable-libssp \
921931
--disable-libquadmath \
@@ -1037,6 +1047,7 @@ stamps/build-uclibc-linux: $(UCLIBC_SRCDIR) $(UCLIBC_SRC_GIT) stamps/build-gcc-u
10371047

10381048
mkdir -p $(dir $@) && touch $@
10391049

1050+
stamps/build-gcc-uclibc-stage2: ENABLED_LANGUAGES?="c,c++"
10401051
stamps/build-gcc-uclibc-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-uclibc-linux
10411052
rm -rf $@ $(notdir $@)
10421053
mkdir $(notdir $@)
@@ -1047,7 +1058,7 @@ stamps/build-gcc-uclibc-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-uclibc
10471058
--with-sysroot=$(SYSROOT) \
10481059
@with_system_zlib@ \
10491060
--enable-tls \
1050-
--enable-languages=c,c++ \
1061+
--enable-languages=$(ENABLED_LANGUAGES) \
10511062
--disable-shared \
10521063
--disable-libmudflap \
10531064
--disable-libssp \

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ using the `--print-multi-lib` flag on either cross-compiler.
103103
Linux toolchain has an additional option `--enable-default-pie` to control the
104104
default PIE enablement for GCC, which is disable by default.
105105

106+
To customize the enabled languages, use option `--with-languages=`. For example,
107+
if you want to enable `c,c++,fortran`, use `./configure --with-languages=c,c++,fortran`.
108+
This option only takes effect for the GNU toolchain.
109+
106110
### Troubleshooting Build Problems
107111

108112
Builds work best if installing into an empty directory. If you build a

configure

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ glibc_multilib_names
646646
multilib_flags
647647
extra_multilib_test
648648
multilib_gen
649+
WITH_LANGUAGES
649650
WITH_SIM
650651
WITH_ISA_SPEC
651652
WITH_TUNE
@@ -721,6 +722,7 @@ with_abi
721722
with_tune
722723
with_isa_spec
723724
with_sim
725+
with_languages
724726
enable_multilib
725727
with_multilib_generator
726728
with_extra_multilib_test
@@ -1403,6 +1405,10 @@ Optional Packages:
14031405
Set the default ISA spec version, default to
14041406
20191213, available options: 2.2, 20190608, 20191213
14051407
--with-sim=qemu Sets the base RISC-V Simulator, defaults to qemu
1408+
--with-languages= Sets the enabled languages for GNU toolchain,
1409+
defaults to c,c++,fortran for Linux/native and
1410+
Linux/glibc or c,c++ for Bare-metal, Linux/musl and
1411+
Linux/uClibc
14061412
--with-multilib-generator
14071413
Multi-libs configuration string, only supported for
14081414
bare-metal/elf toolchain, this option implied
@@ -1928,7 +1934,9 @@ struct stat;
19281934
/* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */
19291935
struct buf { int x; };
19301936
struct buf * (*rcsopen) (struct buf *, struct stat *, int);
1931-
static char *e (char **p, int i)
1937+
static char *e (p, i)
1938+
char **p;
1939+
int i;
19321940
{
19331941
return p[i];
19341942
}
@@ -1979,7 +1987,6 @@ extern int puts (const char *);
19791987
extern int printf (const char *, ...);
19801988
extern int dprintf (int, const char *, ...);
19811989
extern void *malloc (size_t);
1982-
extern void free (void *);
19831990
19841991
// Check varargs macros. These examples are taken from C99 6.10.3.5.
19851992
// dprintf is used instead of fprintf to avoid needing to declare
@@ -3631,14 +3638,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
36313638
36323639
/* Override any GCC internal prototype to avoid an error.
36333640
Use char because int might match the return type of a GCC
3634-
builtin and then its argument prototype would still apply.
3635-
The 'extern "C"' is for builds by C++ compilers;
3636-
although this is not generally supported in C code supporting it here
3637-
has little cost and some practical benefit (sr 110532). */
3638-
#ifdef __cplusplus
3639-
extern "C"
3640-
#endif
3641-
char __gmpz_init (void);
3641+
builtin and then its argument prototype would still apply. */
3642+
char __gmpz_init ();
36423643
int
36433644
main (void)
36443645
{
@@ -3682,14 +3683,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
36823683
36833684
/* Override any GCC internal prototype to avoid an error.
36843685
Use char because int might match the return type of a GCC
3685-
builtin and then its argument prototype would still apply.
3686-
The 'extern "C"' is for builds by C++ compilers;
3687-
although this is not generally supported in C code supporting it here
3688-
has little cost and some practical benefit (sr 110532). */
3689-
#ifdef __cplusplus
3690-
extern "C"
3691-
#endif
3692-
char mpfr_init (void);
3686+
builtin and then its argument prototype would still apply. */
3687+
char mpfr_init ();
36933688
int
36943689
main (void)
36953690
{
@@ -3733,14 +3728,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
37333728
37343729
/* Override any GCC internal prototype to avoid an error.
37353730
Use char because int might match the return type of a GCC
3736-
builtin and then its argument prototype would still apply.
3737-
The 'extern "C"' is for builds by C++ compilers;
3738-
although this is not generally supported in C code supporting it here
3739-
has little cost and some practical benefit (sr 110532). */
3740-
#ifdef __cplusplus
3741-
extern "C"
3742-
#endif
3743-
char mpc_init2 (void);
3731+
builtin and then its argument prototype would still apply. */
3732+
char mpc_init2 ();
37443733
int
37453734
main (void)
37463735
{
@@ -3979,18 +3968,20 @@ else $as_nop
39793968
fi
39803969
39813970
# Check whether --enable-default-pie was given.
3982-
if test "${enable_default_pie+set}" = set; then :
3971+
if test ${enable_default_pie+y}
3972+
then :
39833973
enableval=$enable_default_pie;
3984-
else
3974+
else $as_nop
39853975
enable_default_pie=no
39863976
39873977
fi
39883978
39893979
3990-
if test "x$enable_default_pie" != xyes; then :
3980+
if test "x$enable_default_pie" != xyes
3981+
then :
39913982
enable_default_pie="--disable-default-pie"
39923983
3993-
else
3984+
else $as_nop
39943985
enable_default_pie="--enable-default-pie"
39953986
39963987
fi
@@ -4051,6 +4042,15 @@ else $as_nop
40514042
fi
40524043
40534044
4045+
4046+
# Check whether --with-languages was given.
4047+
if test ${with_languages+y}
4048+
then :
4049+
withval=$with_languages;
4050+
4051+
fi
4052+
4053+
40544054
if test "x$with_abi" = xdefault
40554055
then :
40564056
case $with_arch in #(
@@ -4084,6 +4084,8 @@ WITH_ISA_SPEC=--with-isa-spec=$with_isa_spec
40844084
40854085
WITH_SIM=$with_sim
40864086
4087+
WITH_LANGUAGES=$with_languages
4088+
40874089
40884090
# Check whether --enable-multilib was given.
40894091
if test ${enable_multilib+y}
@@ -4323,7 +4325,7 @@ else $as_nop
43234325
43244326
fi
43254327
4326-
# Check whether --enable-host_gcc was given.
4328+
# Check whether --enable-host-gcc was given.
43274329
if test ${enable_host_gcc+y}
43284330
then :
43294331
enableval=$enable_host_gcc; enable_host_gcc=yes

configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ AC_ARG_WITH(sim,
114114
[with_sim=qemu]
115115
)
116116

117+
AC_ARG_WITH(languages,
118+
[AS_HELP_STRING([--with-languages=],
119+
[Sets the enabled languages for GNU toolchain, defaults to c,c++,fortran for Linux/native and Linux/glibc or c,c++ for Bare-metal, Linux/musl and Linux/uClibc])],
120+
[]
121+
)
122+
117123
AS_IF([test "x$with_abi" = xdefault],
118124
[AS_CASE([$with_arch],
119125
[*rv64g* | *rv64*d*], [with_abi=lp64d],
@@ -131,6 +137,7 @@ AC_SUBST(WITH_ABI, --with-abi=$with_abi)
131137
AC_SUBST(WITH_TUNE, --with-tune=$with_tune)
132138
AC_SUBST(WITH_ISA_SPEC, --with-isa-spec=$with_isa_spec)
133139
AC_SUBST(WITH_SIM, $with_sim)
140+
AC_SUBST(WITH_LANGUAGES, $with_languages)
134141

135142
AC_ARG_ENABLE(multilib,
136143
[AS_HELP_STRING([--enable-multilib],

0 commit comments

Comments
 (0)