Skip to content

Commit

Permalink
Revert D66765884: fail builds with duplicate module names
Browse files Browse the repository at this point in the history
Differential Revision:
D66765884

Original commit changeset: 7386ab379882

Original Phabricator Diff: D66765884

fbshipit-source-id: 0ce59144cf999bb43057230a7c0c2f39ecb5b458
  • Loading branch information
rmaz authored and facebook-github-bot committed Dec 12, 2024
1 parent d248699 commit 6c1818e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 51 deletions.
1 change: 0 additions & 1 deletion apple/swift/swift_module_map.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ def write_swift_module_map_with_deps(
return ctx.actions.write_json(
module_name + ".swift_module_map.json",
all_deps.project_as_json("swift_module_map"),
pretty = True,
with_inputs = True,
)
50 changes: 0 additions & 50 deletions apple/tools/swift_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree.

import json
import os
import subprocess
import sys
Expand All @@ -15,42 +14,6 @@
_FILE_WRITE_FAILURE_MARKER = "could not write"


def expand_argsfile(command):
for arg in command:
if arg.startswith("@"):
with open(arg[1:]) as f:
return f.read().splitlines()

return []


def validate_swift_module_map(path):
seen_clang_modules = set()
seen_swift_modules = set()
with open(path, "r") as f:
j = json.load(f)

for entry in j:
is_clang_module = "clangModulePath" in entry
module_name = entry["moduleName"]
if is_clang_module:
if module_name in seen_clang_modules:
print(
f"Duplicate clang module {module_name} found in {path}",
file=sys.stderr,
)
sys.exit(1)
seen_clang_modules.add(module_name)
else:
if module_name in seen_swift_modules:
print(
f"Duplicate Swift module {module_name} found in {path}",
file=sys.stderr,
)
sys.exit(1)
seen_swift_modules.add(module_name)


def main():
env = os.environ.copy()
if "INSIDE_RE_WORKER" in env and _RE_TMPDIR_ENV_VAR in env:
Expand All @@ -71,19 +34,6 @@ def main():
env["CLANG_MODULE_CACHE_PATH"] = "/tmp/buck-module-cache"

command = sys.argv[1:]

# T209485965: swift module maps allow for duplicate entries
# and the first one will be picked. Until we have a compiler
# warning for this case we need to validate here.
expanded_args = expand_argsfile(command)
for i in range(len(expanded_args)):
if expanded_args[i] == "-explicit-swift-module-map-file":
if expanded_args[i + 1] == "-Xfrontend":
validate_swift_module_map(expanded_args[i + 2])
else:
validate_swift_module_map(expanded_args[i + 1])
break

# Apply a debug prefix map for the current directory
# to make debug info relocatable. To correctly make paths
# relocatable, we must use that path at which the action
Expand Down

0 comments on commit 6c1818e

Please sign in to comment.