diff options
author | klarlund <klarlund@01de4be4-8c4a-0410-9132-4925637da917> | 2008-06-30 17:10:17 +0000 |
---|---|---|
committer | klarlund <klarlund@01de4be4-8c4a-0410-9132-4925637da917> | 2008-06-30 17:10:17 +0000 |
commit | 4a5ed9d72d3eecc60de9431d2c825aecda45ec7a (patch) | |
tree | e750abfd25ce70e5b962a4350bbd8c8e2943d304 | |
parent | 56a22fef83fefdb4c1de6185cc83c233e7e1fb60 (diff) | |
download | distcc-4a5ed9d72d3eecc60de9431d2c825aecda45ec7a.tar.gz |
Revert r393.
This change is mostly reverted -- some variable renamings are not
changed back. A subsequent CL proposes a less arbitrary way to solve
the problem of -I<some_dir_in_default_place_where_compiler_looks>,
which involves sending no system default header files at all.
Tests: make pump-check and make include-server-check
git-svn-id: http://distcc.googlecode.com/svn/trunk@543 01de4be4-8c4a-0410-9132-4925637da917
-rwxr-xr-x | include_server/include_analyzer.py | 8 | ||||
-rwxr-xr-x | include_server/include_analyzer_memoizing_node.py | 3 | ||||
-rwxr-xr-x | include_server/include_analyzer_memoizing_node_test.py | 165 | ||||
-rwxr-xr-x | include_server/include_analyzer_test.py | 2 | ||||
-rwxr-xr-x | include_server/parse_command.py | 37 | ||||
-rwxr-xr-x | include_server/parse_command_test.py | 16 |
6 files changed, 70 insertions, 161 deletions
diff --git a/include_server/include_analyzer.py b/include_server/include_analyzer.py index 801517e..48b2e5d 100755 --- a/include_server/include_analyzer.py +++ b/include_server/include_analyzer.py @@ -98,7 +98,6 @@ class IncludeAnalyzer(object): self.stat_reset_triggers = stat_reset_triggers self.translation_unit = "unknown translation unit" self.timer = None - self.send_systemdirs = False self.include_server_cwd = os.getcwd() self._InitializeAllCaches() @@ -161,8 +160,7 @@ class IncludeAnalyzer(object): statistics.parse_file_counter_last = statistics.parse_file_counter (self.quote_dirs, self.angle_dirs, self.include_files, translation_unit, - self.result_file_prefix, self.d_opts, - self.send_systemdirs) = parsed_command + self.result_file_prefix, self.d_opts) = parsed_command statistics.translation_unit = translation_unit self.translation_unit = translation_unit @@ -249,11 +247,9 @@ class IncludeAnalyzer(object): currdir, self.includepath_map, self.directory_map, - self.realpath_map, - self.systemdir_prefix_cache, self.compiler_defaults, self.timer)) - (_, _, _, source_file, result_file_prefix, _, _) = parsed_command + (_, _, _, source_file, result_file_prefix, _) = parsed_command # Do the real work. include_closure = ( diff --git a/include_server/include_analyzer_memoizing_node.py b/include_server/include_analyzer_memoizing_node.py index e5e4275..c7471f5 100755 --- a/include_server/include_analyzer_memoizing_node.py +++ b/include_server/include_analyzer_memoizing_node.py @@ -609,7 +609,6 @@ class IncludeAnalyzerMemoizingNode(include_analyzer.IncludeAnalyzer): starts_with_systemdir = self.systemdir_prefix_cache.cache dir_map_string = self.directory_map.string if not node: return - send_systemdirs = self.send_systemdirs stack = ([node]) # TODO(csilvers): consider using a deque if __debug__: statistics.len_calculated_closure_nonsys = 0 while stack: @@ -628,7 +627,7 @@ class IncludeAnalyzerMemoizingNode(include_analyzer.IncludeAnalyzer): if __debug__: statistics.len_calculated_closure_nonsys += 1 # We ignore "system" includes like /usr/include/stdio.h. # These files are not likely to change, so it's safe to skip them. - if not starts_with_systemdir[node[0]] or send_systemdirs: + if not starts_with_systemdir[node[0]]: # Add the resolved filepath to those found for realpath. if node[0] not in include_closure: include_closure[node[0]] = [] diff --git a/include_server/include_analyzer_memoizing_node_test.py b/include_server/include_analyzer_memoizing_node_test.py index 8139be5..d3247db 100755 --- a/include_server/include_analyzer_memoizing_node_test.py +++ b/include_server/include_analyzer_memoizing_node_test.py @@ -26,7 +26,6 @@ import basics import parse_command import cache_basics import include_analyzer_memoizing_node -import compiler_defaults import unittest NotCoveredError = basics.NotCoveredError @@ -150,23 +149,21 @@ class IncludeAnalyzerMemoizingNodeUnitTest(unittest.TestCase): self.assertEqual(len(stringified_include_closure), 4) - def _ConstructDistccCommandLine(self, src_stem, extra_arg=""): + def _ConstructDistccCommandLine(self, src_stem): # A command line, which is more or less the one found in the # generated Makefile for distcc. We don't need the exact form of # the command." - return ("gcc -DHAVE_CONFIG_H -D_GNU_SOURCE" - " %s" - " -I./src" - ' -DSYSCONFDIR="/usr/local/etc"' - ' -DPKGDATADIR="/usr/local/share/distcc"' - " -Isrc" - " -I./lzo" - " -include include_me.h " - " -o src/%s.o" - " -c src/%s.c") % (extra_arg, src_stem, src_stem) - - def _CheckIncludeClosureOnDistcc(self, expected_suffixes, - extra_arg="", system_dirs=[]): + return ("gcc -DHAVE_CONFIG_H -D_GNU_SOURCE" + + " -I./src" + + ' -DSYSCONFDIR="/usr/local/etc"' + + ' -DPKGDATADIR="/usr/local/share/distcc"' + + " -Isrc" + + " -I./lzo" + + " -include include_me.h " + + " -o src/%s.o" + + " -c src/%s.c") % (src_stem, src_stem) + + def test__CalculateIncludeClosureExceptSystem_on_distcc(self): includepath_map = self.includepath_map canonical_path = self.canonical_path @@ -174,106 +171,64 @@ class IncludeAnalyzerMemoizingNodeUnitTest(unittest.TestCase): realpath_map = self.realpath_map include_analyzer = self.include_analyzer - current_dir_original = os.getcwd() current_dir = os.path.realpath("test_data/distcc") + os.chdir(current_dir) - try: - os.chdir(current_dir) + src_stem = "distcc" + cmd = self._ConstructDistccCommandLine(src_stem) - src_stem = "distcc" - cmd = self._ConstructDistccCommandLine(src_stem, extra_arg) - print 'cmd', cmd - parsed_command = ( - parse_command.ParseCommandArgs( - parse_command.ParseCommandLine(cmd), - current_dir, - include_analyzer.includepath_map, - include_analyzer.directory_map, - include_analyzer.realpath_map, - include_analyzer.systemdir_prefix_cache, - include_analyzer.compiler_defaults)) + parsed_command = ( + parse_command.ParseCommandArgs( + parse_command.ParseCommandLine(cmd), + current_dir, + include_analyzer.includepath_map, + include_analyzer.directory_map, + include_analyzer.compiler_defaults)) - (include_analyzer.quote_dirs, - include_analyzer.angle_dirs, - include_analyzer.include_files, - translation_unit, - include_analyzer.result_file_prefix, - _, - include_analyzer.send_systemdirs) = parsed_command + (include_analyzer.quote_dirs, + include_analyzer.angle_dirs, + include_analyzer.include_files, + translation_unit, + include_analyzer.result_file_prefix, + _) = parsed_command - self.assertEqual(translation_unit, "src/%s.c" % src_stem) + self.assertEqual(translation_unit, "src/%s.c" % src_stem) - include_closure = ( - include_analyzer.ProcessCompilationCommand(current_dir, - parsed_command)) - - expected_prefix = os.getcwd() + '/' - - expected = set([os.path.join(expected_prefix, expected_suffix) - for expected_suffix in expected_suffixes]) - - found = set(realpath_map.string[key] for key in include_closure) - - self.failUnless(expected <= found) - - residue = found - expected - - for header in residue: - self.failUnless( - include_analyzer.systemdir_prefix_cache.StartsWithSystemdir( - realpath_map.Index(header), realpath_map)) - - if not system_dirs: - for rp_idx in include_closure: - self.assertEqual(len(include_closure[rp_idx]), 0) + expected_suffixes = [ + "src/include_me.h", + "src/implicit.h", + "src/distcc.c", + "src/config.h", + "src/distcc.h", + "src/state.h", + "src/compile.h", + "src/trace.h", + "src/exitcode.h", + "src/util.h", + "src/hosts.h", + "src/bulk.h", + "src/emaillog.h"] + + include_closure = ( + include_analyzer.ProcessCompilationCommand(current_dir, + parsed_command)) - # TODO(klarlund): massage command so as to test that with a - # different search path files are reported as absolute. That is, - # provoke pairs (directory_idx, includepath_idx) to exist in - # include_closure[rp_idx]. + expected_prefix = os.getcwd() + '/' - finally: - os.chdir(current_dir_original) + expected = set([ expected_prefix + expected_suffix + for expected_suffix in expected_suffixes ]) + self.assertEqual(set([realpath_map.string[key] + for key in include_closure.keys()]), + expected) - def test_CalculateIncludeClosureOnDistccWithoutSysdir(self): - expected_suffixes = [ - "src/include_me.h", - "src/implicit.h", - "src/distcc.c", - "src/config.h", - "src/distcc.h", - "src/state.h", - "src/compile.h", - "src/trace.h", - "src/exitcode.h", - "src/util.h", - "src/hosts.h", - "src/bulk.h", - "src/emaillog.h"] - self._CheckIncludeClosureOnDistcc(expected_suffixes) - - def test_CalculateIncludeClosureOnDistccWithSysdir(self): - systemdirs = compiler_defaults._SystemSearchdirsGCC( - 'gcc', 'c', lambda x:x) - assert systemdirs - assert os.path.isdir(systemdirs[0]), systemdirs - expected_suffixes = [ - "src/include_me.h", - "src/implicit.h", - "src/distcc.c", - "src/config.h", - "src/distcc.h", - "src/state.h", - "src/compile.h", - "src/trace.h", - "src/exitcode.h", - "src/util.h", - "src/hosts.h", - "src/bulk.h", - "src/emaillog.h"] - self._CheckIncludeClosureOnDistcc( - expected_suffixes, "-isystem " + systemdirs[0], systemdirs) + for rp_idx in include_closure: + self.assertEqual(len(include_closure[rp_idx]), 0) + # TODO(klarlund): massage command so as to test that with a + # different search path files are reported as absolute. That is, + # provoke pairs (directory_idx, includepath_idx) to exist in + # include_closure[rp_idx]. + def tearDown(self): pass diff --git a/include_server/include_analyzer_test.py b/include_server/include_analyzer_test.py index 3dba929..4232934 100755 --- a/include_server/include_analyzer_test.py +++ b/include_server/include_analyzer_test.py @@ -71,8 +71,6 @@ class IncludeAnalyzerTest(unittest.TestCase): cwd, self.include_analyzer.includepath_map, self.include_analyzer.directory_map, - self.include_analyzer.realpath_map, - self.include_analyzer.systemdir_prefix_cache, self.include_analyzer.compiler_defaults))) def CanonicalPathsForTestData(self, dirs, test_data_dir='test_data'): diff --git a/include_server/parse_command.py b/include_server/parse_command.py index 6b3faa0..e58f973 100755 --- a/include_server/parse_command.py +++ b/include_server/parse_command.py @@ -56,7 +56,6 @@ class ParseState: self.output_file = None self.iprefix = "" self.Dopts = [] - self.send_systemdirs = False def set_nostdinc(self): self.nostdinc = True def set_language(self, x): self.language = x @@ -64,16 +63,6 @@ class ParseState: def set_sysroot(self, x): self.sysroot = x def set_outputfile(self, x): self.output_file = x def set_iprefix(self, x): self.iprefix = x - - def _ProcessIsystem(self, arg): - """Investigate whether to turn send_systemdirs on.""" - if arg.startswith('/'): - # Determine whether this is an include of a default system directory of the - # compiler (or a subdirectory thereof). - realpath_idx = self.realpath_map.Index(os.path.realpath(arg)) - self.send_systemdirs |= self.systemdir_prefix_cache.StartsWithSystemdir( - realpath_idx, self.realpath_map) - def _SplitMacroArg(arg): """Split an arg as found in -Darg @@ -314,8 +303,8 @@ TRANSLATION_UNIT_FILEPATH_RE = ( for ext in basics.TRANSLATION_UNIT_MAP.keys()]))) -def ParseCommandArgs(args, current_dir, includepath_map, dir_map, realpath_map, - systemdir_prefix_cache, compiler_defaults, timer=None): +def ParseCommandArgs(args, current_dir, includepath_map, dir_map, + compiler_defaults, timer=None): """Parse arguments like -I to make include directory lists. Arguments: @@ -323,8 +312,6 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map, realpath_map, current_dir: string includepath_map: a MapToIndex object dir_map: a DirectoryMapToIndex object - realpath_map: a CanonicalMapToIndex cache - systemdir_prefix_cache: a SystemdirPrefixCache compiler_defaults: a CompilerDefaults object timer: a basics.IncludeAnalyzerTimer object Returns: @@ -335,26 +322,15 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map, realpath_map, files: a list of includepath_map-indexed files source_file_prefix: the source file name with extension stripped dopts: a list of items as returned by _SplitMacroArg - send_systemdirs: a boolean, true only in exceptional cases Modifies: compiler_defaults - - The send_systemdirs boolean is normally false. It is true if there is a - -isystem option with a default system directory (one known to the compiler). - With send_systemdirs true, the compiler headers of system headers are sent to - the servers and mounted under the server root. The isystem option is as usual - rewritten to be relative to the root. Without this flag setting, distcc - quickly decides that pump mode is not viable because remote compilations fail. """ if __debug__: Debug(DEBUG_TRACE, "ParseCommand %s" % args) assert isinstance(dir_map, cache_basics.DirectoryMapToIndex) assert isinstance(includepath_map, cache_basics.MapToIndex) - assert isinstance(realpath_map, cache_basics.CanonicalMapToIndex) parse_state = ParseState() - parse_state.realpath_map = realpath_map - parse_state.systemdir_prefix_cache = systemdir_prefix_cache if len(args) < 2: raise NotCoveredError("Command line: too few arguments.") @@ -488,14 +464,9 @@ def ParseCommandArgs(args, current_dir, includepath_map, dir_map, realpath_map, ignore_absolute_path_warning=True) for f in parse_state.include_files]) - # Send default system dirs? - for isystem_dir in parse_state.before_system_dirs: - parse_state._ProcessIsystem(isystem_dir) - if __debug__: Debug(DEBUG_TRACE, ("ParseCommand result: %s %s %s %s %s %s" % (quote_dirs, angle_dirs, include_files, source_file, source_file_prefix, parse_state.Dopts))) - - return (quote_dirs, angle_dirs, include_files, source_file, - source_file_prefix, parse_state.Dopts, parse_state.send_systemdirs) + return (quote_dirs, angle_dirs, include_files, source_file, source_file_prefix, + parse_state.Dopts) diff --git a/include_server/parse_command_test.py b/include_server/parse_command_test.py index 4d8ddfb..a982775 100755 --- a/include_server/parse_command_test.py +++ b/include_server/parse_command_test.py @@ -116,8 +116,7 @@ class ParseCommandUnitTest(unittest.TestCase): def test_ParseCommandArgs(self): - (quote_dirs, angle_dirs, include_files, filepath, _incl_clos_f, _d_opts, - send_systemdirs) = ( + quote_dirs, angle_dirs, include_files, filepath, _incl_clos_f, _d_opts = ( parse_command.ParseCommandArgs( parse_command.ParseCommandLine( self.mock_compiler + " -isystem system -Imice -iquote/and -I/men a.c " @@ -127,8 +126,6 @@ class ParseCommandUnitTest(unittest.TestCase): os.getcwd(), self.includepath_map, self.directory_map, - self.realpath_map, - self.systemdir_prefix_cache, self.compiler_defaults)) self.assertEqual( @@ -149,12 +146,9 @@ class ParseCommandUnitTest(unittest.TestCase): os.getcwd(), self.includepath_map, self.directory_map, - self.realpath_map, - self.systemdir_prefix_cache, self.compiler_defaults) - (quote_dirs, angle_dirs, include_files, filepath, _incl_cls_file, _d_opts, - send_systemdirs) = ( + quote_dirs, angle_dirs, include_files, filepath, _incl_cls_file, _d_opts = ( parse_command.ParseCommandArgs(parse_command.ParseCommandLine( "/usr/crosstool/v8/gcc-4.1.0-glibc-2.2.2/blah/gcc" + " -fno-exceptions -funsigned-char -D__STDC_FORMAT_MACROS -g0" @@ -168,8 +162,6 @@ class ParseCommandUnitTest(unittest.TestCase): os.getcwd(), self.includepath_map, self.directory_map, - self.realpath_map, - self.systemdir_prefix_cache, self.compiler_defaults)) self.assertEqual( (self._RetrieveDirectoriesExceptSys(quote_dirs), @@ -191,14 +183,12 @@ class ParseCommandUnitTest(unittest.TestCase): t = time.time() for unused_i in range(100): (quote_dirs, angle_dirs, include_files, filepath, - _include_closure_file, _d_opts, send_systemdirs) = ( + _include_closure_file, _d_opts) = ( parse_command.ParseCommandArgs( parse_command.ParseCommandLine(whopper), os.getcwd(), self.includepath_map, self.directory_map, - self.realpath_map, - self.systemdir_prefix_cache, self.compiler_defaults)) print "100 iterations of ParseCommandArgs takes %3.1fs" % (time.time() - t) return True |