@@ -1504,6 +1504,9 @@ BACKEND = libbackend.a main.o @TREEBROWSER@ libcommon-target.a libcommon.a \
# front-end checking.
TREECHECKING = @TREECHECKING@
+# The full name of the driver on installation
+FULL_DRIVER_NAME=$(target_noncanonical)-gcc-$(version)$(exeext)
+
MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
insn-output.c insn-recog.c insn-emit.c insn-extract.c insn-peep.c \
insn-attr.h insn-attr-common.h insn-attrtab.c insn-dfatab.c \
@@ -1511,7 +1514,7 @@ MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
tm-preds.h tm-constrs.h checksum-options \
tree-check.h min-insn-modes.c insn-modes.c insn-modes.h \
genrtl.h gt-*.h gtype-*.h gtype-desc.c gtyp-input.list \
- xgcc$(exeext) cpp$(exeext) \
+ xgcc$(exeext) cpp$(exeext) $(FULL_DRIVER_NAME) \
$(EXTRA_PROGRAMS) gcc-cross$(exeext) \
$(SPECS) collect2$(exeext) gcc-ar$(exeext) gcc-nm$(exeext) \
gcc-ranlib$(exeext) \
@@ -1520,6 +1523,12 @@ MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
gengtype$(exeext) *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a \
libcommon-target.a libcommon.a libgcc.mk
+# This symlink makes the full installation name of the driver be available
+# from within the *build* directory, for use when running the JIT library
+# from there (e.g. when running its testsuite).
+$(FULL_DRIVER_NAME): ./xgcc
+ $(LN) -s $< $@
+
#
# Language makefile fragments.
@@ -3248,9 +3257,9 @@ install-driver: installdirs xgcc$(exeext)
-rm -f $(DESTDIR)$(bindir)/$(GCC_INSTALL_NAME)$(exeext)
-$(INSTALL_PROGRAM) xgcc$(exeext) $(DESTDIR)$(bindir)/$(GCC_INSTALL_NAME)$(exeext)
-if [ "$(GCC_INSTALL_NAME)" != "$(target_noncanonical)-gcc-$(version)" ]; then \
- rm -f $(DESTDIR)$(bindir)/$(target_noncanonical)-gcc-$(version)$(exeext); \
+ rm -f $(DESTDIR)$(bindir)/$(FULL_DRIVER_NAME); \
( cd $(DESTDIR)$(bindir) && \
- $(LN) $(GCC_INSTALL_NAME)$(exeext) $(target_noncanonical)-gcc-$(version)$(exeext) ); \
+ $(LN) $(GCC_INSTALL_NAME)$(exeext) $(FULL_DRIVER_NAME) ); \
fi
-if [ ! -f gcc-cross$(exeext) ] \
&& [ "$(GCC_INSTALL_NAME)" != "$(GCC_TARGET_INSTALL_NAME)" ]; then \
@@ -3504,7 +3513,6 @@ site.exp: ./config.status Makefile
@echo "# add them to the last section" >> ./site.tmp
@echo "set rootme \"`${PWD_COMMAND}`\"" >> ./site.tmp
@echo "set srcdir \"`cd ${srcdir}; ${PWD_COMMAND}`\"" >> ./site.tmp
- @echo "set bindir \"`cd ${bindir}; ${PWD_COMMAND}`\"" >> ./site.tmp
@echo "set host_triplet $(host)" >> ./site.tmp
@echo "set build_triplet $(build)" >> ./site.tmp
@echo "set target_triplet $(target)" >> ./site.tmp
@@ -51,7 +51,10 @@ LIBGCCJIT_FILENAME = \
LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME)
LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_SONAME)
-jit: $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SYMLINK) $(LIBGCCJIT_LINKER_NAME_SYMLINK)
+jit: $(LIBGCCJIT_FILENAME) \
+ $(LIBGCCJIT_SYMLINK) \
+ $(LIBGCCJIT_LINKER_NAME_SYMLINK) \
+ $(FULL_DRIVER_NAME)
# Tell GNU make to ignore these if they exist.
.PHONY: jit
@@ -1631,7 +1631,7 @@ compile ()
{
auto_timevar assemble_timevar (TV_ASSEMBLE);
const char *errmsg;
- const char *argv[6];
+ const char *argv[7];
int exit_status = 0;
int err = 0;
const char *gcc_driver_name = GCC_DRIVER_NAME;
@@ -1643,8 +1643,18 @@ compile ()
/* The output: shared library. */
argv[3] = "-o";
argv[4] = m_path_so_file;
+
+ /* Don't use the linker plugin.
+ If running with just a "make" and not a "make install", then we'd
+ run into
+ "fatal error: -fuse-linker-plugin, but liblto_plugin.so not found"
+ libto_plugin is a .la at build time, with it becoming installed with
+ ".so" suffix: i.e. it doesn't exist with a .so suffix until install
+ time. */
+ argv[5] = "-fno-use-linker-plugin";
+
/* pex argv arrays are NULL-terminated. */
- argv[5] = NULL;
+ argv[6] = NULL;
errmsg = pex_one (PEX_SEARCH, /* int flags, */
gcc_driver_name,
@@ -1656,7 +1666,7 @@ compile ()
&err); /* int *err*/
if (errmsg)
{
- add_error (NULL, "error invoking gcc harness: %s", errmsg);
+ add_error (NULL, "error invoking gcc driver: %s", errmsg);
return NULL;
}
@@ -1665,8 +1675,14 @@ compile ()
if (exit_status || err)
{
add_error (NULL,
- "error invoking gcc harness: exit_status: %i err: %i",
+ "error invoking gcc driver: exit_status: %i err: %i",
exit_status, err);
+ add_error (NULL,
+ "whilst attempting to run a driver named: %s",
+ gcc_driver_name);
+ add_error (NULL,
+ "PATH was: %s",
+ getenv ("PATH"));
return NULL;
}
}
@@ -172,6 +172,18 @@ set tests [lsort [concat $tests [find $srcdir/../jit/docs/examples *.c]]]
verbose "tests: $tests"
+# libgloss has found the driver (as "xgcc" or "gcc) and stored
+# its full path as GCC_UNDER_TEST.
+proc get_path_of_driver {} {
+ global GCC_UNDER_TEST
+
+ verbose "GCC_UNDER_TEST: $GCC_UNDER_TEST"
+ set binary [lindex $GCC_UNDER_TEST 0]
+ verbose "binary: $binary"
+
+ return [file dirname $binary]
+}
+
proc jit-dg-test { prog do_what extra_tool_flags } {
verbose "within jit-dg-test..."
verbose " prog: $prog"
@@ -206,31 +218,41 @@ proc jit-dg-test { prog do_what extra_tool_flags } {
set ld_library_path "$base_dir/../../"
set_ld_library_path_env_vars
- # If running with just a "make" and not a "make install", then I was
- # running into
- # "fatal error: -fuse-linker-plugin, but liblto_plugin.so not found"
- # emitted by the inner gcc invoked to convert the .s into .so
- # This appears to be due to not installing the built compiler;
- # libto_plugin is a .la at build time, with the .so becoming installed
- # at install time; the "set_ld_library_path_env_vars" function from
- # target-libpath.exp that I'm using to set LD_LIBRARY_PATH to find
- # the library under test, libgccjit.so, was setting GCC_EXEC_PREFIX to
- # the builddir, thus picking up the built-but-not-installed toolchain.
- # Hacking in an "unsetenv GCC_EXEC_PREFIX" here fixes the issue,
- # allowing quick running of testsuite without needing a full install.
- #
- unsetenv GCC_EXEC_PREFIX
-
# libgccjit uses the driver to convert .s files to .so libraries
- # via its *installed* name, the expansion of:
+ # via its *installed* name, FULL_DRIVER_NAME
# ${target_noncanonical}-gcc-${gcc_BASEVER}${exeext}
# e.g. "x86_64-unknown-linux-gnu-gcc-5.0.0"
- # looking for it on PATH. Hence we need to prepend the installation
- # bindir to PATH when running the tests
+ # looking for it on PATH. Hence we need to prepend the location of
+ # that executable to PATH when running the tests
+ set dir_containing_driver [get_path_of_driver ]
+ verbose "dir_containing_driver: $dir_containing_driver"
global env
- global bindir
set old_path $env(PATH)
- setenv "PATH" $bindir:$env(PATH)
+ setenv "PATH" $dir_containing_driver:$old_path
+ verbose -log "PATH=[getenv PATH]"
+
+ # We have:
+ # test-executables
+ # linked to -> libgccjit.so
+ # -> invokes driver:
+ # -> invokes the assembler
+ # -> invokes the linker
+ # We want to be able to run this from the builddir without installing
+ # but the linker needs to be able to locate various libraries, or we
+ # get:
+ # ld: cannot find crtbeginS.o: No such file or directory
+ # ld: cannot find -lgcc
+ # ld: cannot find -lgcc_s
+ # These can be found in the "gcc" subdir of the build.
+ # Hence to be able to run the testsuite without installing, we need
+ # to set or prepend the "gcc" subdir of the build to LIBRARY_PATH:
+ if { [info exists env(LIBRARY_PATH) ] } {
+ set old_library_path $env(LIBRARY_PATH)
+ setenv "LIBRARY_PATH" $dir_containing_driver:$old_library_path
+ } else {
+ setenv "LIBRARY_PATH" $dir_containing_driver
+ }
+ verbose -log "LIBRARY_PATH=[getenv LIBRARY_PATH]"
# dejagnu.exp's host_execute has code to scrape out test results
# from the DejaGnu C API and bring back into the tcl world, so we
@@ -245,6 +267,13 @@ proc jit-dg-test { prog do_what extra_tool_flags } {
# Restore PATH
setenv "PATH" $old_path
+ # Restore LIBRARY_PATH
+ if { [info exists old_library_path] } {
+ setenv "LIBRARY_PATH" $old_library_path
+ } else {
+ unsetenv "LIBRARY_PATH"
+ }
+
restore_ld_library_path_env_vars
}