diff --git a/src/main.cpp b/src/main.cpp index d6148d4587..a4ab719123 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -992,6 +992,14 @@ static int main0(int argc, char **argv) { } } else { target_init_default_glibc_version(&target); +#if defined(ZIG_OS_LINUX) + if (target.is_native) { + // TODO self-host glibc version detection, and then this logic can go away + if ((err = glibc_detect_native_version(target.glibc_version))) { + // Fall back to the default version. + } + } +#endif } } else if (target_glibc != nullptr) { fprintf(stderr, "'%s' is not a glibc-compatible target", target_string); diff --git a/src/target.cpp b/src/target.cpp index 0a3fb3da5f..8a68afbd83 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -467,12 +467,6 @@ void get_native_target(ZigTarget *target) { if (target_is_glibc(target)) { target->glibc_version = heap::c_allocator.create(); target_init_default_glibc_version(target); -#ifdef ZIG_OS_LINUX - Error err; - if ((err = glibc_detect_native_version(target->glibc_version))) { - // Fall back to the default version. - } -#endif } }