-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc] Add ${CMAKE_CROSSCOMPILING_EMULATOR} to custom test cmdlines #66565
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
Merged
Merged
Changes from 1 commit
Commits
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
We do the following for the GPU build.
This looks very similar to cross-compiling by design. I'm thinking it would be good to unify this approach with the GPU build. This is just me thinking out loud.
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 sounds like a good idea, but how do you handle env variables in these cases?
Currently, the script I wrote expects
<env variables> <full path to binary> <args>to work properly... We need the full path to the binary to scp any test data present in the binary directory; we then copy the binary to a temp dir in the qemu-system and callssh foo@bar <env variables> ~/<temp dir>/<binary> <args>.(I should probably upload the script I'm using somewhere).
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 don't use any env vars, but presumably it would be handled just by the loader. E.g. if I do
env foo ./amdhsa_loader <args> <image>it would readfoofrom the environment and pass it to theimageit launches.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.
do you know does it detects the foo env variable in the loader? Or will it just send every env var on the system to the image?
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.
Every single one, it clones the current user environment.
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.
https://github.com/llvm/llvm-project/blob/main/libc/utils/gpu/loader/Loader.h#L92 here's the code for it, pretty much just uses the
envppassed in from themainfunction.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 actually makes things easier for me.
What do you think about dropping
gpu_loader_exeand using justCMAKE_CROSSCOMPILING_EMULATORinstead?Uh oh!
There was an error while loading. Please reload this page.
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.
Would this be an argument passed in the
cmakeinvocation? Because thegpu_loader_exeis built internally so it's not known until CMake runs. We could potentially just setCMAKE_CROSSCOMPILING_EMULATORmanually inside oflibc? Maybe that would override something the user set, unsure.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 just ran some tests here and it works both ways: either you set it during the cmake config via cmd line or you can set it using
set(CMAKE_CROSSCOMPILING_EMULATOR "foobar").My only concern is that it doesn't tell the user that it overwrote an argument passed via cmd line, but I guess we can always throw a warning there.
I'll update this PR to put
$CMAKE_CROSSCOMPILING_EMULATORright after the$gpu_loader_exefor now, and send all environment variables as the loader does. If you can test using only$CMAKE_CROSSCOMPILING_EMULATORand it does work, we can send another PR to remove$gpu_loader_exelater.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.
SG, I'll test it once this lands.