Fix relibc strtold linkage for C++ consumers

Keep the relibc overlay consistent so the generated stdlib header preserves C linkage for strtold and the existing toolchain can still satisfy stale C++ callers while it is refreshed.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-04-18 10:36:46 +01:00
parent 5f44bbab0c
commit 619fd0f2d1
3 changed files with 201 additions and 0 deletions
@@ -0,0 +1,43 @@
diff --git a/src/c/stdlib.c b/src/c/stdlib.c
index 62e98108..a9c72392 100644
--- a/src/c/stdlib.c
+++ b/src/c/stdlib.c
@@ -4,6 +4,13 @@ long double strtold(const char *nptr, char **endptr) {
return (long double)strtod(nptr, endptr);
}
+long double relibc_compat_cpp_strtold(const char *nptr, char **endptr)
+ __asm__("_Z7strtoldPKcPPc");
+
+long double relibc_compat_cpp_strtold(const char *nptr, char **endptr) {
+ return strtold(nptr, endptr);
+}
+
double relibc_ldtod(const long double* val) {
return (double)(*val);
}
diff --git a/src/header/stdlib/cbindgen.toml b/src/header/stdlib/cbindgen.toml
index 2e02e68a..07867c32 100644
--- a/src/header/stdlib/cbindgen.toml
+++ b/src/header/stdlib/cbindgen.toml
@@ -1,7 +1,20 @@
sys_includes = ["stddef.h", "alloca.h", "wchar.h", "features.h"]
include_guard = "_RELIBC_STDLIB_H"
trailer = """
+#ifndef _RELIBC_STDLIB_STRTOLD_H
+#define _RELIBC_STDLIB_STRTOLD_H
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
long double strtold(const char *nptr, char **endptr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
"""
language = "C"
style = "Type"