On 22 Dec 13:35, Jakub Jelinek wrote:
> On Mon, Dec 22, 2014 at 12:48:08PM +0100, Thomas Schwinge wrote:
> > In my understanding, we'd like to support the modes that either all
> > compilers are installed (which is what a user will be using), or all are
> > tested from their build trees. Or, do we also have to support the mode
> > that only the offloading compilers are installed, but the target
> > (offloading host) compiler is not? (Doesn't make much sense to me.)
>
> All 3 of these, yes.
> The nothing is installed yet mode supposedly doesn't work properly on the
> trunk yet (and is what I'd like to use e.g. in distro rpm builds), the
> offloading
> compilers installed, host is not is useful that you actually test the host
> compiler
> before installing, and that supposedly works on the trunk, the all installed
> testing
> I've never used myself, but some people are using it.
This patch enables 'make check-target-libgomp' with noninstalled offloading
compilers. It creates gcc/accel/<target>/ directory in the build tree of the
offloading compiler, this allows lto-wrapper to find corresponding mkoffload in
case if there is more than one offloading compiler. Is this approach ok?
I don't like changes in config.gcc and t-intelmic, probably there is a better
way to create a link?
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 0dfc08f..76eef6f 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4369,7 +4369,7 @@ fi
case ${target} in
i[34567]86-*-* | x86_64-*-*)
if test x$enable_as_accelerator = xyes; then
- extra_programs="mkoffload\$(exeext)"
+ extra_programs="mkoffload\$(exeext)
accel/${target_noncanonical}/mkoffload$(exeext)"
fi
;;
esac
diff --git a/gcc/config/i386/intelmic-mkoffload.c
b/gcc/config/i386/intelmic-mkoffload.c
index 8e490ff..41807cf 100644
--- a/gcc/config/i386/intelmic-mkoffload.c
+++ b/gcc/config/i386/intelmic-mkoffload.c
@@ -45,6 +45,11 @@ const char *temp_files[MAX_NUM_TEMPS];
/* Shows if we should compile binaries for i386 instead of x86-64. */
bool target_ilp32 = false;
+/* An optional prefix for the target compiler, which is required when target
+ compiler is not installed. */
+char *optional_target_path = NULL;
+
+
/* Delete tempfiles and exit function. */
void
tool_cleanup (bool from_signal ATTRIBUTE_UNUSED)
@@ -151,14 +156,18 @@ access_check (const char *name, int mode)
return access (name, mode);
}
-/* Find target compiler using a path from COLLECT_GCC or COMPILER_PATH. */
+/* Find target compiler using a path from COLLECT_GCC, COMPILER_PATH, or a path
+ relative to ARGV0. */
static char *
-find_target_compiler (const char *name)
+find_target_compiler (const char *argv0)
{
bool found = false;
char **paths = NULL;
unsigned n_paths, i;
+ const char *current_path;
const char *collect_path = dirname (ASTRDUP (getenv ("COLLECT_GCC")));
+ const char *name
+ = DEFAULT_REAL_TARGET_MACHINE "-accel-" DEFAULT_TARGET_MACHINE "-gcc";
size_t len = strlen (collect_path) + 1 + strlen (name) + 1;
char *target_compiler = XNEWVEC (char, len);
sprintf (target_compiler, "%s/%s", collect_path, name);
@@ -177,13 +186,28 @@ find_target_compiler (const char *name)
if (access_check (target_compiler, X_OK) == 0)
{
found = true;
- break;
+ goto out;
}
}
+ /* If installed compiler wasn't found, try to find a non-installed compiler,
+ using a path relative to mkoffload. */
+ current_path = dirname (ASTRDUP (argv0));
+ len = strlen (current_path) + sizeof ("/../../") - 1;
+ target_compiler = XRESIZEVEC (char, target_compiler, len + sizeof ("xgcc"));
+ sprintf (target_compiler, "%s/../../xgcc", current_path);
+ if (access_check (target_compiler, X_OK) == 0)
+ {
+ optional_target_path = XNEWVEC (char, len + sizeof ("-B"));
+ sprintf (optional_target_path, "-B%s/../../", current_path);
+ found = true;
+ }
+
out:
free_array_of_ptrs ((void **) paths, n_paths);
- return found ? target_compiler : NULL;
+ if (!found)
+ fatal_error ("offload compiler %s not found", name);
+ return target_compiler;
}
static void
@@ -193,6 +217,10 @@ compile_for_target (struct obstack *argv_obstack)
obstack_ptr_grow (argv_obstack, "-m32");
else
obstack_ptr_grow (argv_obstack, "-m64");
+
+ if (optional_target_path)
+ obstack_ptr_grow (argv_obstack, optional_target_path);
+
obstack_ptr_grow (argv_obstack, NULL);
char **argv = XOBFINISH (argv_obstack, char **);
@@ -492,11 +520,7 @@ main (int argc, char **argv)
if (!host_compiler)
fatal_error ("COLLECT_GCC must be set");
- const char *target_driver_name
- = DEFAULT_REAL_TARGET_MACHINE "-accel-" DEFAULT_TARGET_MACHINE "-gcc";
- char *target_compiler = find_target_compiler (target_driver_name);
- if (target_compiler == NULL)
- fatal_error ("offload compiler %s not found", target_driver_name);
+ char *target_compiler = find_target_compiler (argv[0]);
/* We may be called with all the arguments stored in some file and
passed with @file. Expand them into argv before processing. */
diff --git a/gcc/config/i386/t-intelmic b/gcc/config/i386/t-intelmic
index 8b36e0d..efc50fca 100644
--- a/gcc/config/i386/t-intelmic
+++ b/gcc/config/i386/t-intelmic
@@ -7,3 +7,9 @@ mkoffload.o: $(srcdir)/config/i386/intelmic-mkoffload.c |
insn-modes.h
mkoffload$(exeext): mkoffload.o collect-utils.o libcommon-target.a
$(LIBIBERTY) $(LIBDEPS)
$(COMPILER) -o $@ mkoffload.o collect-utils.o libcommon-target.a
$(LIBIBERTY) $(LIBS)
+
+accel/$(target_noncanonical)/mkoffload$(exeext): mkoffload$(exeext)
+ test -d accel || mkdir accel
+ test -d accel/$(target_noncanonical) || mkdir
accel/$(target_noncanonical)
+ rm -f $@
+ $(LN) mkoffload$(exeext) $@
diff --git a/libgomp/configure b/libgomp/configure
index 3214e9d..134064a 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -16251,7 +16251,11 @@ if test x"$enable_offload_targets" != x; then
tgt=`echo $tgt | sed 's/=.*//'`
case $tgt in
*-intelmic-* | *-intelmicemul-*)
- tgt_name="intelmic" ;;
+ tgt_name="intelmic"
+ if test x"$tgt_dir" != x; then
+
offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/$tgt/liboffloadmic/.libs"
+ fi
+ ;;
*)
as_fn_error "unknown offload target specified" "$LINENO" 5 ;;
esac
@@ -16261,7 +16265,7 @@ if test x"$enable_offload_targets" != x; then
offload_targets=$offload_targets,$tgt_name
fi
if test x"$tgt_dir" != x; then
- offload_additional_options="$offload_additional_options
-B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+ offload_additional_options="$offload_additional_options
-B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/gcc
-B$tgt_dir/bin"
offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
else
offload_additional_options="$offload_additional_options
-B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
diff --git a/libgomp/configure.ac b/libgomp/configure.ac
index 8ed1bae..d74fce0 100644
--- a/libgomp/configure.ac
+++ b/libgomp/configure.ac
@@ -293,7 +293,11 @@ if test x"$enable_offload_targets" != x; then
tgt=`echo $tgt | sed 's/=.*//'`
case $tgt in
*-intelmic-* | *-intelmicemul-*)
- tgt_name="intelmic" ;;
+ tgt_name="intelmic"
+ if test x"$tgt_dir" != x; then
+
offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/$tgt/liboffloadmic/.libs"
+ fi
+ ;;
*)
AC_MSG_ERROR([unknown offload target specified]) ;;
esac
@@ -303,7 +307,7 @@ if test x"$enable_offload_targets" != x; then
offload_targets=$offload_targets,$tgt_name
fi
if test x"$tgt_dir" != x; then
- offload_additional_options="$offload_additional_options
-B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+ offload_additional_options="$offload_additional_options
-B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/gcc
-B$tgt_dir/bin"
offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
else
offload_additional_options="$offload_additional_options
-B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
-- Ilya