Skip to content

Commit 636252a

Browse files
committed
Define _GNU_SOURCE when importing glibc on Fuchisa
Some functions and types are hidden behind feature flags. _GNU_SOURCE exposes the most symbols and methods in glibc and musl. Currently only turning it on for the Fuchsia triple. Also add a test for the missing extended C functions in the Glibc module.
1 parent 43ee2db commit 636252a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,18 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
533533
});
534534
}
535535
} else {
536+
// Ideally we should turn this on for all Glibc targets that are actually
537+
// using Glibc or a libc that respects that flag. This will cause some
538+
// source breakage however (specifically with strerror_r()) on Linux
539+
// without a workaround.
540+
if (triple.isOSFuchsia()) {
541+
// Many of the modern libc features are hidden behind feature macros like
542+
// _GNU_SOURCE or _XOPEN_SOURCE.
543+
invocationArgStrs.insert(invocationArgStrs.end(), {
544+
"-D_GNU_SOURCE",
545+
});
546+
}
547+
536548
// The module map used for Glibc depends on the target we're compiling for,
537549
// and is not included in the resource directory with the other implicit
538550
// module maps. It's at {freebsd|linux}/{arch}/glibc.modulemap.

0 commit comments

Comments
 (0)