From 8e551a6badc4d84435e0deb9dba10030f9ef1f69 Mon Sep 17 00:00:00 2001 From: Nakhyun Choi Date: Mon, 27 Jul 2020 20:45:58 +0900 Subject: [PATCH 1/5] add more flags need to be sent local --- client/arg.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/arg.cpp b/client/arg.cpp index 3a26dc459..bc710d1ad 100644 --- a/client/arg.cpp +++ b/client/arg.cpp @@ -548,6 +548,10 @@ bool analyse_argv(const char * const *argv, CompileJob &job, bool icerun, list Date: Mon, 27 Jul 2020 20:52:02 +0900 Subject: [PATCH 2/5] add /var/tmp into environment for clang bitcode --- client/icecc-create-env.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/icecc-create-env.in b/client/icecc-create-env.in index 4fea59c92..713b044ac 100755 --- a/client/icecc-create-env.in +++ b/client/icecc-create-env.in @@ -491,6 +491,10 @@ if test -n "$clang"; then touch $tempdir/fakeproc/proc/cpuinfo add_file $tempdir/fakeproc/proc/cpuinfo /proc/cpuinfo fi + # clang needs tmp directory when it used with "-fembed-bitcode" + mkdir -p $tempdir/fakevar/tmp + touch $tempdir/fakevar/tmp/DUMMY + add_file $tempdir/fakevar/tmp/DUMMY /var/tmp/DUMMY fi # Do not do any prefix stripping on extra files, they (e.g. clang plugins) are usually From 325aee7d2785643d7018cc1d3c0f970e26db88cb Mon Sep 17 00:00:00 2001 From: Nakhyun Choi Date: Mon, 27 Jul 2020 20:47:29 +0900 Subject: [PATCH 3/5] remove special PCH handling also from call_cpp --- client/cpp.cpp | 31 +------------------------------ tests/test.sh | 2 +- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/client/cpp.cpp b/client/cpp.cpp index b607d962e..ee02c5691 100644 --- a/client/cpp.cpp +++ b/client/cpp.cpp @@ -116,36 +116,7 @@ pid_t call_cpp(CompileJob &job, int fdwrite, int fdread) appendList(flags, job.restFlags()); for (list::iterator it = flags.begin(); it != flags.end();) { - /* This has a duplicate meaning. it can either include a file - for preprocessing or a precompiled header. decide which one. */ - if ((*it) == "-include") { - ++it; - - if (it != flags.end()) { - std::string p = (*it); - - if (access(p.c_str(), R_OK) < 0 && access((p + ".gch").c_str(), R_OK) == 0) { - // PCH is useless for preprocessing, ignore the flag. - list::iterator o = --it; - ++it; - flags.erase(o); - o = it++; - flags.erase(o); - } - } - } else if ((*it) == "-include-pch") { - list::iterator o = it; - ++it; - if (it != flags.end()) { - std::string p = (*it); - if (access(p.c_str(), R_OK) == 0) { - // PCH is useless for preprocessing (and probably slows things down), ignore the flag. - flags.erase(o); - o = it++; - flags.erase(o); - } - } - } else if ((*it) == "-fpch-preprocess") { + if ((*it) == "-fpch-preprocess") { // This would add #pragma GCC pch_preprocess to the preprocessed output, which would make // the remote GCC try to load the PCH directly and fail. Just drop it. This may cause a build // failure if the -include check above failed to detect usage of a PCH file (e.g. because diff --git a/tests/test.sh b/tests/test.sh index 62203f39e..82ef20252 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -2206,7 +2206,7 @@ else fi run_ice "$testdir/includes.h.gch" "local" 0 "keepoutput" $TESTCXX -x c++-header -Wall -Werror -c includes.h -o "$testdir"/includes.h.gch -run_ice "$testdir/includes.o" "remote" 0 $TESTCXX -Wall -Werror -c includes.cpp -include "$testdir"/includes.h -Winvalid-pch -o "$testdir"/includes.o +run_ice "$testdir/includes.o" "remote" 0 $TESTCXX -Wall -Werror -c includes.cpp -include includes.h -Winvalid-pch -o "$testdir"/includes.o if test -n "$using_clang"; then run_ice "$testdir/includes.o" "remote" 0 $TESTCXX -Wall -Werror -c includes.cpp -include-pch "$testdir"/includes.h.gch -o "$testdir"/includes.o $TESTCXX -Werror -fsyntax-only -Xclang -building-pch-with-obj -c includes.cpp -include-pch "$testdir"/includes.h.gch 2>/dev/null From 2cf9102cf6e9172303ae41c250450c7d8e4137bb Mon Sep 17 00:00:00 2001 From: Nakhyun Choi Date: Thu, 30 Jul 2020 18:41:06 +0900 Subject: [PATCH 4/5] ignore flag which is added by Xcode GUI --- client/arg.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/arg.cpp b/client/arg.cpp index bc710d1ad..674b3f31a 100644 --- a/client/arg.cpp +++ b/client/arg.cpp @@ -220,6 +220,7 @@ static bool is_argument_with_space(const char* argument) "-iwithprefixbefore", "--include-with-prefix-before", "-iwithsysroot" + "-index-store-path" }; for(const char* const arg : arguments) { @@ -556,7 +557,8 @@ bool analyse_argv(const char * const *argv, CompileJob &job, bool icerun, list Date: Tue, 11 Aug 2020 17:31:02 +0900 Subject: [PATCH 5/5] Revert "remove special PCH handling also from call_cpp" This reverts commit 325aee7d2785643d7018cc1d3c0f970e26db88cb. --- client/cpp.cpp | 31 ++++++++++++++++++++++++++++++- tests/test.sh | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/client/cpp.cpp b/client/cpp.cpp index ee02c5691..b607d962e 100644 --- a/client/cpp.cpp +++ b/client/cpp.cpp @@ -116,7 +116,36 @@ pid_t call_cpp(CompileJob &job, int fdwrite, int fdread) appendList(flags, job.restFlags()); for (list::iterator it = flags.begin(); it != flags.end();) { - if ((*it) == "-fpch-preprocess") { + /* This has a duplicate meaning. it can either include a file + for preprocessing or a precompiled header. decide which one. */ + if ((*it) == "-include") { + ++it; + + if (it != flags.end()) { + std::string p = (*it); + + if (access(p.c_str(), R_OK) < 0 && access((p + ".gch").c_str(), R_OK) == 0) { + // PCH is useless for preprocessing, ignore the flag. + list::iterator o = --it; + ++it; + flags.erase(o); + o = it++; + flags.erase(o); + } + } + } else if ((*it) == "-include-pch") { + list::iterator o = it; + ++it; + if (it != flags.end()) { + std::string p = (*it); + if (access(p.c_str(), R_OK) == 0) { + // PCH is useless for preprocessing (and probably slows things down), ignore the flag. + flags.erase(o); + o = it++; + flags.erase(o); + } + } + } else if ((*it) == "-fpch-preprocess") { // This would add #pragma GCC pch_preprocess to the preprocessed output, which would make // the remote GCC try to load the PCH directly and fail. Just drop it. This may cause a build // failure if the -include check above failed to detect usage of a PCH file (e.g. because diff --git a/tests/test.sh b/tests/test.sh index 82ef20252..62203f39e 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -2206,7 +2206,7 @@ else fi run_ice "$testdir/includes.h.gch" "local" 0 "keepoutput" $TESTCXX -x c++-header -Wall -Werror -c includes.h -o "$testdir"/includes.h.gch -run_ice "$testdir/includes.o" "remote" 0 $TESTCXX -Wall -Werror -c includes.cpp -include includes.h -Winvalid-pch -o "$testdir"/includes.o +run_ice "$testdir/includes.o" "remote" 0 $TESTCXX -Wall -Werror -c includes.cpp -include "$testdir"/includes.h -Winvalid-pch -o "$testdir"/includes.o if test -n "$using_clang"; then run_ice "$testdir/includes.o" "remote" 0 $TESTCXX -Wall -Werror -c includes.cpp -include-pch "$testdir"/includes.h.gch -o "$testdir"/includes.o $TESTCXX -Werror -fsyntax-only -Xclang -building-pch-with-obj -c includes.cpp -include-pch "$testdir"/includes.h.gch 2>/dev/null