diff --git a/.gitignore b/.gitignore index 421153a..a85d4a6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,8 @@ gitignore* # Python trash. *.pyc __pycache__ + +# Accidents. +/m5out +*.o +*.out diff --git a/README.adoc b/README.adoc index 191d93e..eb2feb6 100644 --- a/README.adoc +++ b/README.adoc @@ -10657,6 +10657,47 @@ git -C data/gem5/some-branch checkout some-branch-v2 `--gem5-worktree` is only required if you have multiple gem5 checkouts, e.g. it would not be required for multiple builds of the same tree, e.g. a <> and a non-debug one. +===== gem5 private source trees + +Suppose that you are working on a private fork of gem5, but you want to use this repository to develop it as well. + +Simply adding your private repository as a remote to `submodules/gem5` is dangerous, as you might forget and push your private work by mistake one day. + +Even removing remotes is not safe enough, since `git submodule update` and other submodule commands can restore the old public remote. + +Instead, we provide the following safer process. + +First do a separate private clone of you private repository: + +.... +git clone https://my.private.repo.com/my-fork/gem5.git gem5-internal +gem5_internal="$(pwd)/gem5-internal" +.... + +Next, when you want to build with this repository, use the `--gem5-src` argument to point this repository to the private source code: + +.... +cd linux-kernel-module-cheat +./build-gem5 \ + --gem5-build-id p/lkmc/master \ + --gem5-src "$gem5_internal" \ + --gem5-worktree p/lkmc/master \ +; +./run-gem5 + --gem5-build-id p/lkmc/master \ + --gem5-src "$gem5_internal" \ + --gem5-worktree p/lkmc/master \ +; +.... + +`p/lkmc/` is not mandatory but it provides a sane default: + +* `p` stands for `private`, and will separate the private from public builds +* `lkmc` is added to prevent name conflicts with other work-trees of the private repository +* `master`, finally, reflects that the worktree is at the `master` state of private repository + +This setup only creates gitignored worktrees of the private repository inside this repository, which is pretty safe, while still allowing fully use our infrastructure as usual. + ===== gem5 debug build The `gem5.debug` has optimizations turned off unlike the default `gem5.opt`, and provides a much better <>: diff --git a/common.py b/common.py index 2c20e18..44ad956 100644 --- a/common.py +++ b/common.py @@ -31,7 +31,6 @@ kernel_modules_src_dir = os.path.join(this.packages_dir, 'kernel_modules') submodules_dir = os.path.join(root_dir, 'submodules') buildroot_src_dir = os.path.join(submodules_dir, 'buildroot') crosstool_ng_src_dir = os.path.join(submodules_dir, 'crosstool-ng') -gem5_default_src_dir = os.path.join(submodules_dir, 'gem5') linux_src_dir = os.path.join(submodules_dir, 'linux') extract_vmlinux = os.path.join(linux_src_dir, 'scripts', 'extract-vmlinux') qemu_src_dir = os.path.join(submodules_dir, 'qemu') @@ -126,6 +125,10 @@ See the documentation for other values known to work. '-M', '--gem5-build-id', default=default_build_id, help='gem5 build ID. Allows you to keep multiple separate gem5 builds. Default: %(default)s' ) + parser.add_argument( + '--gem5-src', + help='If given, use the gem5 directory exactly as submodules/gem5 is would normally used.' + ) parser.add_argument( '-N', '--gem5-worktree', help='''\ @@ -512,6 +515,10 @@ def setup(parser): this.crosstool_ng_executable = os.path.join(this.crosstool_ng_util_dir, 'ct-ng') this.crosstool_ng_build_dir = os.path.join(this.crosstool_ng_buildid_dir, 'build') this.crosstool_ng_download_dir = os.path.join(this.crosstool_ng_out_dir, 'download') + if (args.gem5_src): + this.gem5_default_src_dir = args.gem5_src + else: + this.gem5_default_src_dir = os.path.join(submodules_dir, 'gem5') if args.gem5_worktree is not None: this.gem5_src_dir = os.path.join(this.gem5_non_default_src_root_dir, args.gem5_worktree) else: