Skip to content

build: standalone build#121

Merged
AsakuraMizu merged 1 commit intomainfrom
pr/build
Feb 27, 2026
Merged

build: standalone build#121
AsakuraMizu merged 1 commit intomainfrom
pr/build

Conversation

@AsakuraMizu
Copy link
Contributor

For now, ArceOS makefiles are copied over temporarily; the build system will be redesigned later.

Copilot AI review requested due to automatic review settings February 27, 2026 05:49
@AsakuraMizu AsakuraMizu merged commit e3fd959 into main Feb 27, 2026
15 checks passed
@AsakuraMizu AsakuraMizu deleted the pr/build branch February 27, 2026 05:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a standalone Makefile-based build entrypoint under make/ (temporarily copied from ArceOS), and wires the repo root Makefile to delegate build/run/debug targets to it.

Changes:

  • Added a new make/ build system (platform/config/feature resolution, Cargo build orchestration, and QEMU launch args).
  • Added helper scripts/config (strtosz.py, dwarf.sh, defconfig.toml) to support config generation and debug info handling.
  • Updated the top-level Makefile to call into make/ and to place the rootfs disk image under make/disk.img.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
make/utils.mk Adds shared helper macros (command echoing + disk image creation).
make/strtosz.py Adds size-string parsing utility used for config generation.
make/qemu.mk Adds QEMU argument composition and run/debug helpers.
make/platform.mk Resolves platform package/config and derives arch/platform names.
make/features.mk Parses feature lists into ArceOS/module/library/app feature sets.
make/dwarf.sh Adds DWARF section extraction/rewrite helper.
make/deps.mk Adds dependency bootstrapping for required Cargo tools.
make/defconfig.toml Adds default config inputs for axconfig-gen.
make/config.mk Adds config generation logic (defconfig/oldconfig) and MEM/SMP derivation.
make/cargo.mk Adds Cargo build argument composition and cargo invocation helper.
make/build.mk Adds core build flow (build ELF/BIN/UIMG, DWARF handling).
make/Makefile Adds the new standalone build entrypoint and targets.
Makefile Redirects top-level targets to make/ and updates disk image output location.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

endif

qemu_args-$(INPUT) += \
-device virtio-mouse-pci -device virtio-keyboard-pci
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For BUS=mmio, the input devices are still hard-coded to virtio-*-pci. This will make INPUT=y fail on non-PCI virtio setups; consider using the existing $(vdev-suffix) here (and providing the corresponding mmio device names) or gating INPUT to PCI-only.

Suggested change
-device virtio-mouse-pci -device virtio-keyboard-pci
-device virtio-mouse-$(vdev-suffix) -device virtio-keyboard-$(vdev-suffix)

Copilot uses AI. Check for mistakes.

qemu_args-$(INPUT) += \
-device virtio-mouse-pci -device virtio-keyboard-pci

Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For BUS=mmio, the vsock device is hard-coded to vhost-vsock-pci. This will break VSOCK=y when mmio is selected; use a bus-appropriate device (or document/enforce that vsock requires BUS=pci).

Suggested change
ifeq ($(VSOCK), y)
ifneq ($(BUS), pci)
$(error "VSOCK" requires "BUS=pci")
endif
endif

Copilot uses AI. Check for mistakes.
include cargo.mk

ifeq ($(APP_TYPE), c)
include build_c.mk
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build.mk includes build_c.mk when APP_TYPE is c, but make/build_c.mk is not present in this PR/repo. Any C app build will fail at include time; either add build_c.mk (and its targets) or remove/guard the C path until it’s supported.

Suggested change
include build_c.mk
$(error C app builds are not supported in this repository (missing make/build_c.mk))

Copilot uses AI. Check for mistakes.
Comment on lines +201 to +202
clean: clean_c
rm -rf $(APP)/*.bin $(APP)/*.elf $(OUT_CONFIG)
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean depends on clean_c, but no clean_c target/rule is provided in the current make system. This makes make clean fail with “No rule to make target 'clean_c'”; either define clean_c (likely in the missing build_c.mk) or remove it from the prerequisite list.

Copilot uses AI. Check for mistakes.
UIMAGE ?= n

# App options
A ?= examples/helloworld
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default app path is set to examples/helloworld, but that path doesn’t exist in this repository. As a result, running make -C make with defaults fails immediately; consider defaulting APP to an existing crate (e.g. . or kernel) or making APP mandatory with a clearer error message.

Suggested change
A ?= examples/helloworld
A ?= .

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +19
# Tool to parse information about the target package
ifeq ($(shell cargo axplat --version 2>/dev/null),)
$(info Installing cargo-axplat...)
$(shell cargo install cargo-axplat)
endif

# Tool to generate platform configuration files
ifeq ($(shell axconfig-gen --version 2>/dev/null),)
$(info Installing axconfig-gen...)
$(shell cargo install axconfig-gen)
endif

# Cargo binutils
ifeq ($(shell cargo install --list | grep cargo-binutils),)
$(info Installing cargo-binutils...)
$(shell cargo install cargo-binutils)
endif
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Makefile auto-installs build dependencies via cargo install during Makefile evaluation. This has operational downsides (network access during make, non-reproducible tool versions, and it runs even for targets like clean); prefer failing with a clear message and a separate explicit deps/bootstrap target, and use cargo install --locked if you keep installation.

Suggested change
# Tool to parse information about the target package
ifeq ($(shell cargo axplat --version 2>/dev/null),)
$(info Installing cargo-axplat...)
$(shell cargo install cargo-axplat)
endif
# Tool to generate platform configuration files
ifeq ($(shell axconfig-gen --version 2>/dev/null),)
$(info Installing axconfig-gen...)
$(shell cargo install axconfig-gen)
endif
# Cargo binutils
ifeq ($(shell cargo install --list | grep cargo-binutils),)
$(info Installing cargo-binutils...)
$(shell cargo install cargo-binutils)
endif
# Install required build tools explicitly via `make deps`.
# This avoids running `cargo install` during Makefile evaluation.
.PHONY: deps
deps:
@echo "Installing build dependencies (cargo-axplat, axconfig-gen, cargo-binutils)..."
@cargo install --locked cargo-axplat
@cargo install --locked axconfig-gen
@cargo install --locked cargo-binutils

Copilot uses AI. Check for mistakes.
-o "$(OUT_CONFIG)"

ifneq ($(MEM),)
config_args += -w 'plat.phys-memory-size=$(shell ./strtosz.py $(MEM))'
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$(shell ./strtosz.py $(MEM)) runs inside $(shell ...), which ignores the command’s exit status. If parsing fails, Make will keep going with an empty/partial value (and Python will emit a stack trace). Consider validating MEM in Make (and using $(error ...) on failure) or reworking this so a parsing failure reliably stops the build with a concise message.

Suggested change
config_args += -w 'plat.phys-memory-size=$(shell ./strtosz.py $(MEM))'
MEM_PARSED := $(shell ./strtosz.py $(MEM))
ifeq ($(MEM_PARSED),)
$(error "Failed to parse MEM='$(MEM)'. Please specify a valid memory size (e.g. 1G, 512M).")
endif
config_args += -w 'plat.phys-memory-size=$(MEM_PARSED)'

Copilot uses AI. Check for mistakes.
# - `LD_SCRIPT`: Use a custom linker script file.
# * App options:
# - `A` or `APP`: Path to the application
# - `FEATURES`: Features os ArceOS modules to be enabled.
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc comment typo: “Features os ArceOS modules” should be “Features of ArceOS modules”.

Suggested change
# - `FEATURES`: Features os ArceOS modules to be enabled.
# - `FEATURES`: Features of ArceOS modules to be enabled.

Copilot uses AI. Check for mistakes.
endif

ifneq ($(VFIO_PCI),)
qemu_args-y += --device vfio-pci,host=$(VFIO_PCI)
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qemu_args-y uses --device vfio-pci,... but QEMU’s option is -device (single dash). With the current flag, QEMU will fail to parse the arguments when VFIO_PCI is set.

Suggested change
qemu_args-y += --device vfio-pci,host=$(VFIO_PCI)
qemu_args-y += -device vfio-pci,host=$(VFIO_PCI)

Copilot uses AI. Check for mistakes.
endif
PLAT_CONFIG := $(strip $(call resolve_config))
# We don't need to check whether `PLAT_CONFIG` is valid here, as the `PLAT_PACKAGE`
# is a valid pacakage.
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: “pacakage” should be “package”.

Suggested change
# is a valid pacakage.
# is a valid package.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants