Skip to content

Commit

Permalink
Add cross-compile argument
Browse files Browse the repository at this point in the history
When cross-compiling on SUSE distributions vng fails to find gcc, since
it's named '<arch>-suse-linux-gcc', instead of the hardcoded
'<arch>-linux-gnu-gcc'.

This commit provides a '--cross-compile' argument that will override the
hardcoded prefix if used, otherwise it should do nothing.

Signed-off-by: Fredrik Lönnegren <[email protected]>
  • Loading branch information
frelon committed Jul 16, 2024
1 parent 3bb0256 commit e12dfb2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
17 changes: 14 additions & 3 deletions virtme/commands/configkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ def make_parser():
help="Target architecture",
)

parser.add_argument(
"--cross-compile",
action="store",
metavar="CROSS_COMPILE_PREFIX",
help="Cross-compile compiler prefix",
)

parser.add_argument(
"--custom",
action="append",
Expand Down Expand Up @@ -313,9 +320,13 @@ def do_it():
linuxname = shlex.quote(arch.linuxname)
archargs = [f"ARCH={linuxname}"]

if shutil.which(f"{arch.gccname}-linux-gnu-gcc") and arch.gccname != uname.machine:
gccname = shlex.quote(f"{arch.gccname}-linux-gnu-")
archargs.append(f"CROSS_COMPILE={gccname}")
cross_compile_prefix = f"{arch.gccname}-linux-gnu-"
if args.cross_compile != "":
cross_compile_prefix = args.cross_compile

if shutil.which(f"{cross_compile_prefix}-gcc") and arch.gccname != uname.machine:
gccname = shlex.quote(cross_compile_prefix)
archargs.append(f"CROSS_COMPILE={cross_compile_prefix}")

maketarget: Optional[str]

Expand Down
6 changes: 6 additions & 0 deletions virtme/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ def make_parser() -> argparse.ArgumentParser:
default=uname.machine,
help="Guest architecture",
)
g.add_argument(
"--cross-compile",
action="store",
metavar="CROSS_COMPILE_PREFIX",
help="Cross-compile compiler prefix",
)
g.add_argument(
"--busybox",
action="store",
Expand Down
9 changes: 9 additions & 0 deletions virtme_ng/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ def make_parser():
"(default is host architecture)",
)

parser.add_argument(
"--cross-compile",
action="store",
help="Set cross-compile prefix"
)

parser.add_argument(
"--force",
action="store_true",
Expand Down Expand Up @@ -733,6 +739,9 @@ def make(self, args):
arg_fail(f"unsupported architecture: {arch}")
target = ARCH_MAPPING[arch]["kernel_target"]
cross_compile = ARCH_MAPPING[arch]["cross_compile"]
if args.cross_compile != "":
cross_compile=args.cross_compile

cross_arch = ARCH_MAPPING[arch]["linux_name"]
else:
target = "bzImage"
Expand Down

0 comments on commit e12dfb2

Please sign in to comment.