openSUSE / hwinfo

Hardware information tool
GNU General Public License v2.0
255 stars 68 forks source link

Some questions about cross compiling hwinfo #107

Open meator opened 2 years ago

meator commented 2 years ago

Hello. I'm trying to cross compile hwinfo. I have noticed several things:

I'm not familiar with hwinfo's code nor its internal structure so I'm asking here for clarification.

I have two questions: Are there any other things that I should be aware of that might cause problems while cross compiling and are the three programs I mentioned above influenced the system (and its architecture) they are being run on?

About the second question: I'm compiling these three programs in host architecture, so the files can be generated, then I make the files with those programs, then I remove the host architecture programs and use the generated files while compiling hwinfo in target architecture. If the files generated by those three programs are architecture-dependent, then I will be mixing the generated files, which were generated by programs compiled in host architecture and the rest of the code, which is in compiled in target architecture, which is bad.

This is possibly related to #91.

wangzhixin2021 commented 2 months ago

Have you solved the cross compilation problem? I encountered the same problem.

meator commented 2 months ago

I have asked this question because I wanted to package hwinfo for Void Linux, which supports many architectures and libcs.

I have succeeded, you can see the void-packages package template here: https://github.com/void-linux/void-packages/tree/master/srcpkgs/hwinfo

My solution is far from a "clean" one. I had to make patches to the build system to use host installed built executables instead of those the build system tries to use (and can't, because cross compiled programs can't be executed on host).

As described in this issue, I use host compiled executables for check_hd, isdn_cdb and mk_isdnhwdb[^1]. I have asked in this issue whether the output of these programs is architecture dependent. My question remains unanswered, I assume that they aren't. If they are, a) the hwinfo Void Linux package is likely corrupted for architectures which require cross compilation b) fixing this would be difficult.

Rather than making complicated patches to the build system, it would be much easier for me to rewrite the build system altogether (I have experience with this). The Meson build system has a clean mechanism for intertwining host and target built executables and it is forthcoming to packagers. I don't think that there would be interest for introducing another build system to hwinfo, but if there is, I'd be willing to take a look at it. It looks like this project's needs exceed the capabilities of GNU Make.

[^1]: But I don't remember the details exactly, it has been a few years since I have worked with hwinfo in these ways. The build definition template will contain more accurate information.