This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Use -nostdinc++ in clang_rt.profile to avoid including C++ headers
ClosedPublic

Authored by ldionne on Jul 20 2020, 3:55 PM.

Details

Summary

Most of the code in compiler_rt is C code. However, clang_rt.profile
contains the InstrProfilingRuntime.cpp file, which builds as C++. This
means that including e.g. <stdint.h> will actually include libc++'s
<stdint.h> and then #include_next the system's <stdint.h>. However, if
the target we're building compiler-rt for isn't supported by libc++,
this will lead to a failure since libc++'s <stdint.h> includes <__config>,
which performs various checks.

Since the goal seems to *not* be including any header from the C++ Standard
Library in clang_rt.profile, using -nostdinc++ to ensure that doesn't
happen unknowingly seems to make sense.

Diff Detail

Event Timeline

ldionne created this revision.Jul 20 2020, 3:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2020, 3:55 PM
Herald added subscribers: Restricted Project, jkorous, mgorny, dberris. · View Herald Transcript

I am unsure who's the right people to look at this, so I added some based on $ git shortlog -sne -- compiler-rt/lib/profile.

This revision is now accepted and ready to land.Jul 20 2020, 4:49 PM
This revision was automatically updated to reflect the committed changes.