Commit dca19b6757

Andrew Kelley <andrew@ziglang.org>
2020-02-22 02:48:50
fix regression in detecting native glibc version
closes #4519
1 parent 6305ce8
Changed files (2)
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);
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<ZigGLibCVersion>();
         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
     }
 }