make: use -isystem for CPU vendor header includes#7993
make: use -isystem for CPU vendor header includes#7993smlng wants to merge 2 commits intoRIOT-OS:masterfrom
Conversation
66ed8b7 to
3e1f95c
Compare
|
Please wait with this PR until #7882 is merged. |
3e1f95c to
b48faee
Compare
cpu/cc2538/include/cpu_conf.h
Outdated
|
|
||
| #include "cpu_conf_common.h" | ||
| /* disable -Wpedantic for vendor header */ | ||
| #pragma GCC diagnostic push |
There was a problem hiding this comment.
hm .. I remember that we wanted to stay clear of pragmas as they hurt portability. Isn't it possible to disable the -Wpedantic flag via the Makefile? The Makefile solution would be a little more cumbersome, but at least our source code wouldn't contain commands / hints to the compiler.
There was a problem hiding this comment.
Compiler flags on the command line will not work for disabling the flag for only one header, not the entire compilation unit
|
rebased after #7882 merged, ready to go from my side. @cgundogan as @gebart pointed out, won't work need pragma here - besides we do use pragma in RIOT where ever necessary. |
cgundogan
left a comment
There was a problem hiding this comment.
IMO a more appropriate solution is to use -isystem instead of -I to specify the include paths for vendor files. The way I understand isystem, it ignores warnings and is very much suitable to be used for third-party vendor headers. Could you give this a try?
b48faee to
92326a6
Compare
|
@cgundogan nice idea, wasn't aware of that plus seems to work! |
|
@cgundogan -isystem is for system headers such as libc and compiler provided headers. Besides, if you wanted to use that you would make the whole CPU include dir a system include, because there are no -I for the vendor directories themselves. |
|
@gebart, I replaced the |
Hm from the gcc docs:
In interpret this as a good fit of |
|
Okay, I see your point with the isystem, but still we are using the path prefix vendor/x.h to see clearly show in the source where we are using vendor supplied headers, I don't think we should change that. |
|
Ideally there shouldn't be any comment here. But just in case: this is a warning for that ;-). |
|
Worked :-) |
|
@gebart by using If we agree to use |
|
I like the idea of the If it is made global to RIOT, I think it would be good to add a new variable for system include path, and populate CFLAGS from the main |
|
@cladmi I take this as a +1 for the proposed idea above. Will adapt this PR in a fixup commit here for review. |
92326a6 to
205f00c
Compare
Makefile.include
Outdated
| INCLUDES += -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/include | ||
| INCLUDES += -I$(RIOTCPU)/$(CPU)/include | ||
| CPUVENDOR ?= $(RIOTCPU)/$(CPU)/include/vendor | ||
| ifneq (0,$(shell test -d $(CPUVENDOR)/; echo $$?)) |
There was a problem hiding this comment.
Can you use make's wildcard function here?
There was a problem hiding this comment.
mhm sure, if you give a hint what and how ... thx!
There was a problem hiding this comment.
There was a problem hiding this comment.
shelling out is always more expensive than using make's natives
There was a problem hiding this comment.
to be honest: I simply copied from L169:
ifneq (0,$(shell test -d $(RIOTBOARD)/$(BOARD); echo $$?))
205f00c to
f3863c7
Compare
|
@kaspar030 and @cgundogan adapted to proposed solution, thanks for the hint! |
|
@cgundogan happy, can I squash? |
cgundogan
left a comment
There was a problem hiding this comment.
Looks much better now (: Untested ACK from my side. Please squash!
8b7afe9 to
f3e920e
Compare
|
rebased and squashed |
|
@haukepetersen you are the one who introduced the vendor include prefix, I think it makes sense if you add your comments to this PR |
|
@gebart and/or @haukepetersen can you elaborate, I'm out of context right now? |
|
Sure: (big) +1 for adding the vendor headers to the system includes. But I think this PR is immature and does not go all the way. I have mainly two concerns:
So if we go with this change, let's do it right! |
|
for your first point: I had it that way first (i.e., in For the second: I tend to agree as well, but was hesitant to introduce another subdirectory for vendor headers, which are still includes in a way. So you would suggest to have directory structure like: |
|
@kYc0o sorry for the short message. I was referring to an earlier PR (#6700) by @haukepetersen where we moved all vendor headers to the vendor dir to avoid name clashes between vendor files and our own. |
I don't agree, I think it makes it a lot easier on the port developers to have the central makefile assume at least one CPU specific include directory. Any port which needs more than the one default include path can set additional paths in its Makefile.include, but it makes future refactoring and maintenance easier to have the default set at only one location. I propose that the includes still have the vendor/ prefix, even with -isystem, to make them stand out a little extra against the other system libc/compiler headers such as math.h, stdio.h, inttypes.h etc. ( |
|
I still disagree on the default inclusion, but I won't block this. So if you guys agree that this is best, leave it... Regarding the include path: I agree with @gebart, that keeping the This would lead to a clear separation of vendor and RIOT specific headers, would simplify the exclusion of these headers (e.g. in static tests etc), and it would also simplify/solve the issue of the default include path as discussed above :-) One more general question that just came to my mind: does 'moving' the vendor headers to the system includes have any implications at the |
yes, but it also likely means we need to have an unnecessarily complicated nested directory structure just to achieve that. IMHO if we stick with a certain order for document and impose that rule/order when reviewing, would be fine too. I know there might be side-cases where headers must be included in a certain order - but no rule without exception, I guess.
big NO, please don't - this basically means to duplicate (or even extend) the current directory structure for nearly all CPUs (or vendors) we have in another directory. I really favour the current approach of heaving vendor headers with their respective CPU, that is also as close as possible to it directory-wise, like for
but at the costs describe above, btw. its already dead simple: just exclude any file within some (sub) directory of |
|
also note: typically vendor headers are included by |
|
I agree with @smlng, don't move the headers to a single dir, that would make it harder to find the files and breaks the containment for CPU specific files. However, I do like the idea of changing the vendor prefix to the actual vendor name, it makes it even more obvious what each header inclusion is for. |
I completely disagree. The more I think about it, the more I even start to like this idea.
I don't see the costs. If it helps the discussion, I could open a showcase branch so we get a practical comparison going.
Completely agreed. But all directions in the current discussions are equal in this regard...
This I have my trouble with: if we can have ways to enforce something that are equally simple to implement than the rule based variant, we should always choose enforcing variant... We all know how bad reviews can be on things that are not enforced... |
but then we could go for my suggested directory structure above just adding: and then use A good compromise, at least to me. |
|
Which vendor headers actually cause problems? To me it seems they're not that many (I only found the mips headers). We could just pragma their include sites. Please don't rearrange the directory structure just for "-pedantic". And please don't put "vendor/stmd32foobar.h" on the same level as |
|
Forget everything I stated above. After talking about the more general motivation of this PR offline with people, I come to the same conclusion as @kaspar030 above and I say that we don't add the vendor headers to the system headers in the first place. Excluding the (as it seems few) vendor headers that are actually causing problems with |
|
Looking at the current code base on master, we already use a lot of pragmas for similar purposes. I wasn't aware of that and AFAIR, our intentions were always to reduce the use of pragmas whereever possible. If that's not our philosophy, then I do not understand why we're not using |
AFAIK (and I'm well aware that I could be totally wrong there) |
Why is CPU code not required to be portable? Still multiple compilers can be used to compile for a single cpu. |
Simple:
This is not (always) true: |
|
how do we want to proceed here, I still like the idea of including the vendor headers with |
I see a style change with no objective benefits and at least potential for confusion / trouble. |
|
No consensus here, thus I'll close. Feel free to re-open. |
this PR disables pedantic checks for certain vendor headers, required by #7919