cross-compiling strace on non-Linux build
Alexey Neyman
stilor at att.net
Thu Jan 12 06:58:26 UTC 2017
Hi,
I've encountered a problem with cross-compiling strace - as a part of
crosstool-ng on MacOS [1]. While compiling ioctlsort.c, strace uses
CC_FOR_BUILD, so it wants to include <linux/ioctl.h> header from the
host - which is obviously missing on MacOS. Googling suggested replacing
<linux/ioctl.h> with <sys/ioctl.h> - but I think this is wrong, as this
will pick up build definitions and MacOS uses incompatible definitions
for IOC_* macros (different bit shifts and different values for
IOC_{READ,WRITE,VOID}).
I worked this around by creating a temporary include directory and
creating symlinks in that directory to {linux,asm,asm-generic}
directories in *host* header directory [2], so that <linux/ioctl.h> is
picked up from the host rather than from the build. This is a bit
awkward, but it works.
A better solution would be to modify strace makefiles to get these
headers from the host (e.g. by running CC-for-host with -E to generate a
"header" with the appropriate IOC_* definitions; or by adding these
definitions to the stuff gleaned by ioctl_*.sh from the Linux kernel
sources).
Thoughts? Suggestions?
Best regards,
Alexey.
[1]
https://github.com/crosstool-ng/crosstool-ng/issues/469#issuecomment-259840807
[2]
https://github.com/crosstool-ng/crosstool-ng/commit/c69e593a9272ad186b6669bc5b12886890cea7fe
More information about the Strace-devel
mailing list