Skip to content

Conversation

bulbazord
Copy link
Member

It's possible for this logic to fail if the build system runs this script in parallel. One instance could create the directory in between another instance's checking of its existence and attempt at creation.

Instead, always try to create it and ignore any FileExistsErrors.

rdar://160120161

It's possible for this logic to fail if the build system runs this
script in parallel. One instance could create the directory in between
another instance's checking of its existence and attempt at creation.

Instead, always try to create it and ignore any FileExistsErrors.

rdar://160120161
@llvmbot
Copy link
Member

llvmbot commented Sep 12, 2025

@llvm/pr-subscribers-lldb

Author: Alex Langford (bulbazord)

Changes

It's possible for this logic to fail if the build system runs this script in parallel. One instance could create the directory in between another instance's checking of its existence and attempt at creation.

Instead, always try to create it and ignore any FileExistsErrors.

rdar://160120161


Full diff: https://github.com/llvm/llvm-project/pull/158355.diff

1 Files Affected:

  • (modified) lldb/scripts/framework-header-fix.py (+3-1)
diff --git a/lldb/scripts/framework-header-fix.py b/lldb/scripts/framework-header-fix.py
index 36c5c67c59d36..3447dfc29a761 100755
--- a/lldb/scripts/framework-header-fix.py
+++ b/lldb/scripts/framework-header-fix.py
@@ -115,8 +115,10 @@ def main():
         unifdef_guards = ["-U" + guard for guard in args.unifdef_guards]
 
     # Create the framework's header dir if it doesn't already exist
-    if not os.path.exists(os.path.dirname(output_file_path)):
+    try:
         os.makedirs(os.path.dirname(output_file_path))
+    except FileExistsError:
+        pass
 
     if framework_version == "lldb_main":
         modify_main_includes(input_file_path, output_file_path)

@bulbazord
Copy link
Member Author

Test failures look unrelated.

@bulbazord bulbazord merged commit 120d747 into llvm:main Sep 12, 2025
10 of 11 checks passed
@bulbazord bulbazord deleted the framework-header-fix-fix branch September 12, 2025 23:38
@JDevlieghere
Copy link
Member

Why don't we ensure the build system creates the directory instead?

kastiglione pushed a commit to swiftlang/llvm-project that referenced this pull request Sep 17, 2025
…158355)

It's possible for this logic to fail if the build system runs this
script in parallel. One instance could create the directory in between
another instance's checking of its existence and attempt at creation.

Instead, always try to create it and ignore any FileExistsErrors.

rdar://160120161
(cherry picked from commit 120d747)
kastiglione pushed a commit to swiftlang/llvm-project that referenced this pull request Sep 17, 2025
…158355)

It's possible for this logic to fail if the build system runs this
script in parallel. One instance could create the directory in between
another instance's checking of its existence and attempt at creation.

Instead, always try to create it and ignore any FileExistsErrors.

rdar://160120161
(cherry picked from commit 120d747)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants