diff mbox series

[1/4] Driver : Provide a spec to insert rpaths for compiler lib dirs.

Message ID 20211117210319.92514-2-iain@sandoe.co.uk
State New
Headers show
Series Darwin: Replace environment runpath with embedded [PR88590]. | expand

Commit Message

Iain Sandoe Nov. 17, 2021, 9:03 p.m. UTC
This provides a spec to insert "-rpath DDD" for each DDD corresponding
to a compiler startfile directory.  This allows a target to use @rpath
as the install path for libraries, and have the compiler provide the
necessary rpath to handle this.

gcc/ChangeLog:

	* gcc.c (RUNPATH_OPTION): New.
	(do_spec_1): Provide '%P' as a spec to insert rpaths for
	each compiler startfile path.
---
 gcc/gcc.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/gcc/gcc.c b/gcc/gcc.c
index 506c2acc282..7b52d0bcbfd 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -572,6 +572,7 @@  or with constant text in a single argument.
  %l     process LINK_SPEC as a spec.
  %L     process LIB_SPEC as a spec.
  %M     Output multilib_os_dir.
+ %P	Output a RUNPATH_OPTION for each directory in startfile_prefixes.
  %G     process LIBGCC_SPEC as a spec.
  %R     Output the concatenation of target_system_root and
         target_sysroot_suffix.
@@ -1191,6 +1192,10 @@  proper position among the other output files.  */
 # define SYSROOT_HEADERS_SUFFIX_SPEC ""
 #endif
 
+#ifndef RUNPATH_OPTION
+# define RUNPATH_OPTION "-rpath"
+#endif
+
 static const char *asm_debug = ASM_DEBUG_SPEC;
 static const char *asm_debug_option = ASM_DEBUG_OPTION_SPEC;
 static const char *cpp_spec = CPP_SPEC;
@@ -6130,6 +6135,19 @@  do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
 	    }
 	    break;
 
+	  case 'P':
+	    {
+	      struct spec_path_info info;
+
+	      info.option = RUNPATH_OPTION;
+	      info.append_len = 0;
+	      info.omit_relative = false;
+	      info.separate_options = true;
+
+	      for_each_path (&startfile_prefixes, true, 0, spec_path, &info);
+	    }
+	    break;
+
 	  case 'e':
 	    /* %efoo means report an error with `foo' as error message
 	       and don't execute any more commands for this file.  */