Hi, I am wondering if anyone has successfully compiled latest kernel using clang, I have been having problem with it for the last few month, and here is the error that I have:
In file included from drivers/tty/tty_io.c:103: ./include/linux/termios_internal.h:37:5: error: conflicting types for 'user_termio_to_kernel_termios' int user_termio_to_kernel_termios(struct ktermios *, struct termio __user *); ^ ./include/asm-generic/termios.h:20:19: note: previous definition is here static inline int user_termio_to_kernel_termios(struct ktermios *termios,
Sorry, if it has been discussed before, but I don't seem to find the answer.
Chung
On Thu, 16 Feb 2023 17:18:36 -0000 "Chung Chung" ctwo0002@gmail.com wrote:
Hi, I am wondering if anyone has successfully compiled latest kernel using clang, I have been having problem with it for the last few month, and here is the error that I have:
In file included from drivers/tty/tty_io.c:103: ./include/linux/termios_internal.h:37:5: error: conflicting types for 'user_termio_to_kernel_termios' int user_termio_to_kernel_termios(struct ktermios *, struct termio __user *); ^ ./include/asm-generic/termios.h:20:19: note: previous definition is here static inline int user_termio_to_kernel_termios(struct ktermios *termios,
Sorry, if it has been discussed before, but I don't seem to find the answer.
That looks like a bug. I compile the kernel, but it uses the default compiler, and I think that is gcc, so it compiles fine. I would suggest you file a bug against the kernel at https://bugzilla.redhat.com/ There are no current bugs about this in the fedora bugzilla or put a message on the fedora kernel list asking about the problem, with the above information. kernel@lists.fedoraproject.org
I *think* that gcc considers static inline to be a suggestion, while clang is probably considering it required. Might be just the compiler flags. Could be wrong.
On 16 Feb 2023, at 17:18, Chung Chung ctwo0002@gmail.com wrote:
Hi, I am wondering if anyone has successfully compiled latest kernel using clang, I have been having problem with it for the last few month, and here is the error that I have:
In file included from drivers/tty/tty_io.c:103: ./include/linux/termios_internal.h:37:5: error: conflicting types for 'user_termio_to_kernel_termios' int user_termio_to_kernel_termios(struct ktermios *, struct termio __user *); ^ ./include/asm-generic/termios.h:20:19: note: previous definition is here static inline int user_termio_to_kernel_termios(struct ktermios *termios,
Sorry, if it has been discussed before, but I don't seem to find the answer.
I am not sure if clang, llvm, is supported for the linux kernel. Maybe someone else here can comment.
I do know that there are people working on getting it working.
Using gcc will work as that is supported.
Barry
Chung _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
On Thu, Feb 16, 2023 at 1:02 PM Barry barry@barrys-emacs.org wrote:
On 16 Feb 2023, at 17:18, Chung Chung ctwo0002@gmail.com wrote:
Hi, I am wondering if anyone has successfully compiled latest kernel using clang, I have been having problem with it for the last few month, and here is the error that I have:
In file included from drivers/tty/tty_io.c:103: ./include/linux/termios_internal.h:37:5: error: conflicting types for 'user_termio_to_kernel_termios' int user_termio_to_kernel_termios(struct ktermios *, struct termio __user *); ^ ./include/asm-generic/termios.h:20:19: note: previous definition is here static inline int user_termio_to_kernel_termios(struct ktermios *termios,
Sorry, if it has been discussed before, but I don't seem to find the answer.
I am not sure if clang, llvm, is supported for the linux kernel. Maybe someone else here can comment.
I do know that there are people working on getting it working.
Using gcc will work as that is supported.
I think the LLVM devs presented results of compiling the kernel several years ago. I don't recall the link to the talk, though.
I think some of the kernel devs are the biggest problem. Some of the developers feel GCC is the only compiler to support. They rely on GCC-isms, and don't care about things like undefined behavior since it "works for me using GCC." I've even had some of the devs tell me they don't care about the C standard. That was very befuddling to me.
Jeff
On 16 Feb 2023, at 18:42, Jeffrey Walton noloader@gmail.com wrote:
I think some of the kernel devs are the biggest problem. Some of the developers feel GCC is the only compiler to support. They rely on GCC-isms, and don't care about things like undefined behavior since it "works for me using GCC." I've even had some of the devs tell me they don't care about the C standard. That was very befuddling to me.
The problem is that LLVM has different undefined behaviour from GCC. That has to be understood and coded around. You cannot write an OS or device driver based on the C standard's memory model. Linux has its own definition of a memory-model that any compiler must be able to implement to write a kernel.
There are articles on lwn.net that talk to these issues.
Try a search for "lwn bad compiler" to find https://lwn.net/Articles/799218/ and others that talk about why this is not what you are suggesting.
Barry
On Sat, 18 Feb 2023, Barry Scott wrote:
On 16 Feb 2023, at 18:42, Jeffrey Walton noloader@gmail.com wrote:
I think some of the kernel devs are the biggest problem. Some of the developers feel GCC is the only compiler to support. They rely on GCC-isms, and don't care about things like undefined behavior since it "works for me using GCC." I've even had some of the devs tell me they don't care about the C standard. That was very befuddling to me.
The problem is that LLVM has different undefined behaviour from GCC. That has to be
That might be a problem, but it is not the current problem. In the case at hand, clang will not compile the kernel code at all. A slight editing of a header file should cure that particular problem.
understood and coded around. You cannot write an OS or device driver based on the C standard's memory model. Linux has its own definition of a memory-model that any compiler must be able to implement to write a kernel.
volatile would help here. It limits allowed optimizations. Also, C does have a limit on how one can convert between integers and pointers. The result is supposed to be unsurprising to one familiar with the architecture.
When things get bad enough, that is why Odin invented inline assembly.
On Thu, Feb 16, 2023 at 12:18 PM Chung Chung ctwo0002@gmail.com wrote:
Hi, I am wondering if anyone has successfully compiled latest kernel using clang,
I have not tried to build a kernel with Clang. However the LLVM devs have done it in the past.
Also see https://docs.kernel.org/kbuild/llvm.html . There are helpful links at the bottom of the page.
I have been having problem with it for the last few month, and here is the error that I have:
In file included from drivers/tty/tty_io.c:103: ./include/linux/termios_internal.h:37:5: error: conflicting types for 'user_termio_to_kernel_termios' int user_termio_to_kernel_termios(struct ktermios *, struct termio __user *); ^ ./include/asm-generic/termios.h:20:19: note: previous definition is here static inline int user_termio_to_kernel_termios(struct ktermios *termios,
It does not look like this issue has been reported in the LLVM kernel issue tracker at https://github.com/ClangBuiltLinux/linux/issues .
Jeff
On Thu, 16 Feb 2023, Chung Chung wrote:
Hi, I am wondering if anyone has successfully compiled latest kernel using clang, I have been having problem with it for the last few month, and here is the error that I have:
In file included from drivers/tty/tty_io.c:103: ./include/linux/termios_internal.h:37:5: error: conflicting types for 'user_termio_to_kernel_termios' int user_termio_to_kernel_termios(struct ktermios *, struct termio __user *); ^ ./include/asm-generic/termios.h:20:19: note: previous definition is here static inline int user_termio_to_kernel_termios(struct ktermios *termios,
Not enough is shown to be sure, but I think the problem is that a function is declared external not inline before being defined as static inline. My guess is that gcc accepts that without comment, even though it should not, and clang rejects it with a not-so-great error message.
Thank you for all the suggestions. I am going to try a few and let you guys know. Thanks again!!!
Chung