diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2024-06-06 19:37:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-06 19:37:31 +0200 |
| commit | b196b84ef24e90a8c1cfeb6226b43171c376c7b2 (patch) | |
| tree | dfcd6d43da5b3b3ee2668eca0acc87026bbcd3aa /src/build_settings.cpp | |
| parent | d0dbe9a1bd3ca5187414e43f2cf804443e468f18 (diff) | |
| parent | e2eb3cdd8afb8e105414ba5459d0b6382b609d89 (diff) | |
Merge pull request #3695 from laytan/fix-linking-on-weird-linuxes
fix linking on weird linuxes
Diffstat (limited to 'src/build_settings.cpp')
| -rw-r--r-- | src/build_settings.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 52e6fd7ff..251dd06dd 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -2035,6 +2035,9 @@ gb_internal void init_build_context(TargetMetrics *cross_target, Subtarget subta bc->link_flags = str_lit("/machine:x86 "); break; } + } else if (bc->metrics.os == TargetOs_darwin) { + bc->link_flags = concatenate3_strings(permanent_allocator(), + str_lit("-target "), bc->metrics.target_triplet, str_lit(" ")); } else if (is_arch_wasm()) { gbString link_flags = gb_string_make(heap_allocator(), " "); // link_flags = gb_string_appendc(link_flags, "--export-all "); @@ -2052,8 +2055,13 @@ gb_internal void init_build_context(TargetMetrics *cross_target, Subtarget subta // Disallow on wasm bc->use_separate_modules = false; } else { - bc->link_flags = concatenate3_strings(permanent_allocator(), - str_lit("-target "), bc->metrics.target_triplet, str_lit(" ")); + // NOTE: for targets other than darwin, we don't specify a `-target` link flag. + // This is because we don't support cross-linking and clang is better at figuring + // out what the actual target for linking is, + // for example, on x86/alpine/musl it HAS to be `x86_64-alpine-linux-musl` to link correctly. + // + // Note that codegen will still target the triplet we specify, but the intricate details of + // a target shouldn't matter as much to codegen (if it does at all) as it does to linking. } // NOTE: needs to be done after adding the -target flag to the linker flags so the linker |