Skip to content

Commit

Permalink
Rust: Move 'libformat_parser' build into libgrust
Browse files Browse the repository at this point in the history
Addresses Rust-GCC#2883.

	contrib/
	* gcc_update (files_and_dependencies): Update for
	'libformat_parser' in libgrust.
	gcc/rust/
	* Make-lang.in (LIBFORMAT_PARSER): Point to 'libformat_parser'
	build in libgrust.
	(%.toml:, $(LIBFORMAT_PARSER):): Remove.
	libgrust/
	* libformat_parser/Makefile.am: New.
	* Makefile.am [!TARGET_LIBRARY] (SUBDIRS): Add 'libformat_parser'.
	* configure.ac: Handle it.
	(TARGET_LIBRARY): New 'AM_CONDITIONAL'.
	* libformat_parser/Makefile.in: Generate.
	* Makefile.in: Regenerate.
	* configure: Likewise.
  • Loading branch information
tschwinge committed Apr 16, 2024
1 parent 8dde956 commit 611d0bd
Show file tree
Hide file tree
Showing 8 changed files with 487 additions and 20 deletions.
1 change: 1 addition & 0 deletions contrib/gcc_update
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ libgomp/config.h.in: libgomp/configure.ac libgomp/aclocal.m4
libgrust/Makefile.in: libgrust/Makefile.am libgrust/aclocal.m4
libgrust/aclocal.m4: libgrust/configure.ac
libgrust/configure: libgrust/configure.ac libgrust/aclocal.m4
libgrust/libformat_parser/Makefile.in: libgrust/libformat_parser/Makefile.am libgrust/aclocal.m4
libgrust/libproc_macro_internal/Makefile.in: libgrust/libproc_macro_internal/Makefile.am libgrust/aclocal.m4
libitm/aclocal.m4: libitm/configure.ac libitm/acinclude.m4
libitm/Makefile.in: libitm/Makefile.am libitm/aclocal.m4
Expand Down
16 changes: 1 addition & 15 deletions gcc/rust/Make-lang.in
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o

LIBPROC_MACRO_INTERNAL = ../libgrust/libproc_macro_internal/libproc_macro_internal.a
LIBFORMAT_PARSER_D = rust/libformat_parser
LIBFORMAT_PARSER = $(LIBFORMAT_PARSER_D)/debug/liblibformat_parser.a
LIBFORMAT_PARSER = ../libgrust/libformat_parser/debug/liblibformat_parser.a

# The compiler itself is called crab1
crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) $(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(rust.prev)
Expand Down Expand Up @@ -419,19 +418,6 @@ rust/%.o: rust/lex/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)

%.toml:
echo $@

# TODO: Improve `cargo` invocation with host specific flags, possibly creating a $(CARGO) variable?
$(LIBFORMAT_PARSER): $(srcdir)/../libgrust/libformat_parser/Cargo.toml $(wildcard $(srcdir)/../libgrust/libformat_parser/src/*.rs)
cargo \
--config $(srcdir)/../libgrust/libformat_parser/.cargo/config \
build \
--offline \
--target-dir $(LIBFORMAT_PARSER_D) \
--manifest-path $(srcdir)/../libgrust/libformat_parser/Cargo.toml \
# FIXME: Not always '--release', right?

# build all rust/parse files in rust folder, add cross-folder includes
rust/%.o: rust/parse/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
Expand Down
6 changes: 5 additions & 1 deletion libgrust/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ TOP_GCCDIR := $(shell cd $(top_srcdir) && cd .. && pwd)
GCC_DIR = $(TOP_GCCDIR)/gcc
RUST_SRC = $(GCC_DIR)/rust

SUBDIRS = libproc_macro_internal
SUBDIRS =
if !TARGET_LIBRARY
SUBDIRS += libformat_parser
endif
SUBDIRS += libproc_macro_internal

RUST_BUILDDIR := $(shell pwd)

Expand Down
5 changes: 3 additions & 2 deletions libgrust/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
@TARGET_LIBRARY_FALSE@am__append_1 = libformat_parser
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
Expand Down Expand Up @@ -165,7 +166,7 @@ am__define_uniq_tagged_files = \
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
DIST_SUBDIRS = libformat_parser libproc_macro_internal
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
Expand Down Expand Up @@ -308,7 +309,7 @@ AM_CFLAGS = -I $(srcdir)/../libgcc -I $(MULTIBUILDTOP)../../gcc/include
TOP_GCCDIR := $(shell cd $(top_srcdir) && cd .. && pwd)
GCC_DIR = $(TOP_GCCDIR)/gcc
RUST_SRC = $(GCC_DIR)/rust
SUBDIRS = libproc_macro_internal
SUBDIRS = $(am__append_1) libproc_macro_internal
RUST_BUILDDIR := $(shell pwd)

# Work around what appears to be a GNU make bug handling MAKEFLAGS
Expand Down
22 changes: 20 additions & 2 deletions libgrust/configure
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@ am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
get_gcc_base_ver
TARGET_LIBRARY_FALSE
TARGET_LIBRARY_TRUE
toolexeclibdir
toolexecdir
target_subdir
Expand Down Expand Up @@ -12655,7 +12657,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12658 "configure"
#line 12660 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -12761,7 +12763,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12764 "configure"
#line 12766 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -16192,6 +16194,17 @@ esac



if test -n "$with_target_subdir"; then
TARGET_LIBRARY_TRUE=
TARGET_LIBRARY_FALSE='#'
else
TARGET_LIBRARY_TRUE='#'
TARGET_LIBRARY_FALSE=
fi


ac_config_files="$ac_config_files libformat_parser/Makefile"


ac_config_files="$ac_config_files libproc_macro_internal/Makefile"

Expand Down Expand Up @@ -16398,6 +16411,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then
as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${TARGET_LIBRARY_TRUE}" && test -z "${TARGET_LIBRARY_FALSE}"; then
as_fn_error $? "conditional \"TARGET_LIBRARY\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi

: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
Expand Down Expand Up @@ -17348,6 +17365,7 @@ do
"default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
"depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
"libformat_parser/Makefile") CONFIG_FILES="$CONFIG_FILES libformat_parser/Makefile" ;;
"libproc_macro_internal/Makefile") CONFIG_FILES="$CONFIG_FILES libproc_macro_internal/Makefile" ;;

*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
Expand Down
3 changes: 3 additions & 0 deletions libgrust/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ esac
AC_SUBST(toolexecdir)
AC_SUBST(toolexeclibdir)

AM_CONDITIONAL(TARGET_LIBRARY, test -n "$with_target_subdir")

AC_CONFIG_FILES([libformat_parser/Makefile])

AC_CONFIG_FILES(AC_FOREACH([DIR], [libproc_macro_internal], [DIR/Makefile ]),
[ cat > vpsed$$ << \_EOF
Expand Down
13 changes: 13 additions & 0 deletions libgrust/libformat_parser/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
LIBFORMAT_PARSER = debug/liblibformat_parser.a

all-local: $(LIBFORMAT_PARSER)

# TODO: Improve `cargo` invocation with host specific flags, possibly creating a $(CARGO) variable?
$(LIBFORMAT_PARSER): $(srcdir)/Cargo.toml $(srcdir)/src/*.rs
cargo \
--config $(srcdir)/.cargo/config \
build \
--offline \
--target-dir . \
--manifest-path $(srcdir)/Cargo.toml \
# FIXME: Not always '--release', right?
Loading

0 comments on commit 611d0bd

Please sign in to comment.