Add Makefile for executing user space apps on QEMU guest shell - #384
Open
StevenChen1997 wants to merge 5 commits into
Open
Add Makefile for executing user space apps on QEMU guest shell#384StevenChen1997 wants to merge 5 commits into
StevenChen1997 wants to merge 5 commits into
Conversation
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.
Based on review comments from cubic-dev-ai, this commit includes some enhancement on Makefile and build-modules.sh. For Makefile: 1. Enhance variable assignment for CC and QEMU_ENV 2. Add QEMU_ENV into dependency and force check if QEMU_ENV is changed when building user applications 3. Automate header dependency tracing for each target 4. Add virtual targets into .PHONY For build-modules.sh: 1. To avoid changing working directory of environment which runs build-modules.sh, we use make -C to automate working directory switching.
Add output files, environment variable monitoring files, and dependency files into .gitignore
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
Apply suggestion by cubic-dev-ci to avoid unexpected file ignored
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
Add a Makefile to build user-space apps with optional static linking and wire it into the build so
cat_nonblockanduserspace_ioctlrun on the QEMU guest shell without a dynamic linker. Tracks header deps and rebuilds whenQEMU_ENVchanges.examples/other/Makefile: builds all.c; adds-staticwhenQEMU_ENV=1; auto-generates.d; writes.qemu-envto detect env changes.devtools/build-modules.sh: usesmake -Cand builds withQEMU_ENV=1; tightened.gitignoretoexamples/otherfor binaries,.d, and.qemu-env.Written for commit a091b90. Summary will update on new commits.