[clang] [Clang][Hexagon] Define _GNU_SOURCE when using picolibc in C++ mode (PR #201599)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 4 21:55:01 PDT 2026
================
@@ -813,6 +815,13 @@ void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
CC1Args.push_back("-mllvm");
CC1Args.push_back("-hexagon-autohvx");
}
+
+ // picolibc guards GNU-extension functions (e.g. strtold_l) with __GNU_VISIBLE
+ // which requires _GNU_SOURCE. Define it automatically for C++ compilations
+ // so that building libcxx against picolibc works without -D_GNU_SOURCE.
+ if (GetCStdlibType(DriverArgs) == ToolChain::CST_Picolibc &&
+ getDriver().CCCIsCXX())
+ CC1Args.push_back("-D_GNU_SOURCE");
}
----------------
quic-k wrote:
ideally yes
I was trying to define this macro for only Picolibc so we don't break anything for default libc but the driver cstdlib flag is not available in OSTargetInfo, so I added it in driver
do you think it makes sense to define this macro for Hexagon, and not depend of what libc we have?
https://github.com/llvm/llvm-project/pull/201599
More information about the cfe-commits
mailing list