[Tofino] Replace bf-asm BUG macros with top-level BUG macros. Remove GNU extensions flags. #5188
[Tofino] Replace bf-asm BUG macros with top-level BUG macros. Remove GNU extensions flags. #5188
Conversation
513f8b5 to
1a40489
Compare
|
@ChrisDodd I couldn't find a way to rewrite the EXPAND_COMMA macros safely, so I resorted to VA_OPT. Also @jafingerhut had trouble compiling the BUG macros so I replaced them and added diagnostics. Let me know if you other suggestions or see something incorrect. |
1a40489 to
6a38dd5
Compare
|
@ChrisDodd This code touches a lot of files, but most of the changes are just there to add diagnostics to I am using VA_OPT although we are not quite C++20 yet. Thankfully, this works on all the systems we test on. It's the only way I have been able to get rid of the gnu-extensions and variadic arguments, which cause compilation problems for various compiler distributions. |
|
The compiler BUG macros throw an exception rather than printing a message and then exiting. Do we want a top-level exception handler in |
backends/tofino/bf-asm/target.h
Outdated
| */ | ||
| #define EXPAND(...) __VA_ARGS__ | ||
| #define EXPAND_COMMA(...) __VA_OPT__(, )##__VA_ARGS__ // NOLINT | ||
| #define EXPAND_COMMA_CLOSE(...) __VA_OPT__(, ) ##__VA_ARGS__ __VA_OPT__()) // NOLINT |
There was a problem hiding this comment.
Should the ## be here? In addition, the ) needs to be macro-ized to make paren handling correct. so should be:
#define CLOSE_PAREN )
#define EXPAND_COMMA_CLOSE(...) __VA_OPT__(, ) __VA_ARGS__ __VA_OPT__(CLOSE_PAREN)
There was a problem hiding this comment.
Or maybe it should always have the ), so the second __VA_OPT__ is not needed. Should be
#define EXPAND_COMMA_CLOSE(...) __VA_OPT__(, ) __VA_ARGS__ )
-- that seems to be what the original code was doing
There was a problem hiding this comment.
It is probably ok like this -- __VA_OPT__() is a noop no matter how you look at it, and the spurious ## is probably just ignored, though a strict reading of the spec suggests that having it here is undefined.
Signed-off-by: fruffy <fruffy@nyu.edu>
Signed-off-by: fruffy <fruffy@nyu.edu>
Signed-off-by: fruffy <fruffy@nyu.edu>
Signed-off-by: fruffy <fruffy@nyu.edu>
Signed-off-by: fruffy <fruffy@nyu.edu>
Signed-off-by: fruffy <fruffy@nyu.edu>
3cc40ad to
2da7d00
Compare
Signed-off-by: fruffy <fruffy@nyu.edu>
Signed-off-by: fruffy <fruffy@nyu.edu>
2da7d00 to
103d3c4
Compare
|
@fruffy @ChrisDodd After this PR, I am getting a bunch of errors like this each time I try to locally run Do you have any idea how to resolve this? |
|
Which version of clang-format are you using? Seems to be a problem with the config file. |
|
@fruffy I am using |
|
Let me see whether it can be reproduced with that version.. |
|
I can not reproduce it locally and with CI (#5272). Maybe the CMake script picks up a dated |
|
@fruffy After doing a clean build, |
__VA_OPT__which only emits is argument when there are more variadic args. This seems to compile on all systems, but I need to add some more checks.TODO: Recheck error messages and consider emitting a output that is different from
Compiler Bug?