You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clang has multiple flags for controlling the include path. From the documentation:
-nostdinc
Do not search the standard system directories or compiler builtin directories for include files.
-nostdlibinc
Do not search the standard system directories for include files, but do search compiler builtin include directories.
-nobuiltininc
Do not search clang’s builtin directory for include files.
So in effect, -nostdinc implies -nostdlibinc and -nobuiltininc. But to control the standard system include dir and the builtins include dir separately, we have -nostdlibinc and -nobuiltininc to control those two kinds of include dirs separately.
You can see the logic here for the RISCV toolchain:
For BareMetal it's similar, with the addition of multilib:
voidBareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
SmallString<128> Dir(getDriver().ResourceDir);
llvm::sys::path::append(Dir, "include");
addSystemInclude(DriverArgs, CC1Args, Dir.str());
}
if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
const SmallString<128> SysRoot(computeSysRoot());
if (!SysRoot.empty()) {
for (const Multilib &M : getOrderedMultilibs()) {
SmallString<128> Dir(SysRoot);
llvm::sys::path::append(Dir, M.includeSuffix());
llvm::sys::path::append(Dir, "include");
addSystemInclude(DriverArgs, CC1Args, Dir.str());
}
}
}
}
Unfortunately, it seems that Xtensa ignores the builtins include directory unless a GCC installation has been found. In fact, if the -nostdlibinc flag is passed, it exits early without adding the builtins directory at all!
This makes no sense to me, since the resources directory is specific to Clang. On Linux, it's the /usr/lib/clang/<version>/include/ directory.
In TinyGo, we're not using a GCC installation. We use picolibc as the libc, and otherwise use LLVM native tools. Therefore, there is no GCC installation. To better control this, we pass -nostdlibinc to ignore the system libc, with the expectation that the builtins directory is still added. Xtensa is the only platform where this is not the case.
Somehow this still works when using Clang as-is (hence why I don't have an easy reproducer) because Clang seems to add this directory again somewhere else, but when I use it with libclang and specify the resource directory manually, the builtins directory doesn't get added.
The text was updated successfully, but these errors were encountered:
This fixesespressif#83
In short, it adjusts the include path logic to include the builtins
directory as long as `-nostdinc` or `-nobuiltininc` isn't specified.
Previously, the builtins directory would not be included if either the
GCC installation wasn't found, or `-nostdlibinc` was specified (both of
which aren't related to the builtins directory).
This fixes#83
In short, it adjusts the include path logic to include the builtins
directory as long as `-nostdinc` or `-nobuiltininc` isn't specified.
Previously, the builtins directory would not be included if either the
GCC installation wasn't found, or `-nostdlibinc` was specified (both of
which aren't related to the builtins directory).
Clang has multiple flags for controlling the include path. From the documentation:
So in effect,
-nostdinc
implies-nostdlibinc
and-nobuiltininc
. But to control the standard system include dir and the builtins include dir separately, we have-nostdlibinc
and-nobuiltininc
to control those two kinds of include dirs separately.You can see the logic here for the RISCV toolchain:
For BareMetal it's similar, with the addition of multilib:
Unfortunately, it seems that Xtensa ignores the builtins include directory unless a GCC installation has been found. In fact, if the
-nostdlibinc
flag is passed, it exits early without adding the builtins directory at all!This makes no sense to me, since the resources directory is specific to Clang. On Linux, it's the
/usr/lib/clang/<version>/include/
directory.In TinyGo, we're not using a GCC installation. We use picolibc as the libc, and otherwise use LLVM native tools. Therefore, there is no GCC installation. To better control this, we pass
-nostdlibinc
to ignore the system libc, with the expectation that the builtins directory is still added. Xtensa is the only platform where this is not the case.Somehow this still works when using Clang as-is (hence why I don't have an easy reproducer) because Clang seems to add this directory again somewhere else, but when I use it with libclang and specify the resource directory manually, the builtins directory doesn't get added.
The text was updated successfully, but these errors were encountered: