Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error: static_assert expression is not an integral constant expression #1452

Closed
nathanchance opened this issue Sep 9, 2021 · 12 comments
Labels
[BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.15 This bug was fixed in Linux 5.15

Comments

@nathanchance
Copy link
Member

nathanchance commented Sep 9, 2021

After https://git.kernel.org/linus/84f969e1c48ed3825986e91a0786e363d57f69d1, which is now in mainline:

$ make -skj"$(nproc)" LLVM=1 allmodconfig drivers/infiniband/hw/qib/qib_sysfs.o
drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error: static_assert expression is not an integral constant expression
QIB_DIAGC_ATTR(rc_resends);
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/infiniband/hw/qib/qib_sysfs.c:406:16: note: expanded from macro 'QIB_DIAGC_ATTR'
        static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL);    \
        ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
                                 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                       ^~~~
drivers/infiniband/hw/qib/qib_sysfs.c:413:1: note: cannot access field of null pointer
drivers/infiniband/hw/qib/qib_sysfs.c:406:43: note: expanded from macro 'QIB_DIAGC_ATTR'
        static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL);    \
                                                 ^
...

GCC back to at least 7.5.0 has no issues with this construct.

@nathanchance nathanchance added [BUG] Untriaged Something isn't working [BUG] linux A bug that should be fixed in the mainline kernel. labels Sep 9, 2021
@nathanchance
Copy link
Member Author

nathanchance commented Sep 9, 2021

I am guessing the note: cannot access field of null pointer is the crux of the matter.

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Sep 9, 2021

Should this be changed to BUILD_BUG_ON instead of using static_assert?

@nathanchance
Copy link
Member Author

nathanchance commented Sep 9, 2021

I'll test it to see if it fixes it.

@nathanchance
Copy link
Member Author

nathanchance commented Sep 9, 2021

Ah, BUILD_BUG_ON won't work as these structures are not declared within a function but globally within the file so the do { ... } while (0) from __compiletime_assert does not work.

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Sep 10, 2021

I don't understand the check; they're testing the offset of a member isn't 0? Sounds like they should be using offset of, not pointer comparisons.

@nathanchance
Copy link
Member Author

nathanchance commented Sep 10, 2021

They do use offsetof. Are they making sure the member of the structure is the size of a u64 *?

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Sep 13, 2021

@dileks
Copy link

dileks commented Sep 15, 2021

I can confirm this issue with Linux v5.15-rc1+ and LLVM v13.0.0-rc3.
Happily, it is the only error breaking my 1st build.

@nathanchance
Copy link
Member Author

nathanchance commented Sep 15, 2021

@nathanchance nathanchance added [PATCH] Submitted A patch has been submitted for review and removed [BUG] Untriaged Something isn't working labels Sep 15, 2021
@dileks
Copy link

dileks commented Sep 15, 2021

Thanks.
That is what I applied as a diff and was able to continue building.

$ cat /proc/version 
Linux version 5.15.0-rc1-1-amd64-clang13-lto (sedat.dilek@gmail.com@iniza) (dileks clang version 13.0.0 (https://github.com/llvm/llvm-project.git 1f27fe6128769f00197925c3b8f6abb9d0e5cd2e), LLD 13.0.0 (https://github.com/llvm/llvm-project.git 1f27fe6128769f00197925c3b8f6abb9d0e5cd2e)) #1~bookworm+dileks1 SMP 2021-09-15

@dileks
Copy link

dileks commented Sep 15, 2021

Patch is in rdma Git tree.

[1] https://git.kernel.org/rdma/rdma/c/1b789bd4dbd48a92f5427d9c37a72a8f6ca17754

Update 2021-09-23: Commit-ID changed in rdma.git#for-rc.

[1] https://git.kernel.org/rdma/rdma/c/3110b942d36b961858664486d72f815d78c956c3

@dileks dileks added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels Sep 17, 2021
hisenyiu2015 pushed a commit to hisenyiu2015/msm-4.14 that referenced this issue Sep 23, 2021
Clang can't seem to build this driver in the 5.15-rc1 release, so
disable it until either the kernel code is changed, or the compiler is
fixed up.

Full discussion upstream can be found at:
	https://lore.kernel.org/r/202109112002.NZceUwiC-lkp@intel.com

and at:
	ClangBuiltLinux/linux#1452

Fixes: 6880fa6 ("Linux 5.15-rc1")
Cc: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I5d55f40ce5b783d1212e6c649eb6c7799c6be100
@dileks
Copy link

dileks commented Oct 1, 2021

@dileks dileks added [FIXED][LINUX] 5.15 This bug was fixed in Linux 5.15 and removed [PATCH] Accepted A submitted patch has been accepted upstream labels Oct 1, 2021
@dileks dileks closed this as completed Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.15 This bug was fixed in Linux 5.15
Projects
None yet
Development

No branches or pull requests

3 participants