diff --git a/tools/system_libs.py b/tools/system_libs.py index ea06d88515a74..4adeeac5c9b5b 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -219,7 +219,6 @@ def create_ninja_file(input_files, filename, libname, cflags, asflags=None, cust suffix = shared.suffix(libname) build_dir = os.path.dirname(filename) - case_insensitive = is_case_insensitive(os.path.dirname(filename)) if suffix == '.o': assert len(input_files) == 1 input_file = escape_ninja_path(input_files[0]) @@ -229,12 +228,11 @@ def create_ninja_file(input_files, filename, libname, cflags, asflags=None, cust else: objects = [] for src in input_files: - # Resolve duplicates by appending unique. - # This is needed on case insensitive filesystem to handle, - # for example, _exit.o and _Exit.o. - object_basename = shared.unsuffixed_basename(src) - if case_insensitive: - object_basename = object_basename.lower() + # Resolve duplicates by appending unique. This is needed on case + # insensitive filesystem to handle, for example, _exit.o and _Exit.o. + # This is done even on case sensitive filesystem so that builds are + # reproducible across platforms. + object_basename = shared.unsuffixed_basename(src).lower() o = os.path.join(build_dir, object_basename + '.o') object_uuid = 0 # Find a unique basename @@ -270,14 +268,6 @@ def create_ninja_file(input_files, filename, libname, cflags, asflags=None, cust ensure_target_in_ninja_file(get_top_level_ninja_file(), f'subninja {escape_ninja_path(filename)}') -def is_case_insensitive(path): - """Returns True if the filesystem at `path` is case insensitive.""" - utils.write_file(os.path.join(path, 'test_file'), '') - case_insensitive = os.path.exists(os.path.join(path, 'TEST_FILE')) - os.remove(os.path.join(path, 'test_file')) - return case_insensitive - - class Library: """ `Library` is the base class of all system libraries. @@ -490,7 +480,6 @@ def build_objects(self, build_dir): commands = [] objects = set() cflags = self.get_cflags() - case_insensitive = is_case_insensitive(build_dir) for src in self.get_files(): ext = shared.suffix(src) if ext in {'.s', '.S', '.c'}: @@ -507,15 +496,12 @@ def build_objects(self, build_dir): cmd += cflags cmd = self.customize_build_cmd(cmd, src) - object_basename = shared.unsuffixed_basename(src) - if case_insensitive: - object_basename = object_basename.lower() + object_basename = shared.unsuffixed_basename(src).lower() o = os.path.join(build_dir, object_basename + '.o') if o in objects: - # If we have seen a file with the same name before, we are on a case-insensitive - # filesystem and need a separate command to compile this file with a - # custom unique output object filename, as batch compile doesn't allow - # such customization. + # If we have seen a file with the same name before, we need a separate + # command to compile this file with a custom unique output object + # filename, as batch compile doesn't allow such customization. # # This is needed to handle, for example, _exit.o and _Exit.o. object_uuid = 0 @@ -530,6 +516,8 @@ def build_objects(self, build_dir): src = os.path.relpath(src, build_dir) src = utils.normalize_path(src) batches.setdefault(tuple(cmd), []).append(src) + # No -o in command, use original file name. + o = os.path.join(build_dir, shared.unsuffixed_basename(src) + '.o') else: commands.append(cmd + [src, '-o', o]) objects.add(o)