Explorar o código

add -no-rpath

Laytan hai 1 ano
pai
achega
0aa971207b
Modificáronse 3 ficheiros con 15 adicións e 3 borrados
  1. 1 0
      src/build_settings.cpp
  2. 5 3
      src/linker.cpp
  3. 9 0
      src/main.cpp

+ 1 - 0
src/build_settings.cpp

@@ -411,6 +411,7 @@ struct BuildContext {
 	bool   no_dynamic_literals;
 	bool   no_output_files;
 	bool   no_crt;
+	bool   no_rpath;
 	bool   no_entry_point;
 	bool   no_thread_local;
 	bool   use_lld;

+ 5 - 3
src/linker.cpp

@@ -641,9 +641,11 @@ gb_internal i32 linker_stage(LinkerData *gen) {
 				}
 			}
 
-			// Set the rpath to the $ORIGIN (the path of the executable),
-			// so that dynamic libraries are looked for at that path.
-			gb_string_appendc(link_settings, "-Wl,-rpath,\\$ORIGIN ");
+			if (!build_context.no_rpath) {
+				// Set the rpath to the $ORIGIN (the path of the executable),
+				// so that dynamic libraries are looked for at that path.
+				gb_string_appendc(link_settings, "-Wl,-rpath,\\$ORIGIN ");
+			}
 
 			if (!build_context.no_crt) {
 				platform_lib_str = gb_string_appendc(platform_lib_str, "-lm ");

+ 9 - 0
src/main.cpp

@@ -325,6 +325,7 @@ enum BuildFlagKind {
 	BuildFlag_NoTypeAssert,
 	BuildFlag_NoDynamicLiterals,
 	BuildFlag_NoCRT,
+	BuildFlag_NoRPath,
 	BuildFlag_NoEntryPoint,
 	BuildFlag_UseLLD,
 	BuildFlag_UseSeparateModules,
@@ -532,6 +533,7 @@ gb_internal bool parse_build_flags(Array<String> args) {
 	add_flag(&build_flags, BuildFlag_NoThreadLocal,           str_lit("no-thread-local"),           BuildFlagParam_None,    Command__does_check);
 	add_flag(&build_flags, BuildFlag_NoDynamicLiterals,       str_lit("no-dynamic-literals"),       BuildFlagParam_None,    Command__does_check);
 	add_flag(&build_flags, BuildFlag_NoCRT,                   str_lit("no-crt"),                    BuildFlagParam_None,    Command__does_build);
+	add_flag(&build_flags, BuildFlag_NoRPath,                 str_lit("no-rpath"),                  BuildFlagParam_None,    Command__does_build);
 	add_flag(&build_flags, BuildFlag_NoEntryPoint,            str_lit("no-entry-point"),            BuildFlagParam_None,    Command__does_check &~ Command_test);
 	add_flag(&build_flags, BuildFlag_UseLLD,                  str_lit("lld"),                       BuildFlagParam_None,    Command__does_build);
 	add_flag(&build_flags, BuildFlag_UseSeparateModules,      str_lit("use-separate-modules"),      BuildFlagParam_None,    Command__does_build);
@@ -1181,6 +1183,9 @@ gb_internal bool parse_build_flags(Array<String> args) {
 						case BuildFlag_NoCRT:
 							build_context.no_crt = true;
 							break;
+						case BuildFlag_NoRPath:
+							build_context.no_rpath = true;
+							break;
 						case BuildFlag_NoEntryPoint:
 							build_context.no_entry_point = true;
 							break;
@@ -2310,6 +2315,10 @@ gb_internal void print_show_help(String const arg0, String const &command) {
 		print_usage_line(2, "Disables automatic linking with the C Run Time.");
 		print_usage_line(0, "");
 
+		print_usage_line(1, "-no-rpath");
+		print_usage_line(2, "Disables automatic addition of an rpath linked to the executable directory.");
+		print_usage_line(0, "");
+
 		print_usage_line(1, "-no-thread-local");
 		print_usage_line(2, "Ignores @thread_local attribute, effectively treating the program as if it is single-threaded.");
 		print_usage_line(0, "");