-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[qnx] Cross-compiling to QNX #1429
Comments
Same mistake! |
but, error: |
Ok, I did as you suggested, the thing compilers, but at the end of the compilation I don't get |
Hi , I am also trying to build this repo with Qnx/Arm. From where are you getting the Posix headers? I have a linux workstation, and all the low level headers are coming from:
If you could explain how did you get them on your system, would be great! |
I didn't have problems with headers as you describe. I use QNX Sofware
Development Platform 7.1. The compiler's name is
`aarch64-unknown-nto-qnx7.1.0-g++`
…On Mon, Sep 18, 2023 at 2:19 PM sebaleme ***@***.***> wrote:
Hi Ivica, I am also trying to build this repo with Qnx/Arm. From where are
you getting the Posix headers? I have a linux workstation, and all the low
level headers are coming from:
/usr/include/x86_64-linux-gnu/
When I build for QNX/Arm, I am not sure if these headers are provided by
the ccross-compiler, or if I need to download another repository (and
update my cmake configuration). Here is the list of headers that I need:
#include <bits/types.h>
#include <bits/types/sigset_t.h>
#include <bits/types/stack_t.h>
#include <sys/syscall.h>
#include <sys/ucontext.h>
If you could explain how did you get them on your system, would be great!
—
Reply to this email directly, view it on GitHub
<#1429 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACAJBL3V6NTUJMHC36FPYMTX3A35FANCNFSM6AAAAAA4QF47JM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
OK, thx, I found some. The ucontext.h header is in the crosscompiler folder, but the others are not available: Now, the main config is the access to PC register. In x86, this is as followed:
In my case, for arm, the REG_IP is not defined, so I have to find a workaround. I tried this and it did not work:
|
Ok. I see some interest in qnx and I have few hours I can spare to help. But I require someone to help me get qnx cross compilation toolchain or anything. Or pointers. I just got myself qnx account (they insist I register...) but I am frankly struggling to locate anything I can download. And instead of wasting more of my time, I think I'll just ask. So tell me how I can get qnx cross toolchain for GNU/Linux and I'll help you get gperftools building and maybe even running on this OS. |
Hi, thanks for the help. I am also using the QNX SDP 7.1. You can check anytime if your configuration is correct by calling the QNX compiler (qcc). Note that there is a license check when using it, so you need an active QNX license available on your host. However, I do not exactly know how to install manually the SDP, since it was preinstalled inside the (private) docker container I am using. |
okay. I think I'll eventually get it. This is what I am getting on their website :)
Well, I wait then. |
Hi, Then I had to modify the cmake, because some libraries could not link due to: First, I changed the cmakelist to only build what I need: 2 tests were still complaining:
I solved the first issue by adding the "pthread" dependency line 1298 (defined within the LIBPROFILER label). Now, for QNX/aarch64, it has not worked that easily. The main issue is how to access the PC, and here I can only guess how to do this. This code compile, but is it the correct reg?
Here are the steps I followed: And then, finally, the same error as everyone else: [ 18%] Built target tcmalloc_minimal_internal_object This error is not very bad, it just means that the qnx function signature from cfree is different in qnx than for the other systems.
And after few other deactivation, I am able to build the lib and link it to my application. However, testing on the target did not work.
|
So, to sum up, the questions would be:
My usecase is only to run the runtime profiling. If you could explain me the code, maybe I could also try other things by myself? |
@sebaleme I port some gperftool feature to qnx, heap profile and cpu profile. For selftest on qnx aarch64, just works. Porting already done:
For stacktrace with libunwindStill have some problem:
For stacktrace with generic_fpIt's just works and maybe not every backtrace info is correct. Because QNX aarch64, compiler default flags include Test with autoconf compile commandfrom #1147 (comment) ./configure --host=aarch64-unknown-nto-qnx7.1.0 --enable-frame-pointers CPPFLAGS="-D__NO_EXT_QNX -D_SC_NPROCESSORS_ONLN=91" |
Hi, thanks for the reply!! Now, when I run the profiler, it still generates an empty file, so some problem are still there. Can you share your config.h, I have the impression that cmake does not generate it properly:
|
@sebaleme generated config.h use autoconf build without libunwind config.h.txt |
Thanks for updates. So IMHO (emphasis on IMHO) there is no that much if any value for us trying to offer cpu profiler for qnx if they don't support cpu time timers (i.e. SIGPROF mentioned above). We do offer 'wall-clock' time profiling too, and it is occasionally useful. But in my experience only very few engineers know how to use it. I don't think people wanting to profile on QNX are likely among those few. Do I misunderstand anything ? Let me know what you think. |
I understand your position, properly support QNX would require some HW and QNX licenses (might not be possible for open source project). I would be ok if we just have the branch from @iDings classified as "experimental" for people like the ones in this discussion. |
OK, now I get something, but it looks like that. I would say the gperftools works, it is just that I get too much samples from idle cores which prevent me from focusing on my SW. I copied the libraries on my linux pc, and run pprof locally, so now it finds the most important stuff. Although I gave libc.so, it still can t tell me the function names, but it is possible that the libs running on the board are built in release, so no debug info are available. It would be useful to filter the core running my process, in order to have a more exploitable profiling result.
|
|
Ok. One question: when we use linux Perf, we start it like this: I am not sure how it works for gperftools, since the only parameter we have to give is $CPUPROFILE_FREQUENCY. How does gperf knows which process ID it has to monitore? My guess would be that we read during init on which core are running each threads, and then only profile these cores. It might also be possible that when the interruption occurs for reading the HW register, we only record the values if we are interrupting the process threads. I ask this, because I have the impression that the profiling is not working for QNX. When I use gperf on linux, all the samples are coming from my process, but the fact that I get only 10 samples over 170 000 about my process when profiling on QNX tells me that we might be profiling more than what we should be. When we checked the system loading with Momentics, we came to around 1 core utilisation (over 8), so I cannot believe that the 170 000 samples from libc are about idle cores. |
From my understanding, gperftools cpu profiler use timer, when you LD_PRELOAD libprofile.so or link libprofile to your application, and start application with
So it is maybe possible QNX always deliver the signal the some threads in process unevenly. this blog have some more informations. And it provide an proftest use SIGPROF, maybe modiffied to SIGALARM to test on QNX. |
uftrace is an nice function tracer tool to profile, with some more overheat but nice, but it use some linux features. unsure whether can be ported to QNX or not. The mcount part i think is same from compiler support, and QNX also have kernel trace api but totally different than linux. |
Ah, you mean that the profiler does not check each threads is equally represented in the trace. So if I have 3 threads, each loading a complete core, it is possible that I will not get the same number of samples for each of them. I thought that when the interruption occurs, we read the call stack from each thread. But maybe not, the interruption is only handled on one core, so only one thread is profiled. Another thing that I noticed. In my process, we are using some extern SW which creates many threads. So my program has 2 threads that I want to monitore, but due to the external libraries, I end up with around 15 threads within my process. It also explains why I get so many samples from unknown code. Is there a way to filter out which threads we want to monitore? |
Interruption mean timer irq? every core have an local timer, and for an application i think when enable timer, the timer is triggered on one core, and when timer expired, kernel deliver an signal to an thread of process, no matter which cpu core the choosed thread is running, kernel set an pending signal for it, and the choosed thread will handle it somewhere for example for linux is when thread have an syscall and when return to userspace will check pending signal. |
maybe this api, i am unsure. |
Some discussion. Let me answer to few things: a) yes, wall-clock time profiles are expected to get ticks into idle threads. My use of this mode usually involves heavy use of pprof's --focus and --hide options. I also highly recommend interactive UI which has all those features, since you will usually need quite some filtration to see anything. I usually spawn like this pprof --http=:0 . We also have internal filtering API. It is quite low-level. See ProfilerOptions struct in the header. And yes, this need for extensive filtering is why it is rarely good idea to do wall-clock time profiles. b) for the balancing issue. I.e. which thread gets signals, that usually works fine, but your experience may vary. Especially on uncommon OS. So I advice you to test (but not speculate). c) pprof indeed assumes some paths. But it has options. Check pprof --help. I think you'll need PPROF_BINARY_PATH to have it find various .so-s present in your profiles (the binary you already feed it via command line) d) for the symbolization, the troubles are expected. Because pprof uses addr2line (and possibly other tools) to convert offsets into binaries to functions+lines. So you'll need to point it to your platform's tools. Check PPROF_TOOLS environment variable for that. Have a nice day. |
Quick update. a) I took Xiang's first commit. And replaced second with my own. We now cleanly build for qnx with simple ./configure --host= b) I got academic qnx license, so I am able to compile. But I haven't yet figured out how to run this qnx code (there is some stuff that supposedly builds vm image but I am unable to make it work). So we should now have basic malloc (but not as quick as we have on other OSes due to lack decent TLS). This should give us heap profiling too and debug malloc, probably. As noted above, sadly I am unable to test. No cpu profiling patches landed yet. But as noted above, qnx can only support wall-time profiles, which is not nothing, but far from what people normally expect. So not sure if anyone wants more stuff added here or we can close the ticket. |
@alk Thanks for review and accept my patch. I had found my patch still have an issue if use Recently, I do some more analysis, and see some clues. @alk if you have any spare time, need your help to figure out the real reason about this issue. Then, i run the upper link command manually, but remove the magic empty I checked the generated libtool file, the |
So was I finally able to do vm image. It didn't like some qemu bits on my machine, so needed some help. So, for that -L thingy, I have it too. It is some sort of libtool bug. Basically, libtool.m4 writes part of configure script, which inspects the system (and --host arg) and writes ./libtool shell script specific to this specific setup. Then makefiles are using this shell script as a wrapper around building and linking to automagically handle shared libraries. I did a super-brief inspection and it appears to be inspecting compiler output of some sort and taking those -L args out of it. And then somehow it ends up with those bogus args. Might be worth filing ticket to libtool. Also, notably CXX=q++ doesn't work for me. Barks on -pthread. But if I manually unbreak ./libtool I am able to produce seemingly working binary. And malloc_bench runs a lot faster than whatever their libc does natively:
tcmalloc_unittests are passing too. \o/ |
Need config
|
tcmalloc is better than their builtin malloc obviously and absolutely. 💯 |
Below path can solve the probem, seems an unintentional mistake of libtool.m4.
|
Had submitted a patch to libtool: https://savannah.gnu.org/patch/?10411. |
Wow. Great. BTW it took me a bit to find what exactly did you change. So posting for others. x was added on the right side of 'test =' thingy. Indeed, looks like a simple and obvious bug even to my shell-ignorant eye. I'll see if I can "vendor" this fixed libtool temporarily. |
This blog https://www.vidarholen.net/contents/blog/?p=1035 have a really nice explanation about x-hack of shell. |
I wonder if we should officially close this perhaps ? |
I want to use the CPU profiler on QNX, but I cannot cross-compile it. I did the following
After make, I get the following error:
Is there a way to compile only CPU profiler for QNX instead of everything?
The text was updated successfully, but these errors were encountered: