Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,10 @@ bool analyse_argv(const char * const *argv, CompileJob &job, bool icerun, list<s
|| str_equal("-isystem-after", a)
|| str_equal("-ivfsoverlay", a)
|| str_equal("-iwithprefix", a)
|| str_equal("-serialize-diagnostics", a)
|| str_equal("--serialize-diagnostics", a)
|| str_equal("-fmodules-validate-once-per-build-session", a)
|| str_startswith("-fbuild-session-file=", a)
|| str_equal("--include-with-prefix", a)
|| str_equal("--include-with-prefix-after", a)
|| str_equal("-iwithprefixbefore", a)
Expand Down
31 changes: 1 addition & 30 deletions client/cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,36 +116,7 @@ pid_t call_cpp(CompileJob &job, int fdwrite, int fdread)
appendList(flags, job.restFlags());

for (list<string>::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<string>::iterator o = --it;
++it;
flags.erase(o);
o = it++;
flags.erase(o);
}
}
} else if ((*it) == "-include-pch") {
list<string>::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);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What trouble exactly is this part supposed to cause? The flags are removed for a reason, PCH files are not sent to the remote node, so if the flags are kept, the remote compilation may fail.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my environment, that code made building fail.
I'm using Prefix Header option on Xcode.
This option help for not including common headers which is always included.
For example, As I set prefixHeader.pch as value of Prefix Header option, I don't need to include stdarg or vector or any other in my sourcecode.

// contents of prefixHeader.pch
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <time.h>
#include <stdint.h>
#include <assert.h>
#include <sys/time.h>
#include <sys/select.h>
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>

#ifdef __OBJC__
    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>
#endif

#ifdef __cplusplus
    #include <vector>
    #include <string>
    #include <map>
    #include <list>
    #include <memory>
    #include <functional>
    #include <thread>
    #include <mutex>
    #include <unordered_map>
    #include <list>
    #include <algorithm>
    #include <cstdint>
    #include <stack>
#endif

But code that I removed make "-include prefixHeader.pch" skipped during local compilation, So build is failed because that source has not included stdio or vector or etc...

After some investigation, I found you removed the smilar code(#475 ).
I have thought the comment in the #475 can be also applied to the code I removed.
If it must not be removed, I have to find other way to support Prefix Header option.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bleows are documentations in the Xcode.

Precompile Prefix Header (GCC_PRECOMPILE_PREFIX_HEADER)
Generates a precompiled header for the prefix header, which should reduce overall build times.

Precompiling the prefix header will be most effective if the contents of the prefix header or any file it includes change rarely. If the contents of the prefix header or any file it includes change frequently, there may be a negative impact to overall build time.

Prefix Header (GCC_PREFIX_HEADER)
Implicitly include the named header. The path given should either be a project relative path or an absolute path.

Preprocessor Macros (GCC_PREPROCESSOR_DEFINITIONS)
Space-separated list of preprocessor macros of the form foo or foo=bar.

} 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
Expand Down
4 changes: 4 additions & 0 deletions client/icecc-create-env.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need changing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original:
-include and "$testdir"/includes.h is actually ignored by codes I removed in the 325aee7. So test pass successfully.

Modified:
325aee7 makes "$testdir"/includes.h starts actully to work. But there's no file with that name. Only includes.h or `"$testdir"/includes.h.gch' are exist.
So I fixed it working as I have thought it is came from mistake.

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
Expand Down