RT-Thread / RT-Thread/rt-thread

building: DefineGroup not support LIBRARY with LOCAL FLAGS

Open
#4,417 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C
Stars
12.2k
Forks
5.4k
Avg merge
4d 12h
Merged PRs (30d)
40

Description

Description:

when use LIBRARY in DefineGroup with LOCAL FLAGS in SConscript, like:

group = DefineGroup('tensorflow-lite-for-mcu', src, depend = ['USING_TENSORFLOWLITEMICRO'], CPPPATH = CPPPATH, LOCAL_CPPDEFINES = CPPDEFINES, LIBRARY = True)

it will cause two actions:

scons: *** Two environments with different actions were specified for the same target: /Users/libao/Projects/myrtt/xuos-intelligence/framework/tensorflow-lite/tensorflow-lite-for-mcu/source/tensorflow/lite/micro/all_ops_resolver.o
(action 1: arm-none-eabi-g++ -o all_ops_resolver.o -c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -std=c++11 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -DHAVE_CCONFIG_H -DSTM32F407xx -D__RTTHREAD__ -DRT_USING_NEWLIB -DUSE_HAL_DRIVER all_ops_resolver.cc)
(action 2: arm-none-eabi-g++ -o all_ops_resolver.o -c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -std=c++11 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -DHAVE_CCONFIG_H -DSTM32F407xx -D__RTTHREAD__ -DRT_USING_NEWLIB -DUSE_HAL_DRIVER -DCMSIS_NN all_ops_resolver.cc)
Analyse

in tools/building.py, DefineGroup return Env.Library to objs and library source files will not be removed from objs. and then in DoBuilding, when call local_group, library source files action conflict with default Environment.

Maybe need to set a new Environment for Library.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect tools/building.py, especially DefineGroup and DoBuilding, starting with how LIBRARY sources remain in objs and are passed to local_group. Reproduce the SConscript example with LIBRARY=True and LOCAL_CPPDEFINES, then verify that the library sources produce one consistent action while retaining their local flags.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
build-system, embedded-iot, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.