cross armhf tangle
Gary E. Miller
gem at rellim.com
Mon Feb 3 23:59:55 UTC 2025
Yo Hal!
On Sun, 02 Feb 2025 21:35:02 -0800
Hal Murray <halmurray at sonic.net> wrote:
> >> That was my first try. It didn't work on BSD.
> > Care to share what the failure was?
>
> It didn't know what a struct timeval was.
Did you set the required defines first?
Any place I can go to see the BSD man page and the include file contents?
> > Where can I find that man page?
>
> man timeval on this Linux box says:
> SYNOPSIS
> #include <sys/time.h>
Odd. Not on Gentoo. What linux are you on?
> Without the sys, it worked on Linux but not on BSD.
On Linux you usually need both.
> With the sys it works on everything I've tried so I moved on to other
> things.
If it is working, why are we talking about it?
> > Oh, now I have context. The only extra code for cross builds would
> > be the --march. When you use --march then /usr/include/sys may not
> > be used for <sys/time.h>. cc swaps sys directory to one approriate
> > to the target.
>
> Are you sure of that?
100%
> I don't understand this area.
It is a PITA.
> That's what I
> was expecting, but look in .gitlab-ci.yml in the cross-armhf area.
> There are a couple of runs that include:
> --cross-cflags "-I/usr/include/ -I/usr/include/python${pyver}"
> Isn't that using the same headers?
No. As I said in the part you trimmed, it is the "<sys/XXX.h>"
that gets swapped.
And, it is very, very, rare that you use your (usr/include) system
headers when cross compiling.
> My guess is that the same kernel header files work for all
> architectures and they are conditioned on #defines that the compiler
> provides.
But what if you are complaining for a BSD kernel on a Linux kernel?
Or building for a Linus 4.10 kernel on a 6.13 host? As many embedded
systems do. When cross-ccompiling you have to assume the worst.
> /usr/include/bits/timex.h has stuff like this
> # if defined __USE_TIME64_REDIRECTS || (__TIMESIZE == 64 &&
> __WORDSIZE == 32)
> Where do they come from?
Oh boy. You have not been following along. The short answer
is that variable starting with "__" are reserved for the system
and you should never touch tehem.
So don't touch them! Those are usually set from the --march=
option to fit the ABI.
> "gcc -dM -E -" tells you the compiler predefines. 397 of them on
> this box. But no __TIMESIZE or __WORDSIZE
1. You forgot the important part: --march=
2. gcc does not define them. The (proper) include files do, using
defines that gcc sets from the ABI (--marh-)
> [After more grepping...]
> /usr/include/bits/wordsize.h says
> /* Determine the wordsize from the preprocessor defines. */
>
> #if defined __x86_64__ && !defined __ILP32__
> # define __WORDSIZE 64
> #else
> # define __WORDSIZE 32
Note that x86_64 and ILP32 are part of the selected (--march) ABI.
> Similar stuff in /usr/include/bits/timesize.h
And a thousand other places. You are many layers away from user
configurable defines.
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
gem at rellim.com Tel:+1 541 382 8588
Veritas liberabit vos. -- Quid est veritas?
"If you can't measure it, you can't improve it." - Lord Kelvin
More information about the devel
mailing list