From 7bb1c4dfb29899729c13376cbae8393f201f1e83 Mon Sep 17 00:00:00 2001
From: Olivier Michel <Olivier.Michel@cyberbotics.com>
Date: Fri, 31 May 2019 15:07:06 +0200
Subject: [PATCH 10/16] Handle spaces in path for default manifest

---
 gcc/gcc.cc | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index afb23cd07b0..8eee9345afe 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -6829,7 +6829,6 @@ eval_spec_function (const char *func, const char *args,
   int save_arg_going;
   int save_delete_this_arg;
   int save_this_is_output_file;
-  int save_this_is_library_file;
   int save_input_from_pipe;
   int save_this_is_linker_script;
   const char *save_suffix_subst;
@@ -6847,7 +6846,6 @@ eval_spec_function (const char *func, const char *args,
   save_arg_going = arg_going;
   save_delete_this_arg = delete_this_arg;
   save_this_is_output_file = this_is_output_file;
-  save_this_is_library_file = this_is_library_file;
   save_this_is_linker_script = this_is_linker_script;
   save_input_from_pipe = input_from_pipe;
   save_suffix_subst = suffix_subst;
@@ -6879,13 +6877,15 @@ eval_spec_function (const char *func, const char *args,
 			 argbuf.address ());
 
   /* Pop the spec processing context.  */
+  const char *saved_library_file = this_is_library_file ? argbuf.address()[0] : NULL;
   argbuf.release ();
   argbuf = save_argbuf;
+  if (saved_library_file)
+    argbuf.safe_push (saved_library_file);
 
   arg_going = save_arg_going;
   delete_this_arg = save_delete_this_arg;
   this_is_output_file = save_this_is_output_file;
-  this_is_library_file = save_this_is_library_file;
   this_is_linker_script = save_this_is_linker_script;
   input_from_pipe = save_input_from_pipe;
   suffix_subst = save_suffix_subst;
@@ -6957,8 +6957,9 @@ handle_spec_function (const char *p, bool *retval_nonnull,
   /* p now points to just past the end of the spec function expression.  */
 
   funcval = eval_spec_function (func, args, soft_matched_part);
-  if (funcval != NULL && do_spec_1 (funcval, 0, NULL) < 0)
+  if (funcval != NULL && this_is_library_file == 0 && do_spec_1 (funcval, 0, NULL) < 0)
     p = NULL;
+
   if (retval_nonnull)
     *retval_nonnull = funcval != NULL;
 
-- 
2.38.1

