diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 4e5f689498d69b35aba7e843b73405bf4fab71ee..7e78e4d8d3516b27b51ff5284cf1401e267a305f 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4689,6 +4689,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, #ifdef BUILD_FOR_OPENEULER if (Args.hasFlag(options::OPT_fgcc_compatible, options::OPT_fno_gcc_compatible, false)) { + if (Args.hasArg(options::OPT_nostdinc) && !Args.hasArg(options::OPT_iprefix)) { + SmallString<128> P(D.ResourceDir); + P += llvm::sys::path::get_separator(); + CmdArgs.insert(CmdArgs.begin() + 1, "-iprefix"); + CmdArgs.insert(CmdArgs.begin() + 2, Args.MakeArgString(P)); + } // compatibility relevent warnings CmdArgs.push_back("-Wno-error=unknown-warning-option"); CmdArgs.push_back("-Wno-error=ignored-attributes"); diff --git a/clang/test/Driver/prefix.c b/clang/test/Driver/prefix.c new file mode 100644 index 0000000000000000000000000000000000000000..7f1cb4672c3940ea05fc04876c3bb032a0a3d3b1 --- /dev/null +++ b/clang/test/Driver/prefix.c @@ -0,0 +1,14 @@ +// REQUIRES: build_for_openeuler + +// RUN: %clang %s +// RUN: %clang -iprefix $(dirname `which clang`)/../lib/clang/*/ -iwithprefix include %s +// RUN: %clang -iwithprefix include %s +// RUN: %clang -nostdinc -iwithprefix include %s -fgcc-compatible +// RUN: %clang -nostdinc -iprefix $(dirname `which clang`)/../lib/clang/*/ -iwithprefix include %s -fgcc-compatible +// RUN: not %clang -nostdinc -iwithprefix include %s +// RUN: not %clang -nostdinc -iprefix "" -iwithprefix include %s + +#include +int main(void) { +return 0; +}