-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the same patching script and command for all repos #584
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" | ||
Script to apply a set of patches to llvm-project sources. | ||
Script to apply a set of patches to a git repository. | ||
""" | ||
|
||
import argparse | ||
|
@@ -18,8 +18,8 @@ def main(): | |
help="Set of patches to apply. This should be a directory containing one or more ordered *.patch files.", | ||
) | ||
parser.add_argument( | ||
"--llvm_dir", | ||
help="Directory of the llvm-project git checkout, if not the current directory.", | ||
"--repo_dir", | ||
help="Directory of the git checkout, if not the current directory.", | ||
) | ||
parser.add_argument( | ||
"--method", | ||
|
@@ -36,10 +36,20 @@ def main(): | |
action="store_true", | ||
help="If a patch in a series cannot be applied, restore the original state instead of leaving patches missing. Return code will be 2 instead of 1.", | ||
) | ||
parser.add_argument( | ||
"--3way", | ||
action="store_true", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks as if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The I'll update the commit message when squashing to mention all this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine – that makes sense. If it's disabled on purpose and you say why, I'm happy. |
||
dest="three_way", | ||
help="If the patch does not apply cleanly, fall back on 3-way merge.", | ||
) | ||
args = parser.parse_args() | ||
|
||
if args.llvm_dir: | ||
git_cmd = ["git", "-C", args.llvm_dir] | ||
if args.method == "apply" and args.restore_on_fail and args.three_way: | ||
print("--restore_on_fail is incompatible with --3way using apply") | ||
exit(1) | ||
|
||
if args.repo_dir: | ||
git_cmd = ["git", "-C", args.repo_dir] | ||
else: | ||
git_cmd = ["git"] | ||
|
||
|
@@ -57,7 +67,9 @@ def main(): | |
print("\n".join(p.name for p in patch_list)) | ||
|
||
if args.method == "am": | ||
merge_args = git_cmd + ["am", "-k", "--ignore-whitespace", "--3way"] | ||
merge_args = git_cmd + ["am", "-k", "--ignore-whitespace"] | ||
if args.three_way: | ||
merge_args.append("--3way") | ||
for patch in patch_list: | ||
merge_args.append(str(patch)) | ||
p = subprocess.run(merge_args, capture_output=True, text=True) | ||
|
@@ -72,8 +84,8 @@ def main(): | |
# git am doesn't give any specific return codes, | ||
# so check for unresolved working files. | ||
rebase_apply_path = os.path.join(".git", "rebase-apply") | ||
if args.llvm_dir: | ||
rebase_apply_path = os.path.join(args.llvm_dir, rebase_apply_path) | ||
if args.repo_dir: | ||
rebase_apply_path = os.path.join(args.repo_dir, rebase_apply_path) | ||
if os.path.isdir(rebase_apply_path): | ||
print("Aborting git am...") | ||
subprocess.run(git_cmd + ["am", "--abort"], check=True) | ||
|
@@ -90,10 +102,11 @@ def main(): | |
apply_check_args = git_cmd + [ | ||
"apply", | ||
"--ignore-whitespace", | ||
"--3way", | ||
"--check", | ||
str(current_patch), | ||
] | ||
if args.three_way: | ||
apply_check_args.append("--3way") | ||
apply_check_args.append(str(current_patch)) | ||
p_check = subprocess.run(apply_check_args) | ||
|
||
if p_check.returncode == 0: | ||
|
@@ -102,10 +115,11 @@ def main(): | |
apply_args = git_cmd + [ | ||
"apply", | ||
"--ignore-whitespace", | ||
"--3way", | ||
str(current_patch), | ||
] | ||
apply_args = subprocess.run(apply_args, check=True) | ||
if args.three_way: | ||
apply_args.append("--3way") | ||
apply_args.append(str(current_patch)) | ||
p = subprocess.run(apply_args, check=True) | ||
applied_patches.append(current_patch) | ||
else: | ||
# Patch won't apply. | ||
|
@@ -118,10 +132,11 @@ def main(): | |
reverse_args = git_cmd + [ | ||
"apply", | ||
"--ignore-whitespace", | ||
"--3way", | ||
"--reverse", | ||
str(previous_patch), | ||
] | ||
if args.three_way: | ||
reverse_args.append("--3way") | ||
reverse_args.append(str(previous_patch)) | ||
p_check = subprocess.run(reverse_args, check=True) | ||
print( | ||
f"Rollback successful, failure occured on {current_patch.name}" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,40 @@ | ||
From 0e1475e5112b986ef5d9caee23dac554c749c54b Mon Sep 17 00:00:00 2001 | ||
From: David Candler <[email protected]> | ||
Date: Thu, 28 Nov 2024 15:31:35 +0000 | ||
Subject: [PATCH] Enable newlib build | ||
|
||
--- | ||
libgloss/aarch64/syscalls.c | 6 ++ | ||
libgloss/arm/cpu-init/rdimon-aem.S | 107 ++++++++++++------------ | ||
libgloss/arm/crt0.S | 2 +- | ||
libgloss/arm/linux-crt0.c | 2 +- | ||
libgloss/arm/syscalls.c | 6 +- | ||
libgloss/arm/trap.S | 2 +- | ||
libgloss/libnosys/configure | 2 +- | ||
newlib/libc/include/sys/features.h | 2 + | ||
newlib/libc/machine/aarch64/memchr.S | 6 +- | ||
newlib/libc/machine/aarch64/strchr.S | 6 +- | ||
newlib/libc/machine/aarch64/strchrnul.S | 6 +- | ||
newlib/libc/machine/aarch64/strrchr.S | 10 +-- | ||
newlib/libc/stdlib/aligned_alloc.c | 1 + | ||
newlib/libc/sys/arm/crt0.S | 2 +- | ||
newlib/libc/sys/arm/trap.S | 2 +- | ||
newlib/libm/machine/arm/sf_ceil.c | 2 +- | ||
newlib/libm/machine/arm/sf_floor.c | 2 +- | ||
newlib/libm/machine/arm/sf_nearbyint.c | 2 +- | ||
newlib/libm/machine/arm/sf_rint.c | 2 +- | ||
newlib/libm/machine/arm/sf_round.c | 2 +- | ||
newlib/libm/machine/arm/sf_trunc.c | 2 +- | ||
21 files changed, 92 insertions(+), 82 deletions(-) | ||
|
||
diff --git a/libgloss/aarch64/syscalls.c b/libgloss/aarch64/syscalls.c | ||
index 7343cc61f..2c4b63c17 100644 | ||
--- a/libgloss/aarch64/syscalls.c | ||
+++ b/libgloss/aarch64/syscalls.c | ||
@@ -172,6 +172,12 @@ newslot (void) | ||
return i; | ||
} | ||
|
||
+int __aarch64_sme_accessible() { | ||
+ int result = 0; | ||
+ asm volatile ( "mrs %x[result], id_aa64pfr1_el1" : [result]"=r"(result) : : ); | ||
|
@@ -635,3 +664,6 @@ index 64e4aeb9a..c08fa6fed 100644 | |
#include <math.h> | ||
|
||
float | ||
-- | ||
2.43.0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some code duplication here. Perhaps it could be refactored into (yet) another include file that would define
patch_dir
, and a combinedpatch_script_command
list variable containing all of${Python3_EXECUTABLE} ${patch_script} ${patch_script_args}
?Then the LLVM file would still be able to have its special case of conditionally adding a second invocation of the whole thing, but there'd be just one place to add further refinements like
GIT_PATCH_METHOD
(which I like!)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be neater, so I've wrapped it into a simple function which generates the required command for a given target folder, which the LLVM version can simply call twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you've slightly improved on my suggestion, by folding all use of
patch_dir
into the include file instead of having it just defined there and used by the caller. I like it!