--- a/gcc/gcc.c-original	2019-05-31 12:16:26.175109000 +0200
+++ b/gcc/gcc.c	2019-05-31 12:43:48.461954800 +0200
@@ -6129,7 +6129,6 @@
   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;
@@ -6145,7 +6146,6 @@
   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;
@@ -6175,13 +6177,15 @@
 			 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;
@@ -6257,8 +6257,9 @@
   /* 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;
