Re: Building Elfutils with Mingw32

2023-09-13 Thread Ulf Hermann via Elfutils-devel

Hi,

keeping the windows/elfutils fork up to date definitely is a lot of 
work, which is why I haven't found the time to do it for a while. 
However, perfparser could in fact also use debuginfod (with some caveats).


I guess that some more of my patches could be upstreamed if properly 
cleaned up. A rebase rather than a merge may be more conductive to this.


All I can do right now is tell you that I'd be happy about any 
contribution. The repository I've been using still exists and accepts 
outside contributions. See 
https://codereview.qt-project.org/q/repo:qt-creator/elfutils . You have 
to go through the Qt CLA process to work with it, but the CLA is largely 
meaningless in this case. I'd be happy to move the repository to a more 
"official" place without CLA.


There have also been other people on this mailing list talking about 
porting elfutils to windows. Maybe if we combine our efforts we'll 
actually find a way to maintain a port.


best regards,
Ulf


Re: Building Elfutils with Mingw32

2023-09-14 Thread Ulf Hermann via Elfutils-devel
Indeed I have noticed the other patches, but I don't think they are the 
same as mine. So, now we have a three way merge.


I guess some more of the changes could be merged if properly cleaned up 
and made to benefit other obscure platforms, too. However, there are a 
few I got a definite "no" for. In particular the windows dance around 
text/binary mode when opening files was not welcome. I couldn't come up 
with a better solution than adding an O_BINARY or O_TEXT to every single 
open() call. We actually need the distinction as some files need to be 
opened in text mode for the tests to pass. If you can come up with 
anything better here, please let me know.


best regards,
Ulf


Re: Building Elfutils with Mingw32

2023-09-16 Thread Ulf Hermann via Elfutils-devel

Hi,

I'll answer some questions here:


Given that Windows doesn't even use ELF why would you even want elfutils on
such a platform?


There is a large number of developers who build software for ELF-based 
embedded systems on windows and test/debug/profile/deploy it over some 
network or USB connection. Those people want to have elfutils for their 
debugging and profiling. They want to use elfutils on the host (the 
windows box) because that is much faster.


Those people are not me and I'm not talking about sanity.

Qt Creator (the Qt IDE) has a profiling view that takes data produced by 
perf and paints pretty graphs from that. The actual perf data is 
recorded on the target (potentially an embedded device), then streamed 
or copied to the host, then run through perfparser to produce meaningful 
stack traces. perfparser uses elfutils for the actual work. That work is 
quite heavy. A sample frequency of 1000Hz is not uncommon. Few embedded 
device can do that "on the side" while still producing meaningful 
results for the actual task. Finally, Qt Creator takes the processed 
data and displays a UI to explore it. There is another UI for the same 
data, "Hotspot" by Milian, but I don't know if that can run on windows.



And why aren't people simply using cygwin for such a port?


If we built perfparser with cygwin, the people who use it would also 
need cygwin. People building embedded devices generally have a colorful 
mess of different tools, none of which you can rely on in advance. I 
haven't considered shipping cygwin with perfparser. Is that actually 
possible? It looks like it needs some installation procedure I would 
have to burden the user with.



Without it you don't even have a normal POSIX like system.


Indeed, but we have gnulib and the various adapters I wrote myself (some 
of which should probably be upstreamed to gnulib). That deals with the 
problem. We get binaries that only depend on a basic windows system.


This comes at the price of using the most basic C library that Microsoft 
offers, msvcrt.dll. In order to use the elfutils libraries built that 
way you have to jump through the open/close and malloc/free hoops we 
provide in eu_compat.lib. However, that is only a problem for perfparser 
or other software linked against elfutils, not for the user.



And when using mingw do people still use a normal gcc compiler (to cross
build)? Or is the goal to build with some alternative windows
compiler?


The gold standard would indeed be the ability to build it with Microsoft 
compilers and their associated C libraries. Then we could get  rid of 
the malloc/free and open/close hacks. However, given that Microsoft 
compilers have a rather different idea of C than elfutils, I didn't go 
there. Building it with gcc is more overhead for me when producing the 
binary. I cannot cleanly integrate it into the Qt Creator build system 
since that assumes it can use the same compiler for everything. However, 
for the users it doesn't make a difference.



But if there is consensus (among the Windows hackers) about using one
common target for the port then maybe we should have an official
branch on sourceware?


Such a thing would certainly be welcome from my point of view!


Also there is a mingw container setup on builder.sourceware.org which
we might use for doing CI on the port?
https://sourceware.org/cgit/builder/tree/builder/containers/Containerfile-fedora-mingw


I'll have to look at it in detail, but that also sounds great! So far 
there is no automated CI. I just run the tests manually when I change 
anything.


best regards,
Ulf


Re: Building Elfutils with Mingw32

2023-09-16 Thread Ulf Hermann via Elfutils-devel
I haven't considered shipping cygwin with perfparser. Is that actually 
possible? It looks like it needs some installation procedure I would 
have to burden the user with.


I guess shipping cygwin with perfparser would make me a 3PP [1]. Sounds 
like fun.


[1] https://www.cygwin.com/acronyms/#3PP


Re: Windows build of libelf (or more)?

2021-05-05 Thread Ulf Hermann via Elfutils-devel

The Qt project had some windows libraries:
https://code.qt.io/cgit/qt-creator/elfutils.git/
https://download.qt.io/development_releases/prebuilt/elfutils/


Those are somewhat outdated, unfortunately. Contributions through our 
code review system at https://codereview.qt-project.org are always 
welcome. See 
https://codereview.qt-project.org/q/project:qt-creator%252Felfutils for 
older changes, and please add me as a reviewer if you push something.


cheers,
Ulf