diff options
| author | marcs feh <82233333+marcs-feh@users.noreply.github.com> | 2024-02-11 23:55:39 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-11 23:55:39 +0000 |
| commit | 9c6574e053e9a1c27f2831ed81e56edf9a180a95 (patch) | |
| tree | d65a1e5927317a9991263ac96d424b70af8a72ea /src/linker.cpp | |
| parent | fc113315f6ccd5d58652e8d2f326ed150e74adf1 (diff) | |
| parent | 4ca23499fa9bd59083b1beae6c44b5a5d890fcf2 (diff) | |
Merge branch 'odin-lang:master' into master
Diffstat (limited to 'src/linker.cpp')
| -rw-r--r-- | src/linker.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/linker.cpp b/src/linker.cpp index c0952d0e0..987fab7f7 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -482,37 +482,33 @@ gb_internal i32 linker_stage(LinkerData *gen) { gbString platform_lib_str = gb_string_make(heap_allocator(), ""); defer (gb_string_free(platform_lib_str)); if (build_context.metrics.os == TargetOs_darwin) { - platform_lib_str = gb_string_appendc(platform_lib_str, "-Wl,-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/usr/local/lib"); + platform_lib_str = gb_string_appendc(platform_lib_str, "-Wl,-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/usr/local/lib "); // Homebrew's default library path, checking if it exists to avoid linking warnings. if (gb_file_exists("/opt/homebrew/lib")) { - platform_lib_str = gb_string_appendc(platform_lib_str, " -L/opt/homebrew/lib"); + platform_lib_str = gb_string_appendc(platform_lib_str, "-L/opt/homebrew/lib "); } // MacPort's default library path, checking if it exists to avoid linking warnings. if (gb_file_exists("/opt/local/lib")) { - platform_lib_str = gb_string_appendc(platform_lib_str, " -L/opt/local/lib"); + platform_lib_str = gb_string_appendc(platform_lib_str, "-L/opt/local/lib "); } - #if defined(GB_SYSTEM_OSX) - if(!build_context.no_crt) { - platform_lib_str = gb_string_appendc(platform_lib_str, " -lm "); - if(gen->needs_system_library_linked == 1) { - platform_lib_str = gb_string_appendc(platform_lib_str, " -lSystem "); - } - } - #endif - } else { - platform_lib_str = gb_string_appendc(platform_lib_str, "-lc -lm"); - } - - if (build_context.metrics.os == TargetOs_darwin) { // This sets a requirement of Mountain Lion and up, but the compiler doesn't work without this limit. if (build_context.minimum_os_version_string.len) { - link_settings = gb_string_append_fmt(link_settings, " -mmacosx-version-min=%.*s ", LIT(build_context.minimum_os_version_string)); + link_settings = gb_string_append_fmt(link_settings, "-mmacosx-version-min=%.*s ", LIT(build_context.minimum_os_version_string)); } // This points the linker to where the entry point is - link_settings = gb_string_appendc(link_settings, " -e _main "); + link_settings = gb_string_appendc(link_settings, "-e _main "); + } + + if (!build_context.no_crt) { + platform_lib_str = gb_string_appendc(platform_lib_str, "-lm "); + if (build_context.metrics.os == TargetOs_darwin) { + platform_lib_str = gb_string_appendc(platform_lib_str, "-lSystem "); + } else { + platform_lib_str = gb_string_appendc(platform_lib_str, "-lc "); + } } gbString link_command_line = gb_string_make(heap_allocator(), "clang -Wno-unused-command-line-argument "); |