-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Add --dump-offload-bundle option to llvm-objcopy #143347
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
Open
david-salinas
wants to merge
10
commits into
llvm:main
Choose a base branch
from
david-salinas:extend-offloading-api-llvm-objcopy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0f0030c
Add --dump-offload-bundle option to llvm-objcopy
david-salinas bc29780
address PR review comments.
1447801
Code cleanup from PR comments
a454551
Resolve PR comments, add new Error tests.
78faec5
Merge branch 'main' into extend-offloading-api-llvm-objcopy
david-salinas e493a07
Merge branch 'main' into extend-offloading-api-llvm-objcopy
david-salinas 448bfce
Merge branch 'main' into extend-offloading-api-llvm-objcopy
david-salinas 79b6ace
clang-format cleanup
david-salinas 47dbdbd
resolve build error
david-salinas f88b75e
cleanup to remove warnings
david-salinas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,9 +286,13 @@ static Expected<uint8_t> parseVisibilityType(StringRef VisType) { | |
| return type; | ||
| } | ||
|
|
||
| static void llvm::objcopy::parseDumpOffloadBundle(StringRef URI) { | ||
| //static void llvm::objcopy::parseDumpOffloadBundle(StringRef URI) { | ||
|
||
| static Expected<StringRef> llvm::objcopy::parseDumpOffloadBundle(StringRef URI) { | ||
| if (Error Err = object::extractOffloadBundleByURI(URI)) | ||
| outs() << "Failed to extract from URI."; | ||
| //errs() << "Failed to extract from URI."; | ||
| return createStringError(errc::invalid_argument,"Failed to extract from URI"); | ||
jh7370 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return URI; | ||
| } | ||
|
|
||
| namespace { | ||
|
|
@@ -759,7 +763,9 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> ArgsArr, | |
|
|
||
| if (Arg *A = InputArgs.getLastArg(OBJCOPY_dump_offload_bundle)) { | ||
| for (StringRef URIStr : llvm::split(A->getValue(), ",")) { | ||
| llvm::objcopy::parseDumpOffloadBundle(URIStr); | ||
| Expected<StringRef> res = llvm::objcopy::parseDumpOffloadBundle(URIStr); | ||
| if (!res) | ||
| return res.takeError(); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1441,20 +1447,19 @@ objcopy::parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) { | |
| return createStringError( | ||
| errc::invalid_argument, | ||
| "llvm-install-name-tool expects a single input file"); | ||
| if (Config.NeedPositional) { | ||
| Config.InputFilename = Positional[0]; | ||
| Config.OutputFilename = Positional[0]; | ||
|
|
||
| Expected<OwningBinary<Binary>> BinaryOrErr = | ||
| createBinary(Config.InputFilename); | ||
| if (!BinaryOrErr) | ||
| return createFileError(Config.InputFilename, BinaryOrErr.takeError()); | ||
| auto *Binary = (*BinaryOrErr).getBinary(); | ||
| if (!Binary->isMachO() && !Binary->isMachOUniversalBinary()) | ||
| return createStringError(errc::invalid_argument, | ||
| "input file: %s is not a Mach-O file", | ||
| Config.InputFilename.str().c_str()); | ||
| } | ||
|
|
||
| Config.InputFilename = Positional[0]; | ||
| Config.OutputFilename = Positional[0]; | ||
|
|
||
| Expected<OwningBinary<Binary>> BinaryOrErr = | ||
| createBinary(Config.InputFilename); | ||
| if (!BinaryOrErr) | ||
| return createFileError(Config.InputFilename, BinaryOrErr.takeError()); | ||
| auto *Binary = (*BinaryOrErr).getBinary(); | ||
| if (!Binary->isMachO() && !Binary->isMachOUniversalBinary()) | ||
| return createStringError(errc::invalid_argument, | ||
| "input file: %s is not a Mach-O file", | ||
| Config.InputFilename.str().c_str()); | ||
| DC.CopyConfigs.push_back(std::move(ConfigMgr)); | ||
| return std::move(DC); | ||
| } | ||
|
|
@@ -1493,16 +1498,14 @@ objcopy::parseBitcodeStripOptions(ArrayRef<const char *> ArgsArr, | |
| Arg->getAsString(InputArgs).c_str()); | ||
|
|
||
| SmallVector<StringRef, 2> Positional; | ||
| if (Config.NeedPositional) { | ||
| for (auto *Arg : InputArgs.filtered(BITCODE_STRIP_INPUT)) | ||
| Positional.push_back(Arg->getValue()); | ||
| if (Positional.size() > 1) | ||
| return createStringError( | ||
| errc::invalid_argument, | ||
| "llvm-bitcode-strip expects a single input file"); | ||
| assert(!Positional.empty()); | ||
| Config.InputFilename = Positional[0]; | ||
| } | ||
| for (auto *Arg : InputArgs.filtered(BITCODE_STRIP_INPUT)) | ||
| Positional.push_back(Arg->getValue()); | ||
| if (Positional.size() > 1) | ||
| return createStringError( | ||
| errc::invalid_argument, | ||
| "llvm-bitcode-strip expects a single input file"); | ||
| assert(!Positional.empty()); | ||
| Config.InputFilename = Positional[0]; | ||
|
|
||
| if (!InputArgs.hasArg(BITCODE_STRIP_output)) { | ||
| return createStringError(errc::invalid_argument, | ||
|
|
@@ -1570,23 +1573,21 @@ objcopy::parseStripOptions(ArrayRef<const char *> RawArgsArr, | |
| MachOConfig &MachOConfig = ConfigMgr.MachO; | ||
|
|
||
| SmallVector<StringRef, 2> Positional; | ||
| if (Config.NeedPositional) { | ||
| for (auto *Arg : InputArgs.filtered(STRIP_UNKNOWN)) | ||
| return createStringError(errc::invalid_argument, "unknown argument '%s'", | ||
| Arg->getAsString(InputArgs).c_str()); | ||
| for (auto *Arg : InputArgs.filtered(STRIP_INPUT)) | ||
| Positional.push_back(Arg->getValue()); | ||
| std::copy(DashDash, RawArgsArr.end(), std::back_inserter(Positional)); | ||
|
|
||
| if (Positional.empty()) | ||
| return createStringError(errc::invalid_argument, | ||
| "no input file specified"); | ||
| for (auto *Arg : InputArgs.filtered(STRIP_UNKNOWN)) | ||
| return createStringError(errc::invalid_argument, "unknown argument '%s'", | ||
| Arg->getAsString(InputArgs).c_str()); | ||
| for (auto *Arg : InputArgs.filtered(STRIP_INPUT)) | ||
| Positional.push_back(Arg->getValue()); | ||
| std::copy(DashDash, RawArgsArr.end(), std::back_inserter(Positional)); | ||
|
|
||
| if (Positional.size() > 1 && InputArgs.hasArg(STRIP_output)) { | ||
| return createStringError( | ||
| errc::invalid_argument, | ||
| "multiple input files cannot be used in combination with -o"); | ||
| } | ||
| if (Positional.empty()) | ||
| return createStringError(errc::invalid_argument, | ||
|
||
| "no input file specified"); | ||
|
|
||
| if (Positional.size() > 1 && InputArgs.hasArg(STRIP_output)) { | ||
jh7370 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return createStringError( | ||
| errc::invalid_argument, | ||
| "multiple input files cannot be used in combination with -o"); | ||
| } | ||
|
|
||
| if (InputArgs.hasArg(STRIP_regex) && InputArgs.hasArg(STRIP_wildcard)) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ignore this. Leftover from dev work. Will remove in a new patch.