Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix liblvgl with monolith #735

Open
wants to merge 4 commits into
base: develop-pros-4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ CREATE_TEMPLATE_ARGS+=--user "src/main.{cpp,c,cc}" --user "include/main.{hpp,h,h
CREATE_TEMPLATE_ARGS+=--target v5
CREATE_TEMPLATE_ARGS+=--output bin/monolith.bin --cold_output bin/cold.package.bin --hot_output bin/hot.package.bin --cold_addr 58720256 --hot_addr 125829120

template:: patch_sdk_headers clean-template library
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure this was a mistake? It has a semantically different meaning now.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeh, its just a kernel thing. If it overload it will duplicate a libpros.a in the project root directory.

Copy link
Contributor

@djava djava Dec 28, 2024

Choose a reason for hiding this comment

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

So the template rule in common.mk is no longer used then, since it's being overridden in user project Makefile? Can it be removed, or is it used to build the kernel? If so, should it be in the kernel's Makefile?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's only being used by users. There's no template rule in the distributed makefile, only in common.mk.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so the kernel build uses this template rule here, and user project builds use the one in common.mk? Then shouldn't the one in common.mk be moved to template-Makefile? If it's not used by both, it shouldnt be in common.mk, right?

template: patch_sdk_headers clean-template library
$(VV)mkdir -p $(TEMPLATE_DIR)
@echo "Moving template files to $(TEMPLATE_DIR)"
$Dif [ $(shell uname -s) == "Darwin" ]; then \
Expand Down
15 changes: 13 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,18 @@ LIBRARIES+=$(wildcard $(FWDIR)/*.a)
EXCLUDE_COLD_LIBRARIES+=$(FWDIR)/libc.a $(FWDIR)/libm.a
COLD_LIBRARIES=$(filter-out $(EXCLUDE_COLD_LIBRARIES), $(LIBRARIES))
wlprefix=-Wl,$(subst $(SPACE),$(COMMA),$1)

ifneq (,$(wildcard ./firmware/liblvgl.a))
LVGL_LIB_FLAGS=--whole-archive ./firmware/liblvgl.a --no-whole-archive
FILTERED_LIBRARIES=$(filter-out ./firmware/liblvgl.a, $(LIBRARIES))
else
LVGL_LIB_FLAGS=
FILTERED_LIBRARIES=$(LIBRARIES)
endif

LNK_FLAGS=--gc-sections --start-group $(strip $(LIBRARIES)) -lgcc -lstdc++ --end-group -T$(FWDIR)/v5-common.ld --no-warn-rwx-segments
LNK_FLAGS_MONOLITH=--gc-sections --start-group $(strip $(LVGL_LIB_FLAGS) $(FILTERED_LIBRARIES)) -lgcc -lstdc++ --end-group -T$(FWDIR)/v5-common.ld --no-warn-rwx-segments
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we figure out a better way to do this than duplication? Also should LNK_FLAGS be LNK_FLAGS_HOTCOLD or something?



ASMFLAGS=$(MFLAGS) $(WARNFLAGS)
CFLAGS=$(MFLAGS) $(CPPFLAGS) $(WARNFLAGS) $(GCCFLAGS) --std=$(C_STANDARD)
Expand Down Expand Up @@ -213,7 +224,7 @@ $(LIBAR): $(call GETALLOBJ,$(EXCLUDE_SRC_FROM_LIB)) $(EXTRA_LIB_DEPS)
library: $(LIBAR)

.PHONY: template
template:: clean-template $(LIBAR)
template: clean-template $(LIBAR)
$Dpros c create-template . $(LIBNAME) $(VERSION) $(foreach file,$(TEMPLATE_FILES) $(LIBAR),--system "$(file)") --target v5 $(CREATE_TEMPLATE_FLAGS)
endif

Expand All @@ -230,7 +241,7 @@ $(MONOLITH_BIN): $(MONOLITH_ELF) $(BINDIR)

$(MONOLITH_ELF): $(ELF_DEPS) $(LIBRARIES)
$(call _pros_ld_timestamp)
$(call test_output_2,Linking project with $(ARCHIVE_TEXT_LIST) ,$(LD) $(LDFLAGS) $(ELF_DEPS) $(LDTIMEOBJ) $(call wlprefix,-T$(FWDIR)/v5.ld $(LNK_FLAGS)) -o $@,$(OK_STRING))
$(call test_output_2,Linking project with $(ARCHIVE_TEXT_LIST) ,$(LD) $(LDFLAGS) $(ELF_DEPS) $(LDTIMEOBJ) $(call wlprefix,-T$(FWDIR)/v5.ld $(LNK_FLAGS_MONOLITH)) -o $@,$(OK_STRING))
@echo Section sizes:
-$(VV)$(SIZETOOL) $(SIZEFLAGS) $@ $(SIZES_SED) $(SIZES_NUMFMT)

Expand Down