Skip to content

Commit

Permalink
Merge pull request torvalds#62 from sched-ext/rusty_offline
Browse files Browse the repository at this point in the history
rusty: Further tweak build system
  • Loading branch information
DaanDeMeyer authored Oct 16, 2023
2 parents bac7dab + 38ad0e8 commit 52911e1
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions tools/sched_ext/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ CFLAGS += -g -O2 -rdynamic -pthread -Wall -Werror $(GENFLAGS) \
-I$(TOOLSINCDIR) -I$(APIDIR)

CARGOFLAGS := --release --target-dir $(OUTPUT_DIR)
ifneq ($(CARGO_OFFLINE),)
CARGOFLAGS += --offline
endif

# Silence some warnings when compiled with clang
ifneq ($(LLVM),)
Expand Down Expand Up @@ -198,13 +201,21 @@ scx_flatcg: scx_flatcg.c scx_flatcg.skel.h $(SCX_COMMON_DEPS)
scx_userland: scx_userland.c scx_userland.skel.h scx_userland.h $(SCX_COMMON_DEPS)
$(call ccsched,$<,$@)

scx_rusty_deps: $(SCX_COMMON_DEPS)
# Separate build target that is available for build systems to use to fetch
# dependencies in a separate step from building. This allows the scheduler
# to be compiled without network access.
#
# If the scx_rusty Make target is invoked without CARGO_OFFLINE=1 (e.g. if
# building locally), then cargo build will download all of the necessary
# dependencies, and scx_rusty_deps can be skipped.
scx_rusty_deps:
cargo fetch --manifest-path=scx_rusty/Cargo.toml

scx_rusty: export RUSTFLAGS = -C link-args=-lzstd -C link-args=-lz -C link-args=-lelf -L $(BPFOBJ_DIR)
scx_rusty: export SCX_RUSTY_CLANG = $(CLANG)
scx_rusty: export SCX_RUSTY_BPF_CFLAGS = $(BPF_CFLAGS)
scx_rusty: $(INCLUDE_DIR)/vmlinux.h scx_rusty_deps
cargo build --manifest-path=$@/Cargo.toml --offline $(CARGOFLAGS)
scx_rusty: $(INCLUDE_DIR)/vmlinux.h $(SCX_COMMON_DEPS)
cargo build --manifest-path=$@/Cargo.toml $(CARGOFLAGS)
$(Q)cp $(OUTPUT_DIR)/release/$@ $(BINDIR)/$@

install: all
Expand Down Expand Up @@ -239,6 +250,24 @@ help:
@echo '/tmp/sched_ext/build.'
@echo ''
@echo ''
@echo 'Rust schedulers:'
@echo ' scx_rusty - Build the scx_rusty load balancing scheduler.'
@echo ' scx_rusty_deps - Download the scx_rusty scheduler cargo dependencies.'
@echo ''
@echo 'For any cargo rust schedulers built with cargo, you can specify'
@echo 'CARGO_OFFLINE=1 to ensure the build portion does not access the'
@echo 'network (e.g. if the scheduler is being packaged).'
@echo ''
@echo 'For such use cases, the build workflow will look something like this:'
@echo ''
@echo ' make scx_rusty_deps'
@echo ' CARGO_OFFLINE=1 make scx_rusty'
@echo ''
@echo 'If network access during build is allowed, you can just make scx_rusty'
@echo 'directly without CARGO_OFFLINE, and dependencies will be downloaded'
@echo 'during the build step.'
@echo ''
@echo ''
@echo 'Installing targets:'
@echo ' install - Compile and install all schedulers to /usr/bin.'
@echo ' You may specify the DESTDIR= environment variable'
Expand Down

0 comments on commit 52911e1

Please sign in to comment.