Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for cargo when building rust language #2942

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config/acx.m4
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,17 @@ else
fi
])

# Test for Rust
# We require cargo and rustc for some parts of the rust compiler.
AC_DEFUN([ACX_PROG_CARGO],
[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
AC_CHECK_TOOL(CARGO, cargo, no)
if test "x$CARGO" != xno; then
have_cargo=yes
else
have_cargo=no
fi])

# Test for D.
AC_DEFUN([ACX_PROG_GDC],
[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
Expand Down
117 changes: 117 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ PGO_BUILD_GEN_CFLAGS
HAVE_CXX11_FOR_BUILD
HAVE_CXX11
do_compare
CARGO
GDC
GNATMAKE
GNATBIND
Expand Down Expand Up @@ -5787,6 +5788,104 @@ else
have_gdc=no
fi


if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}cargo", so it can be a program name with args.
set dummy ${ac_tool_prefix}cargo; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CARGO+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CARGO"; then
ac_cv_prog_CARGO="$CARGO" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CARGO="${ac_tool_prefix}cargo"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS

fi
fi
CARGO=$ac_cv_prog_CARGO
if test -n "$CARGO"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CARGO" >&5
$as_echo "$CARGO" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_CARGO"; then
ac_ct_CARGO=$CARGO
# Extract the first word of "cargo", so it can be a program name with args.
set dummy cargo; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_CARGO+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CARGO"; then
ac_cv_prog_ac_ct_CARGO="$ac_ct_CARGO" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CARGO="cargo"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS

fi
fi
ac_ct_CARGO=$ac_cv_prog_ac_ct_CARGO
if test -n "$ac_ct_CARGO"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CARGO" >&5
$as_echo "$ac_ct_CARGO" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

if test "x$ac_ct_CARGO" = x; then
CARGO="no"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CARGO=$ac_ct_CARGO
fi
else
CARGO="$ac_cv_prog_CARGO"
fi

if test "x$CARGO" != xno; then
have_cargo=yes
else
have_cargo=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to compare bootstrapped objects" >&5
$as_echo_n "checking how to compare bootstrapped objects... " >&6; }
if ${gcc_cv_prog_cmp_skip+:} false; then :
Expand Down Expand Up @@ -9254,6 +9353,24 @@ $as_echo "$as_me: WARNING: --enable-host-shared required to build $language" >&2
;;
esac

# Disable Rust if cargo is unavailable.
case ${add_this_lang}:${language}:${have_cargo} in
yes:rust:no)
# Specifically requested language; tell them.
as_fn_error $? "cargo is required to build $language" "$LINENO" 5
;;
all:rust:no)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cargo is required to build $language" >&5
$as_echo "$as_me: WARNING: cargo is required to build $language" >&2;}
add_this_lang=unsupported
;;
*:rust:no)
# Silently disable.
add_this_lang=unsupported
;;
esac


# Disable a language that is unsupported by the target.
case "${add_this_lang}: $unsupported_languages " in
no:*) ;;
Expand Down
18 changes: 18 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,7 @@ fi

ACX_PROG_GNAT
ACX_PROG_GDC
ACX_PROG_CARGO
ACX_PROG_CMP_IGNORE_INITIAL

AC_ARG_ENABLE([bootstrap],
Expand Down Expand Up @@ -2347,6 +2348,23 @@ directories, to avoid imposing the performance cost of
;;
esac

# Disable Rust if cargo is unavailable.
case ${add_this_lang}:${language}:${have_cargo} in
yes:rust:no)
# Specifically requested language; tell them.
AC_MSG_ERROR([cargo is required to build $language])
;;
all:rust:no)
AC_MSG_WARN([cargo is required to build $language])
add_this_lang=unsupported
;;
*:rust:no)
# Silently disable.
add_this_lang=unsupported
;;
esac


# Disable a language that is unsupported by the target.
case "${add_this_lang}: $unsupported_languages " in
no:*) ;;
Expand Down
16 changes: 16 additions & 0 deletions gcc/doc/install.texi
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,13 @@ documentation including the target @code{SYSTEM} definition module.
If Python3 is unavailable Modula-2 documentation will include a target
independent version of the SYSTEM modules.

@item @anchor{GCCRS-prerequisite}Rust

In order to build GCCRS you need a working rust compiler, for now we
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In order to build GCCRS you need a working rust compiler, for now we
In order to build GCCRS, you need a working Rust compiler. For now, we

are using cargo and rustc but in the future GCC will be able to compile
it's own rust components and recompile itself with those components
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it's own rust components and recompile itself with those components
its own rust components and recompile itself with those components

included.

@item A ``working'' POSIX compatible shell, or GNU bash

Necessary when running @command{configure} because some
Expand Down Expand Up @@ -3227,6 +3234,15 @@ and network filesystems.
@uref{prerequisites.html#GDC-prerequisite,,GDC prerequisites}.
@end ifhtml

@section Building the Rust compiler

@ifnothtml
@ref{GCCRS-prerequisite}.
@end ifnothtml
@ifhtml
@uref{prerequisites.html#GCCRS-prerequisite,,GCCRS prerequisites}.
@end ifhtml

@section Building with profile feedback

It is possible to use profile feedback to optimize the compiler itself. This
Expand Down
Loading