@@ -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
@@ -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. */
@@ -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) $@
@@ -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)"
@@ -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)"