Skip to content

makefiles/cflags.inc.mk: Use a template for CFLAGS testing#9358

Merged
miri64 merged 3 commits intoRIOT-OS:masterfrom
jnohlgard:pr/cflags-cleanup
Jul 18, 2018
Merged

makefiles/cflags.inc.mk: Use a template for CFLAGS testing#9358
miri64 merged 3 commits intoRIOT-OS:masterfrom
jnohlgard:pr/cflags-cleanup

Conversation

@jnohlgard
Copy link
Copy Markdown
Member

@jnohlgard jnohlgard commented Jun 14, 2018

Contribution description

Using a makefile template reduces the code duplication in cflags.inc.mk

Issues/PRs references

depends on #9357

@jnohlgard jnohlgard 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 labels Jun 14, 2018
@jnohlgard jnohlgard added this to the Release 2018.07 milestone Jun 14, 2018
@jnohlgard jnohlgard requested a review from cladmi June 14, 2018 21:55
@jnohlgard jnohlgard added the State: waiting for other PR State: The PR requires another PR to be merged first label Jun 14, 2018
@jnohlgard jnohlgard force-pushed the pr/cflags-cleanup branch from ffc0a02 to ebffd54 Compare June 26, 2018 10:59
@kYc0o
Copy link
Copy Markdown
Contributor

kYc0o commented Jun 26, 2018

#9357 was merged. Please rebase.

@kYc0o kYc0o removed the State: waiting for other PR State: The PR requires another PR to be merged first label Jun 26, 2018
@jnohlgard jnohlgard force-pushed the pr/cflags-cleanup branch from ebffd54 to 0b2fbc6 Compare June 26, 2018 20:02
@jnohlgard
Copy link
Copy Markdown
Member Author

rebased

cladmi
cladmi previously requested changes Jun 28, 2018
Copy link
Copy Markdown
Contributor

@cladmi cladmi left a comment

Choose a reason for hiding this comment

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

As requested inline, I would just the commit split in two and some other tester on mac.


I tested on Linux/gcc with wsn430-v1_3b, iotlab-m3, arduino-mega2560, pic32-wifire and it worked.

-fdiagnostics-color is not added for wsn320-v1_3b for both master and this PR.

I also tried to add some new gcc7 warning (-Wduplicated-branches) to the foreach line and they are correctly only added for gcc7 compilers.

I used this diff for testing:

diff --git a/makefiles/cflags.inc.mk b/makefiles/cflags.inc.mk
index edd578b..94d6769 100644
--- a/makefiles/cflags.inc.mk
+++ b/makefiles/cflags.inc.mk
@@ -25,6 +25,8 @@ ifeq ($(shell $(CC) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null
   endif
 endif
 
+OLD_CFLAGS := $(CFLAGS)
+
 # Template for testing a compiler flag and adding it to CFLAGS (errors usually
 # happens when using older toolchains which do not support the given flags)
 define cflags_test_and_add
@@ -43,6 +45,8 @@ endif
 # Worse yet they hide errors by accepting wildcard argument types.
 $(foreach flag,-Wstrict-prototypes -Wold-style-definition,$(eval $(call cflags_test_and_add,$(flag))))
 
+$(info DIFF: $(filter-out $(OLD_CFLAGS),$(CFLAGS)))
+
 # Unwanted flags for c++
 CXXUWFLAGS += -std=%
 CXXUWFLAGS += -Wstrict-prototypes -Wold-style-definition

Can someone test on mac/llvm ? @kYc0o ?

ifeq ($(shell $(CC) -Wstrict-prototypes -Werror=strict-prototypes -Wold-style-definition -Werror=old-style-definition -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
# duplicated parameters don't hurt
CFLAGS += -Wstrict-prototypes -Wold-style-definition
CXXUWFLAGS += -Wstrict-prototypes -Wold-style-definition
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just for clarity, I would prefer moving the CXXUWFLAGS and removing the useless WERROR case to a separate "cleanup" commit.

@kYc0o
Copy link
Copy Markdown
Contributor

kYc0o commented Jun 28, 2018

Can someone test on mac/llvm ? @kYc0o ?

Works correctly.

@cladmi
Copy link
Copy Markdown
Contributor

cladmi commented Jul 5, 2018

I can do the split and push it here if you want.

Joakim Nohlgård added 3 commits July 10, 2018 16:47
WERROR already sets -Werror so this is not necessary.
The excluded patterns can always be defined as they only set `CFLAGS` that
should not be passed to `CXX`.

This prepares for replacing the cflags support detection by a function.
@cladmi cladmi force-pushed the pr/cflags-cleanup branch from 0b2fbc6 to 843cec5 Compare July 10, 2018 15:00
@cladmi cladmi dismissed their stale review July 10, 2018 15:00

I splitted the commit

@cladmi
Copy link
Copy Markdown
Contributor

cladmi commented Jul 10, 2018

I reviewed and tested the changes but I also contributed by splitting the commits so I cannot ACK.

Can someone else ACK the changes ?

@jnohlgard
Copy link
Copy Markdown
Member Author

Thanks @cladmi

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 18, 2018

Tested with both gcc and clang on Ubuntu 16.04.4 and Ubuntu 18.04 (riotdocker).

Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

ACK

@miri64 miri64 merged commit 9f93745 into RIOT-OS:master Jul 18, 2018
@cladmi
Copy link
Copy Markdown
Contributor

cladmi commented Jul 18, 2018

Thanks

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants