Add Makefile for executing user space apps on QEMU guest shell - #384
Open
StevenChen1997 wants to merge 1 commit into
Open
StevenChen1997 wants to merge 1 commit into
StevenChen1997 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
visitorckw
suggested changes
Aug 22, 2026
visitorckw
left a comment
Collaborator
There was a problem hiding this comment.
Since patch 2 looks like just a fixup for previous patches, please squash them to keep the git history clean.
In current QEMU environment, we have no C runtime library to execute user application 'userspace_ioctl' and 'cat_nonblock'. An alternative solution is attaching -static flag in gcc input arguments. This flag makes gcc integrate C runtime library into final executable file. The disadvantage is bigger file size and redundant C runtime library scattered in different executable files. Hence, I implemented a Makefile which lets user select the -static flag. I also attached the make command into build-modules.sh to automate the build flow for userspace apps.
StevenChen1997
force-pushed
the
qemu_userapp_makefile
branch
from
September 24, 2026 20:32
a091b90 to
49cec0e
Compare
Author
|
Sorry for late update, commits have already squashed. |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Observation during testing
Root cause
/lib64/ld-linux-x86-64.so.2) deployed.Proposed solution in this PR
An alternative solution is attaching -static flag in gcc input arguments. This flag makes gcc staticly link and load C runtime libraries into final executable file. The disadvantage is bigger executable file size and redundant C runtime library scattered in different executable files. (Same code but loaded into multiple processes)
In QEMU guest shell, we will get the following execution result:
About the Makefile
/lib64/ld-linux-x86-64.so.2or alternative C dynamic linker/loader, you can usemakedirectly for compiling.Trade off and further discussion
Summary by cubic
Adds a Makefile for building user-space apps with optional static linking so
cat_nonblockanduserspace_ioctlcan run on the QEMU guest shell, which has no C dynamic linker. The build tracks header deps and rebuilds whenQEMU_ENVchanges.examples/other/Makefile: compiles all.cfiles, adds-staticwithQEMU_ENV=1, auto-generates.ddependency files, and uses a.qemu-envstamp to detect environment changes.devtools/build-modules.shto compile user apps viamake -C "$EXAMPLES_DIR/other" QEMU_ENV=1and extended.gitignoreforexamples/otherbinaries,.dfiles, and.qemu-env.Written for commit 49cec0e. Summary will update on new commits.