bouffalolab / bl_iot_sdk

BL602/BL702 SDK. Any technical topic, please access the following link.
http://bbs.bouffalolab.com
Apache License 2.0
268 stars 172 forks source link

在不修改bl_iot_sdk内代码的情况下,如何修改gcc编译器选项? #85

Open FlyyingPiggy2020 opened 3 weeks ago

FlyyingPiggy2020 commented 3 weeks ago

image

    -Wl,--whole-archive \
    $(COMPONENT_LDFLAGS) \
    -Wl,--no-whole-archive \

我想增加如下的编译选项,除了直接在bl_iot_sdk内修改外,请问有办法改LDFLAGS吗?

FlyyingPiggy2020 commented 3 weeks ago

把makefile看完了。。 需要在对应组件下的bouffalo.mk文件中添加 COMPONENT_ADD_LDFLAGS_HEADCOMPONENT_ADD_LDFLAGS_TAIL

COMPONENT_ADD_LDFLAGS_HEAD += -Wl,--whole-archive
COMPONENT_ADD_LDFLAGS_TAIL += -Wl,--no-whole-archive

这两个选项在构建component_project_vars.mk时候会放到 COMPONENT_LDFLAGS 两端: (看COMPONENT_LDFLAGS那一行)

component_project_vars.mk::
    $(details) "Building component project variables list $(abspath $@)"
    @echo '# Automatically generated build file. Do not edit.' > $@
    @echo 'COMPONENT_INCLUDES += $(call lib_MakeVariablePath,$(abspath $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_INCLUDEDIRS))))' >> $@
    @echo 'COMPONENT_LDFLAGS += $(COMPONENT_ADD_LDFLAGS_HEAD) $(call lib_MakeVariablePath, $(COMPONENT_ADD_LDFLAGS)) $(COMPONENT_ADD_LDFLAGS_TAIL)' >> $@
    @echo 'COMPONENT_LINKER_DEPS += $(call lib_MakeVariablePath,$(call resolvepath,$(COMPONENT_ADD_LINKER_DEPS),$(COMPONENT_PATH)))' >> $@
    @echo 'component-$(COMPONENT_NAME)-build: $(addprefix component-,$(addsuffix -build,$(COMPONENT_DEPENDS)))' >> $@