Skip to content

make: do not locally export compilation variables#12098

Merged
MrKevinWeiss merged 6 commits intoRIOT-OS:masterfrom
cladmi:pr/export/remove_local_export_compilation_variables
Aug 29, 2019
Merged

make: do not locally export compilation variables#12098
MrKevinWeiss merged 6 commits intoRIOT-OS:masterfrom
cladmi:pr/export/remove_local_export_compilation_variables

Conversation

@cladmi
Copy link
Contributor

@cladmi cladmi commented Aug 27, 2019

Contribution description

These are already exported by makefiles/vars.inc.mk.
It is a prerequisite to allow handling compilation without global exports.

This currently does not un-export them from makefiles/toolchain.

Testing procedure

All the removed export are exported in makefiles/vars.inc.mk or not needed in sub-execution.
I newly exported CFLAGS_CPU as it is needed by pkg/openthread.

git diff $(git merge-base HEAD master) | grep '^-' | grep -v -e '--- a/' -e '#' \
   | grep -v -e 'CFLAGS ' -e 'OBJCOPY'  -e CCAS -e ASFLAGS -e INCLUDES -e OFLAGS -e OBJDUMPFLAGS -e CXXEXFLAGS -e CXXUWFLAGS -e CFLAGS_CPU
-export CFLAGS_LINK  = -ffunction-sections -fdata-sections -fno-builtin -fshort-enums
-export CFLAGS_DBG  ?= -ggdb -g3
-export CFLAGS_OPT  ?= -Os
-
-export CFLAGS_LINK  = -ffunction-sections -fdata-sections -fno-builtin -fshort-enums
-export CFLAGS_DBG  ?= -ggdb -g3
-export CFLAGS_OPT  ?= -Os
-        export CFLAGS_FPU ?= -mfloat-abi=soft
-                export CFLAGS_FPU ?= -mfloat-abi=hard -mfpu=fpv5-d16
-                export CFLAGS_FPU ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16
-export CFLAGS_LINK  = -ffunction-sections -fno-builtin -fshort-enums -fdata-sections
-export CFLAGS_DBG   = -g3
-export CFLAGS_OPT   = -Os

And the CFLAGS_ variables are only used by included files:

git grep '$(CFLAGS_.*)'  | grep -v -e 'pkg/openthread/Makefile'  -e 'dist/tools/uhcpd/Makefile'
Makefile.include:       $(Q)'$(RIOTTOOLS)/genconfigheader/genconfigheader.sh' $(CFLAGS_WITH_MACROS) \
boards/common/msba2/Makefile.include:CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
boards/common/msba2/Makefile.include:ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
boards/common/msba2/Makefile.include:export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -nostartfiles
makefiles/arch/atmega.inc.mk:CFLAGS_CPU   = -mmcu=$(CPU) $(CFLAGS_FPU)
makefiles/arch/atmega.inc.mk:CFLAGS    += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
makefiles/arch/atmega.inc.mk:ASFLAGS   += $(CFLAGS_CPU) $(CFLAGS_DBG)
makefiles/arch/atmega.inc.mk:LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -e reset_handler -Wl,--gc-sections
makefiles/arch/cortexm.inc.mk:CFLAGS_CPU   = -mcpu=$(MCPU) -mlittle-endian -mthumb $(CFLAGS_FPU)
makefiles/arch/cortexm.inc.mk:CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
makefiles/arch/cortexm.inc.mk:ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
makefiles/arch/cortexm.inc.mk:export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -nostartfiles
makefiles/arch/mips.inc.mk:CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_OPT) $(CFLAGS_DBG)
makefiles/arch/mips.inc.mk:eASFLAGS += $(CFLAGS_CPU) $(CFLAGS_OPT) $(CFLAGS_DBG)
makefiles/arch/mips.inc.mk:export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT)
makefiles/arch/msp430.inc.mk:CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
makefiles/arch/msp430.inc.mk:ASFLAGS += $(CFLAGS_CPU) --defsym $(CPU_MODEL)=1 $(CFLAGS_DBG)
makefiles/arch/msp430.inc.mk:export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -Wl,--gc-sections -static -lgcc
makefiles/arch/riscv.inc.mk:CFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) $(CFLAGS_LINK)
makefiles/arch/riscv.inc.mk:ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
makefiles/arch/riscv.inc.mk:export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT) -Wl,--gc-sections -static -lgcc
makefiles/eclipse.inc.mk:       $(Q)printf "%s\n" $(CC) $(CFLAGS_WITH_MACROS) $(INCLUDES) | \
makefiles/toolchain/llvm.inc.mk:    $(shell $(PREFIX)gcc $(CFLAGS_CPU) -v -x $1 -E /dev/null 2>&1 | \
makefiles/toolchain/llvm.inc.mk:  ifeq (,$(CFLAGS_CPU))

And there should not be any other changes than these variables and comments except the first two commits changes and the dist/Makefile comment.

git diff --word-diff $(git merge-base HEAD master) | sed 's/\[-export-\]//g' | sed 's/\[-#.*\]//' | grep -e '{' -e '\[-'
[-CFLAGS += $(CFLAGS_BASIC)-]
{+#INCLUDES+} += -Iapplication_include
{+export CFLAGS_CPU            # CPU architecture specific compiler flags+}

Issues/PRs references

Part of removing exporting everything everywhere #10850

@cladmi cladmi force-pushed the pr/export/remove_local_export_compilation_variables branch from 0fa1e9b to 1933b45 Compare August 27, 2019 15:24
@smlng smlng added Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation labels Aug 28, 2019
@smlng
Copy link
Member

smlng commented Aug 28, 2019

Looks good to me, only removing export from variables. Also if Murdock is happy this should be good to go.

@smlng smlng added the Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines label Aug 28, 2019
@cladmi
Copy link
Contributor Author

cladmi commented Aug 28, 2019

@smlng What do you think about the CFLAGS_CPU added documentation? I needed to export the variable but not sure if the description is good. 94badbc

Copy link
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

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

mhm, somehow the usage of CFLAGS_CPU and its addition to CFLAGS is not very consistent. Its mostly used in makefiles/arch/* but also in boards/common/msba2.
Also I don't understand why it needs to be exported, as it is always added to CFLAGS anyway.

@cladmi
Copy link
Contributor Author

cladmi commented Aug 28, 2019

@smlng as I put in the commit: "CFLAGS_CPU is required for 'pkg/openthread'. So declare it as a global compilation variable."

git grep '$(CFLAGS_CPU)' -- pkg/openthread/
pkg/openthread/Makefile:                CPPFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) -D$(CONFIG_FILE)" \
pkg/openthread/Makefile:                CFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) " \
pkg/openthread/Makefile:                CXXFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) -fno-exceptions -fno-rtti " \
pkg/openthread/Makefile:                LDFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) -nostartfiles -specs=nano.specs \

I do not question why this is there, just it is there, so this PR handles exporting the value as I remove the export in the cpu/arch.

@cladmi
Copy link
Contributor Author

cladmi commented Aug 28, 2019

mhm, somehow the usage of CFLAGS_CPU and its addition to CFLAGS is not very consistent. Its mostly used in makefiles/arch/* but also in boards/common/msba2.

This is being changes for msba2 to be done in cpu #11882

Unrelated to this PR though.

@cladmi
Copy link
Contributor Author

cladmi commented Aug 28, 2019

I found some missing 'export INCLUDES' they were not in my original "grep" command.

# the pickit programmer (MPLAB-IPE) wants physical addresses in the hex file!!
export OBJCOPY = objcopy #use system objcopy as toolchain one is broken.
export OFLAGS += \
OBJCOPY = objcopy #use system objcopy as toolchain one is broken.
Copy link
Member

Choose a reason for hiding this comment

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

this also exported in makefiles/toolchain/{llvm,gnu}.inc.mk, don't know if it makes sense to change that here too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I said in the PR description "This currently does not un-export them from makefiles/toolchain."

The reasoning is that I prefer changing the toolchain in its specific PR.
It is not supposed to be different, but as it would change almost each line, I think it deserve a smaller PR to ease review.

@smlng smlng added Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines labels Aug 28, 2019
@smlng
Copy link
Member

smlng commented Aug 28, 2019

apart from OBJCOPY as commented above, I checked changed variables are only exported in vars.inc.mk.

I guess other such as LINKFLAGS need separate careful handling.

@smlng
Copy link
Member

smlng commented Aug 28, 2019

please squash

@cladmi
Copy link
Contributor Author

cladmi commented Aug 29, 2019

I guess other such as LINKFLAGS need separate careful handling.

Yes, LINK, LINKFLAGS and such are use during linking, so supposedly not even required to be exported, but I would like to do a specific package review too for these as LINK is used in dist/tools/cmake/generate-xcompile-toolchain.sh for example (also LFLAGS that is not defined in RIOT).

cladmi added 5 commits August 29, 2019 10:35
CFLAGS_CPU is required for 'pkg/openthread'. So declare it as a global
compilation variable.

The goal is to move the export to `makefiles/vars.inc.mk` and remove the
local exports that could be in boards/cpu/arch.
CFLAGS and INCLUDES are already exported by `makefiles/vars.inc.mk`.
It is a prerequisite to allow handling compilation without global exports.
These are already exported by `makefiles/vars.inc.mk`.
It is a prerequisite to allow handling compilation without global exports.
These are already exported by `makefiles/vars.inc.mk`.
It is a prerequisite to allow handling compilation without global exports.
These are already exported by `makefiles/vars.inc.mk`.
It is a prerequisite to allow handling compilation without global exports.
@cladmi cladmi force-pushed the pr/export/remove_local_export_compilation_variables branch from 71cf9f3 to 1be5b7b Compare August 29, 2019 08:36
Copy link
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

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

re-checked exports only in vars.inc.mk (apart from mentioned exceptions), ACK

@cladmi
Copy link
Contributor Author

cladmi commented Aug 29, 2019

CI is green and it executed as many compilation jobs as nightly "41197"

@MrKevinWeiss MrKevinWeiss merged commit 969e3b3 into RIOT-OS:master Aug 29, 2019
@cladmi
Copy link
Contributor Author

cladmi commented Aug 29, 2019

Thank you for the review. More will be coming :)

@cladmi cladmi deleted the pr/export/remove_local_export_compilation_variables branch August 29, 2019 12:36
@kb2ma kb2ma added this to the Release 2019.10 milestone Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants