Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Translator instead of a compiler
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Gentoopc
Guru
Guru


Joined: 25 Dec 2017
Posts: 364

PostPosted: Fri Jul 26, 2024 7:32 pm    Post subject: Translator instead of a compiler Reply with quote

Hello, dear forum))) Tell me, is it possible that the user did not use gcc when building linux kernel modules? is it possible to use a translator? you write the module code to a file
Code:
module.txt
and when running the Linux kernel without reassembling, the code of the kernel module is processed by the translator. is it possible?
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1238
Location: Richmond Hill, Canada

PostPosted: Fri Jul 26, 2024 7:42 pm    Post subject: Re: Translator instead of a compiler Reply with quote

Gentoopc wrote:
Hello, dear forum))) Tell me, is it possible that the user did not use gcc when building linux kernel modules? is it possible to use a translator? you write the module code to a file
Code:
module.txt
and when running the Linux kernel without reassembling, the code of the kernel module is processed by the translator. is it possible?
Currently, Not possible. 8O
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22619

PostPosted: Fri Jul 26, 2024 7:43 pm    Post subject: Reply with quote

Yes, you can in some cases use clang instead of gcc to compile kernel modules. You must use the same compiler for both the kernel and the modules, and there may be some Kconfig options that clang does not handle. Support for that is much better in recent kernels, but I'm not sure if clang can be used for arbitrary kernel builds yet.

You can put your code in a file of any name you choose, but if it is not a known extension, you will need to tell the compiler what source language to expect.
Back to top
View user's profile Send private message
logrusx
Advocate
Advocate


Joined: 22 Feb 2018
Posts: 2405

PostPosted: Fri Jul 26, 2024 8:16 pm    Post subject: Reply with quote

If we want to be precise, the compiler is actually a translator. The term compiling came from the ancient days when you had to literally compile your program. I don't want to go in details because I don't really remember those days, but in general there were sheets of paper, punch cards, magnetic tapes and so on. Compilation refers more to the method of producing the source code than to the process of translating it to binary code.

So the programs we call compilers today are in reality translators.

The programs we call translators today are... well translators. The term translation means that one form of code is translated to another which covers source to binary translation and we only use compilation for that process for historical reasons, much like we use dye for integrated circuits and CPU's and similar things.

Technically it is possible to write a program that would run the kernel from source code, practically that would be wildly inefficient, would consume a terrible amount of memory and computing power and is in fact meaningless.

I guess you have an underlying idea or question that you think can be addressed through this question but you better ask the underlying question, you may receive more relevant answer.

Best Regards,
Georgi
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3421

PostPosted: Fri Jul 26, 2024 8:46 pm    Post subject: Reply with quote

Quote:
and when running the Linux kernel without reassembling, the code of the kernel module is processed by the translator. is it possible?
Like in: converting a C file into an interpreted batch script?

Anyway, this is probably the closest thing https://ebpf.io/what-is-ebpf/#jit-compilation
_________________
Make Computing Fun Again
Back to top
View user's profile Send private message
Gentoopc
Guru
Guru


Joined: 25 Dec 2017
Posts: 364

PostPosted: Fri Jul 26, 2024 9:25 pm    Post subject: Reply with quote

logrusx wrote:
If we want to be precise, the compiler is actually a translator. The term compiling came from the ancient days when you had to literally compile your program. I don't want to go in details because I don't really remember those days, but in general there were sheets of paper, punch cards, magnetic tapes and so on. Compilation refers more to the method of producing the source code than to the process of translating it to binary code.

So the programs we call compilers today are in reality translators.

The programs we call translators today are... well translators. The term translation means that one form of code is translated to another which covers source to binary translation and we only use compilation for that process for historical reasons, much like we use dye for integrated circuits and CPU's and similar things.

Technically it is possible to write a program that would run the kernel from source code, practically that would be wildly inefficient, would consume a terrible amount of memory and computing power and is in fact meaningless.

I guess you have an underlying idea or question that you think can be addressed through this question but you better ask the underlying question, you may receive more relevant answer.

Best Regards,
Georgi

I know how the assembly of the program takes place))) but many thanks for the clarification) the modules gather different, but this script as a result GCC and LD linquic still work. And in the end you get a binary file in one way or another. Well, I understand what an intracable is like on Python. If it were possible to work in this way with the text of the module program, then there are many pluses, it is a pity that they did not see. Thank you for going guys
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum