add -no-rpath

This commit is contained in:
Laytan
2024-09-04 22:38:19 +02:00
parent 1a7c1d107a
commit 0aa971207b
3 changed files with 15 additions and 3 deletions
+1
View File
@@ -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
View File
@@ -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
View File
@@ -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, "");